Lesson 2: Modifying a section of a page
Overriding a view is covered in this lesson.
Problem
There is a section of the Elgg page structure that you want to change. Perhaps you want to include an ad in the footer or rearrange the topbar. You could search for that specific HTML code in Elgg and hack it to get what you want, but then upgrades to the latest version of Elgg would be difficult. You want to do this the right way.
Solution
Elgg divides up its page structure into views. As we discussed in the last chapter, a view is a chunk of HTML code. The topbar and header are views. The search box is a view inside the header view. By changing one of these views, we change every Elgg page that uses it. With Elgg, the primary way to change a view is to override it. Overriding a view results in our HTML replacing the HTML of the core view.
Example
The default Elgg theme has a header with the site name, a search bar, and a set of menu tabs:
We are adding a tagline below the site name, as shown in the following...