ez.no / ezpublish / documentation / building an ez publish site / the news page / news archive
These documentation pages are no longer maintained. Please visit the new documentation site.
In the news archive, we simply wish to list all the news articles that have been published. The list should contain the headline/title of the articles and the date they were published.
We could produce the archive by overriding the folder class' standard full-view template within the news section. However, this template has already been overridden when we created a custom template for the news page. A possible solution is to create a new view. We'll call it "archive-view". The following text explains how to create a new view and how to make a custom template for it. In addition, the manual creation of an URL alias is also explained; we'll create a friendly URL for the news archive.
Creating a new view
The following text explains how to create a new view.
Creating a custom template
The following text explains how to create a custom template for the newly created view.
This will generate the "design/tscm/override/templates/archive_view_news_folder.tpl" template file. eZ publish will use this template every time it is instructed to display an archive-view of a folder within the News section. Put the following lines into the newly created template file:
<div class="pagetitle"> News archive </div> {* Grab all the news articles. *} {let children=fetch( content, list, hash( parent_node_id, $node.node_id, sort_by, $node.sort_array, class_filter_type, include, class_filter_array, array( 'article' ) ) ) } <table class="news_archive"> <tr> <td> <b>Article:</b> </td> <td> <b>Published:</b> </td> </tr> {* Loop through all articles that we just fetched. *} {section name=Child loop=$children} <tr> <td> {* Display a link to the article. *} <a href={$:item.url_alias|ezurl}>{$:item.name}</a> <br /> </td> <td> {* Display the date the article was published. *} {$:item.object.published|l10n(shortdate)} </td> </tr> {* End of loop. *} {/section} </table> {/let}
This code will take care of listing all the news articles that are published in a nice fashion.
Creating an URL alias for the News archive
At this point, the news archive can only be reached using a system URL that tells eZ publish which view to use and which node to show ("[...]/content/view/archive/[node-number]" - where [node-number] is the identification number of the node that "contains" the News folder object). In order to be able to reach the news archive using a friendly URL, we must manually create a URL alias for it. The following text explains how to do this.
What we have done is that we've instructed eZ publish to recognize the friendly URL, and when accessed, display the news archive. At this point, you should be able to access the news archive using both the system URL and the newly created virtual URL:
The following text explains how to create a link that can be used to access the news archive.
Creating the actual link to the archive
We will make the archive accessible from the bottom of the latest news page. Insert the following code at the end of the "design/tscm/override/templates/full_view_news_folder.tpl" file:
<br> <div class="center"> <a href={"/news/archive"|ezurl}> Click here to access the news archive... </a> </div>
Comments
In the "Old URL" field, type in: "/news/archive"?
sangib das
Thursday 23 February 2006 11:33:15 am
Can you tell me the "/archive" is predefined directory or create myself in root directory.
Thanks..........
Web directory you're altering
William Steenbergh
Monday 26 September 2005 2:56:08 pm
Setting this will add the template to your list (once returnng to the templates). It may not appear on the exact last page. If not, check the page before it.
Creating an URL alias for the News archive errata
Norbert Beckers
Wednesday 04 May 2005 4:08:09 pm
In step 6 it should say 'Virtual URL' where it reads 'Old URL'
/node/view/archive.tpl
David Goddard
Tuesday 05 April 2005 4:38:03 pm
Re: Can't locate "/node/view/archive.tpl"
Faust Gertz
Wednesday 29 December 2004 10:48:44 pm
http://[...]/index.php/tscm_admin/visual/templateview/node/view/archive.tpl
Can't locate "/node/view/archive.tpl"
Fredrik ohrberg
Wednesday 29 December 2004 1:58:44 am
Any ideas?
/Fredrik