Forums / Install & configuration / static cache - generate sibling node

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}

eZ debug

Timing: Jan 18 2025 16:12:06
Script start
Timing: Jan 18 2025 16:12:06
Module start 'content'
Timing: Jan 18 2025 16:12:07
Module end 'content'
Timing: Jan 18 2025 16:12:07
Script end

Main resources:

Total runtime0.7178 sec
Peak memory usage4,096.0000 KB
Database Queries191

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0085 588.9531180.8203
Module start 'content' 0.00850.5536 769.7734547.4766
Module end 'content' 0.56210.1556 1,317.2500336.7500
Script end 0.7177  1,654.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.5584210.0002
Check MTime0.00150.2110210.0001
Mysql Total
Database connection0.00100.144610.0010
Mysqli_queries0.644989.84581910.0034
Looping result0.00200.27171890.0000
Template Total0.681594.920.3407
Template load0.00170.235720.0008
Template processing0.679894.701220.3399
Template load and register function0.00020.025810.0002
states
state_id_array0.00150.211810.0015
state_identifier_array0.00090.131920.0005
Override
Cache load0.00130.1864180.0001
Sytem overhead
Fetch class attribute can translate value0.00190.268630.0006
Fetch class attribute name0.00130.177530.0004
XML
Image XML parsing0.00090.128630.0003
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00300.4213270.0001
String conversion0.00000.001330.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/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: 11
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs