ez.no / ezpublish / documentation / building an ez publish site / the news page / overview of the latest news
These documentation pages are no longer maintained. Please visit the new documentation site.
The main menu (just below the site-banner) contains a link called "News". When this link is accessed, eZ publish should display the seven latest news articles. We'll achieve this functionality by creating a custom version of the "Folder" content class' full-view template. The full-view template will list the children of the node that is being accessed. Each child will be shown using a custom line-view template.
Fixing the menu
First, we have to make sure that the link in the menu works. The following piece of code takes care of this:
<a href={"/news"|ezurl}>News</a>
Insert this code into the "pagelayout.tpl" file (replace the previous News-link). Note that we're not telling eZ publish the ID of the node that contains the "News" folder. We're using the URL alias of the "News" folder, which is "news". The URL alias is piped into the "ezurl" operator. The operator takes care of setting the correct path based on the siteaccess settings.
Browse the TSCM site. Click on the "News" link. eZ publish will then display the contents of the "News" folder using the standard full-view folder template. A standard line-view template will be used to display each child of the folder. The browser should display something that resembles the following screenshot:
Creating custom templates
The following text explains how to generate a custom full-view-template for the "Folder" content class within the "News" section.
This will generate an empty file ("design/tscm/override/templates/full_view_news_folder.tpl") and instruct eZ publish to use it every time a folder in the "News section" is viewed. Put the following lines into the file, raise the priority (with 1 being the highest), and clear the cache.
<h1>Latest news</h1> {* Grab some of the content of the node that is being viewed. *} {let children=fetch( content, list, hash( parent_node_id, $node.node_id, sort_by, $node.sort_array, limit, 7, class_filter_type, include, class_filter_array, array( 'article' ) ) )} {* LOOP: For each child of the node... *} {section name=Child loop=$children} {* Display the content of the child using a line-view template. *} {node_view_gui view=line content_node=$Child:item} <hr> {* End of loop. *} {/section} {* End of namespace. *} {/let}
This piece of template code does the following:
Try to access the "News" page again (either by refreshing the page or by clicking on the "News" link on the main menu). You should be presented with something like this:
The newly generated full-view template will automatically make use of the standard line-view template. The following text explains how to create a custom template for the line-view of the "Article" class within the "News section".
This will generate the "design/tscm/override/templates/line_view_news_article.tpl" template file. eZ publish will use this template every time it is instructed to display a list-view of article objects within the "News section". Put the following lines into the file:
<table class="latest_news"> <tr> <td colspan="2"> <div class="headline_link"> <a href={$node.url_alias|ezurl}> {attribute_view_gui attribute=$node.object.data_map.title} </a> </div> </td> </tr> <tr> <td> {attribute_view_gui attribute=$node.object.data_map.intro} </td> <td valign="top"> <a href={$node.url_alias|ezurl}> {attribute_view_gui attribute=$node.object.data_map.image image_class="small"} </a> </td> </tr> </table>
This code snippet takes care of getting and displaying some the contents of a news article. For each article, the headline, the intro and the article's thumbnail image is displayed. Browse the "News" page again. You should be looking at a page that resembles the following screenshot:
Comments
Watch out for permissions!
Ciprian Popovici
Friday 03 March 2006 10:05:25 am
http://ez.no/community/forum/setu...tes_being_created_in_wrong_directory
Apparently, ezPublish looks at the permissions of the design/ and settings/ files and subdirectories. If the user PHP runs as (httpd, usually) doesn't have full write access on both dirs and files, it will place the new override template where it has.
If you've been following this tutorial and at some point have created new siteaccesses, you most likely didn't place proper permissions on them. The proper permissions are 770 for directories and 660 for files. Go around design and siteaccess and do this:
find design/ -type f -exec chmod 660 {} \;
find design/ -type d -exec chmod 770 {} \;
(repeat for siteaccess/)
If you don't, here's what happens: when you click "New override", the message will say it's gonna place the new override in design/admin/override/templates instead of your design dir, and you'll spend a while wondering if perhaps you should select a different siteaccess from the "Set" dropdown list, and what happens if you have several siteaccesses, and so on.
The big gotcha is that the "Set" dropdown list is just a "view" filter, it doesn't decide where the new templete override goes. The folder permissions do.
Also a good idea would be to take a look here:
http://ez.no/community/forum/gene...t_tpl_and_site_css_strange_behaviour
...and make sure your AvailableSiteDesignList includes all your own designs, otherwise you may end up wondering why the template cache doesn't clear even if you clear it manually.
url alias /news -> /content/view/full/node_id
David Goddard
Wednesday 13 April 2005 12:29:56 pm
Transpires that automatic URL aliases are "generated from the object names of the parent object, i.e. the "path". It will convert the name to lower case 0-9 a-z and _ characters", when you include in site.ini
[URLTranslator]
Translation=enabled
So a folder just under the root node of "Archive of Old News Articles" can be referenced using the url alias path "/archive_of_old_news_articles".
See http://ez.no/community/forum/setup_design/nice_urls
and http://ez.no/ez_publish/documenta...ation/tips_tricks/creating_nice_urls
showing thumbnail image
Scott Madeira
Thursday 10 February 2005 4:24:16 pm
the second part is assigning an image to the news story. In the image section of the news story you need to "Find Object" and then click on the "Media Library" tab at teh top of the page and then click on the "Images" link in the middle of the page and then select the image you want to display.
Then you can send for publishing and it should show up properly. The directions don't really address the two different phases of associating and then assigning.
Hope that helps......
not showing thumbnail text
Erik Thorsen
Sunday 09 January 2005 12:45:46 pm
Anyone with any suggestions to fix this?
'line_view_news_article' final steps
Faust Gertz
Tuesday 28 December 2004 10:25:39 pm
Class dropdown menu doesn't have Folder or Article as in option in 3.5 RC1
Dave Myron
Friday 10 December 2004 2:21:37 am
This has been fixed in the trunk.