Share » Forums » Setup & design » "Read more..." link

"Read more..." link

"Read more..." link

Thursday 19 August 2004 1:09:23 am - 2 replies

Author Message

Trond Åge Kvalø

Thursday 19 August 2004 1:56:41 am

Hi

The $node variable gives you the current node object. So $node.url_alias|ezurl points to the page you are currently on. That's correct behaviour on eZ's side here.

Now usually you place your articles in for instance a news folder. Let's pretend that the node_id of this news folder is 42. Then you fetch all the articles that resides in that folder by using the fetch function like this:

{let articles = fetch( 'content', 'list', hash( 'parent_node_id', 42) ) }

Now all the articles are placed in an array called articles. The next thing to do will be to loop through that array and extract the needed information. For that we use the template function "section". If we want to show Title, Publish date, Intro and a link to the article on the front page, this is how we do it:

{section loop=$articles}
<div class="pagetitle">
    {attribute_view_gui attribute=$:item.object.data_map.title}
</div>
{$:item.object.published|l10n(date)}
{attribute_view_gui attribute=$:item.object.data_map.intro}
{section show=$:item.object.data_map.body.content.is_empty|not}
  <div class="attribute-link">
    <p><a href={$:item.url_alias|ezurl}>{"Read more..."|i18n("design/base")}</a></p>
  </div>
{/section}
{/section}

Since we're looping an array here, I have replaced $node with $:item which is the current item in the loop. Thus you will display the article's attributes instead of the current node's attributes. This assumes that the articles have class attributes named Title, Intro, Image and so on.

A bit elaborate answer here, but the bottom line is: To show the full article you must use the article's link instead of the current node's link. To show the article's link you must first fetch the article(s) and place it in a variable. Then you must extract the correct data from this variable.

Useful links:
http://ez.no/ez_publish/documentation/reference/data_fetching/content
http://ez.no/ez_publish/documentation/reference/data_fetching/content/list
http://ez.no/ez_publish/documentation/customization/custom_design/variables_arrays_and_objects (First paragraph)

best regards
trondåge

trondåge

Franck T.

Thursday 19 August 2004 3:32:44 am

Thanks Trondåge for responding so brightly. You might be a good teacher...
I understand what you explain but there is still something odd: the article's link I get with your code AND my current position as displayed in my browser's adress bar <b> are the same ! </b>
So when I click on the link it moves to the place I'm already, just showing me the link but not the full article !!!!
'Going mad with this. Please tell me what to do !

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu