static cache - generate sibling node

Author Message

stephane couzinier

Friday 23 February 2007 5:56:05 am

I need to find away to generate the sibling node of an object.
In 1 folder I have 3 articles, on each article page I put:
- 2 links next and previous news.
- the position of the news
On the first news I have only 1 link Next news
On the last there is only the link Previous news.

don't flush the cache

Betsy Gamrat

Saturday 24 February 2007 8:06:48 am

Hi,

I did something similar on http://www.thepulsenetwork.com/healthcare_news/breaking_news_nursing/institute_for_johns_hopkins_nursing_to_offer_nurse_practitioner_continuing_education/(item)/3.

I added an additional view parameter to the folder template, called <b>item</b>. If <b>$view_parameters.item</b> is set, the folder displays that item (for example the fourth child), and the navigation displays options to view the previous item, the list, or the next item. It will observe the number of children in the list - so previous and next are only displayed if they are valid.

At the top of <b>full_folder.tpl</b>, I added the following code. It uses <i>(item)/4</i> to indicate that it is supposed to display the fourth child of the folder. As you can see, instead of displaying the folder contents, it displays the requested node.

{if is_set($view_parameters.item)}
            {node_view_gui content_node=fetch_alias( children, hash( parent_node_id, $node.node_id,
                                                             offset, $view_parameters.item,limit,1,
                                                             sort_by, $node.sort_array)).0 item=$view_parameters.item view=full}
{else}

The site has a sub_navigation template, which provides navigation in the lefthand column, and is included into <b>pagelayout.tpl</b>. It will list all the children of a node, unless there is an <b>item</b>, in which case, it provides the item relative navigation. One note, the content class this is running with is <i>rss</i>. Be sure to change that to work on your site. Substitute your content class name for <i>rss</i>.

{if $node_id|ne(false)}
	{def $item_parm=-1 $item_parm_flag=false()}
	{if is_set($view_parameters.item)}
		{set $item_parm=$view_parameters.item}
		{set $item_parm_flag=true()}
                                {set-block scope=root variable=cache_ttl}0{/set-block}
	{/if}
	{def $n=''}
	{if $module_result.content_info.parent_node_id|ne(2)}
		{if and($module_result.content_info.class_identifier|eq('folder'),$item_parm_flag)}
			{set $n=$module_result.content_info.node_id}
		{else}
			{set $n=$module_result.content_info.parent_node_id}
		{/if}
	{else}
		{set $n=$module_result.content_info.node_id}
	{/if}
	{def $node_data=fetch(content,node,hash(node_id,$n))}
        <h2>{$node_data.name}</h2>
        <div class="pp_subnavitem">
	{if and($module_result.content_info.class_identifier|ne('rss'),not($item_parm_flag))}
		{def $list_items=fetch_alias( children, hash( parent_node_id, $n,'sort_by',array('priority',true())))}
		{def $list_count=fetch_alias( children_count, hash( parent_node_id, $n ) )}
                	{section var=child loop=$list_items}
				{if $child.node_id|ne($node_id)}
					{if $child.object.class_identifier|ne('link')}
						<a href={$child.url_alias|ezurl} title="{$child.name}">{$child.name}</a>
					{else}
						<a href={$child.data_map.location.content|ezurl} title="{$child.name}">{$child.name}</a>
					{/if}
				{else}
					<p>{$child.name}</p>
				{/if}
	               	{/section}
	{else}
		{if $item_parm_flag}
			{def $item_offset=0}
			{if $item_parm|gt(0)}
				<a href={$node_data.url_alias|concat('/(item)/',$item_parm|dec)|ezurl} title="Previous article">Previous Article</a>
			{/if}
			{if $item_parm|gt(10)}
				{set $item_offset=$view_parameters.item|mod(10)}
				{set $item_offset=$view_parameters.item|sub($item_offset)}
			{/if}
			<a href={$node_data.url_alias|concat('/(offset)/',$item_offset)|ezurl} title="Return to listing page">Article List</a>
			{if $node_data.children_count|dec|gt($item_parm)}
	                        <a href={$node_data.url_alias|concat('/(item)/',$item_parm|inc)|ezurl} title="Next article">Next Article</a>
			{/if}
		{/if}

	{/if}
	{undef $item_parm $item_parm_flag $item_offset $n $node_data}
	</div>
{/if}

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:23:58
Script start
Timing: Jan 18 2025 11:23:58
Module start 'layout'
Timing: Jan 18 2025 11:23:58
Module start 'content'
Timing: Jan 18 2025 11:23:58
Module end 'content'
Timing: Jan 18 2025 11:23:58
Script end

Main resources:

Total runtime0.0167 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.1563152.6406
Module start 'layout' 0.00640.0028 741.796939.4766
Module start 'content' 0.00920.0050 781.273493.4922
Module end 'content' 0.01420.0024 874.765634.3047
Script end 0.0166  909.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002514.9963140.0002
Check MTime0.00116.8868140.0001
Mysql Total
Database connection0.00148.204010.0014
Mysqli_queries0.002414.310530.0008
Looping result0.00000.090210.0000
Template Total0.002012.010.0020
Template load0.00095.681210.0009
Template processing0.00106.288310.0010
Override
Cache load0.00063.878610.0006
General
dbfile0.00031.683880.0000
String conversion0.00000.054440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs