Forums / Setup & design / "Read more..." link

"Read more..." link

Author Message

Franck T.

Thursday 19 August 2004 1:09:23 am

Hello everybody.
In my welcome page, I'd like to display a "Read more" link to an article. This is my code wich override the /node/view/full/tpl for my welcome page node.

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

The more important is the "Read more" link. When click I get... nothing than the same page, like a recursive call!
My (beginner) question is how to dispaly the full article when clicking on the link ?
And a second please: is there a way to display this kind of link depending on the article size? I mean display the link for long articles (more than 15 lines for example) and directly display the full content for short articles.
Thanks a lot.

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 !

eZ debug

Timing: Jan 19 2025 01:03:10
Script start
Timing: Jan 19 2025 01:03:10
Module start 'content'
Timing: Jan 19 2025 01:03:11
Module end 'content'
Timing: Jan 19 2025 01:03:11
Script end

Main resources:

Total runtime0.8103 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0082 588.8438180.8516
Module start 'content' 0.00820.6538 769.6953519.2578
Module end 'content' 0.66200.1483 1,288.9531337.5313
Script end 0.8102  1,626.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.5032210.0002
Check MTime0.00150.1903210.0001
Mysql Total
Database connection0.00160.193010.0016
Mysqli_queries0.735290.73071940.0038
Looping result0.00240.29711920.0000
Template Total0.778996.120.3895
Template load0.00210.261020.0011
Template processing0.776895.864920.3884
Template load and register function0.00020.018510.0002
states
state_id_array0.00120.142110.0012
state_identifier_array0.00080.097720.0004
Override
Cache load0.00170.2102300.0001
Sytem overhead
Fetch class attribute can translate value0.00210.257430.0007
Fetch class attribute name0.00200.246330.0007
XML
Image XML parsing0.00060.068730.0002
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00410.5095210.0002
String conversion0.00000.001230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs