previous / next - fetch

Author Message

fabian schoen

Monday 13 November 2006 8:56:34 am

Hi

Maybe I overseen it in the documentation, but is there an easy implementation of a next/previous navigation?

I created an own template which performs a fetch to get 7 (for example) node objects. The first one (A) is shown on the screen. Now I would like to implement the function to use a "next" link to go to the next node (B).
Do I have to perform a second fetch or can I read it from an attribute, which one is the next and which is the previous one?

thanks
fabian
3.6.10

Georg Franz

Monday 13 November 2006 10:14:58 am

Hi,

yes, in an image template, there is an prev / next code, but it contains a bug:
http://issues.ez.no/IssueView.php?Id=9160&activeItem=6

design/base/templates/override/full/image.tpl

It is working if you don't sort the items in the folder by name.

If you need to sort the items by name, there is a workaround:

{def $content_list=fetch( content, list, hash( parent_node_id, $node.parent_node_id,
                                                sort_by, $node.parent.sort_array ) )
     $current_pos=0
     $previous_image=false()
     $next_image=false()
     $content_count=$content_list|count}
{foreach $content_list as $key => $item}
	{if eq($item.node_id,$node.node_id)}{set $current_pos=$key}{/if}
{/foreach}
{if $content_count|gt(1)}
	{if $current_pos|gt(0)}{set $previous_image=array($content_list[sub($current_pos,1)])}{else}{set $previous_image=array($content_list[sub($content_count,1)])}{/if}
	{if sum($current_pos,1)|lt($content_count)}{set $next_image=array($content_list[sum($current_pos,1)])}{else}{set $next_image=array($content_list[0])}{/if}
{/if}

But this code isn't good because you need to fetch each element in the list to find out which is previous and which is next.

Hope that helps.

Best wishes,
Georg.

--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004

fabian schoen

Monday 13 November 2006 1:46:24 pm

Thanks Georg. Works

regards
fabian

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 15:50:59
Script start
Timing: Jan 18 2025 15:50:59
Module start 'layout'
Timing: Jan 18 2025 15:50:59
Module start 'content'
Timing: Jan 18 2025 15:51:01
Module end 'content'
Timing: Jan 18 2025 15:51:01
Script end

Main resources:

Total runtime1.8621 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.3359152.6250
Module start 'layout' 0.00660.0029 741.960939.4297
Module start 'content' 0.00951.8511 781.3906536.0469
Module end 'content' 1.86060.0015 1,317.437512.1875
Script end 1.8621  1,329.6250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.1860160.0002
Check MTime0.00150.0817160.0001
Mysql Total
Database connection0.00140.074910.0014
Mysqli_queries1.805996.9781570.0317
Looping result0.00070.0369550.0000
Template Total1.825198.020.9126
Template load0.00200.107420.0010
Template processing1.823197.903520.9115
Template load and register function0.00020.010010.0002
states
state_id_array0.00110.060010.0011
state_identifier_array0.00530.282220.0026
Override
Cache load0.00160.0873250.0001
Sytem overhead
Fetch class attribute can translate value0.00110.059420.0006
Fetch class attribute name0.00160.087040.0004
XML
Image XML parsing0.00080.044520.0004
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00130.0684160.0001
String conversion0.00000.000340.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs