- Table of Contents
- 5.2.4.1. The 'Feature' article of the section
- 5.2.4.2. Displaying only the most recent feature article on a section page
- 5.2.4.3. Including Images in the Section Listing
The main function of the section page is to provide a table of
content for all articles in a section. By default all sections share
the same template but it is possible to set separate template for each
section. Or, you can use one general section template, which will then
call different sub-templates, depending on the environmental variables
as described above. For example, you can have a different navigations
for the sports and the politics sections.
We'll divide the section page into four zones: header, left menu, content and footer, like in the picture below:
First we include the header template, which is common to all publication pages:
<!** include header.tpl>
Next, we build the left menu:
- create links to other sections:
<!** list section>
<a href="<!** uri section>"><!** print section name></a>
<!** endlist>
- list available articles in the section:
<!** list article>
<a href="<!** uri article>"><!** print article name></a>
<!** endlist>
This
will list all articles in the section. The 'list article' command
already knows what section to list. The second line will create the
link, using the name of the article. To close the listing, use the 'endlist' tag. This
example will order the articles in no particular way. If you want to
make sure the newest article is on the top of the list, you need to
tell Campsite to order the listing:
<!** list article order bynumber desc>
Now we can build the section content by printing a short descriptioin of articles selected to be highlighted on the section page:
<!** list article onsection is on>
<p><a href="<!** uri article>"><!** print article name></a></p>
<br>on <!** print article date>, by <!** print article author>
<br><!** print article intro>
<!** endlist>
The first line will create a list of articles that have "Show article on section page" option checked. Then we create a link to the full article content (line 2), display the article date and author (line 3) and finally the short description (line 3).
The last thing to do is include the footer:
<!** include footer.tpl>
Templates header.tpl and footer.tpl are not explained here. You can learn how to build a header template in the chapter 5.2.5. Building the home page template. For more details on the section page code download the demo templates from Campsite download page.
add a note
User Contributed Notes
5.2.4. Building a Section Template
There are no user contributed notes for this page.