problem with $view_parameters in cache

Author Message

Pierre SCALFATI

Sunday 04 October 2009 3:48:11 am

Hi all,

In my flat_left.tpl menu file I added the following in order to change css class depending on the href link I click on and which which link name is specified in my $view_parameters in URL.

Here's the code


		{def $current_year = currentdate()|l10n('shortdate')|extract(6,4)}
								
								{def $year_param = $module_result.view_parameters.year}
                                
                                
                                
								{if is_set($year_param)|not}
                                    {set $year_param = $current_year}
                                {/if}
                                
                                {def $current_node = fetch('content','node',hash('node_id', $module_result.content_info.node_id))}
                                
                                Archives                                 
                                {for $current_year to 2005 as $year}
                                	<a {if $year_param|eq($year)}class="selected"{/if} href="{concat($current_node.url, '/(year)/', $year)|ezurl(no)}">{$year}</a>
                                    {if $year|ne(2005)}-{/if}
                                {/for}

The aim of the above code is to check if there is a year specified as parameter in the URL. If there's a parameter specified in the URL, that means that the user has clicked on an archive Year and I must change the style of the link he clicked on to declare it as "selected', and this doesn't work.

This part of code if not working :

<a {if $year_param|eq($year)}class="selected"{/if} href="{concat($current_node.url, '/(year)/', $year)|ezurl(no)}">{$year}</a>
                                    {if $year|ne(2005)}-{/if}

The $year value stays on the first value loaded in cache and every time I click on a new value of year (or if I change it in the URL) it's alway this cached value which is selected... I tried to uncache the left menu using this

   {set-block scope=global variable=cache_ttl}0{/set-block}

... but it doesn't work.

A help would be appreciated as I spent a lot of time to try to find solution on ez.no without big success.

Many thanks to all of you.

Ivo Lukac

Sunday 04 October 2009 5:02:47 am

Left menu is not part of content so it is not cached with view cache. You need to look into pagelayout.tpl and flat_left.tpl to see which cache-block surrounds your code and add module_result.view_parameters.year into keys array of the cache block.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Pierre SCALFATI

Monday 05 October 2009 12:50:09 am

Many thanks Ivo, that's right and works correctly.

Cheers!!!

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:29:00
Script start
Timing: Jan 18 2025 11:29:00
Module start 'layout'
Timing: Jan 18 2025 11:29:00
Module start 'content'
Timing: Jan 18 2025 11:29:01
Module end 'content'
Timing: Jan 18 2025 11:29:01
Script end

Main resources:

Total runtime1.6468 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.0043 589.1484152.6250
Module start 'layout' 0.00430.0028 741.773439.4453
Module start 'content' 0.00711.6383 781.2188542.7578
Module end 'content' 1.64540.0013 1,323.976612.1563
Script end 1.6467  1,336.1328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.1938160.0002
Check MTime0.00130.0802160.0001
Mysql Total
Database connection0.00040.021510.0004
Mysqli_queries1.597797.0204570.0280
Looping result0.00070.0397550.0000
Template Total1.612997.920.8065
Template load0.00200.122320.0010
Template processing1.610997.821620.8055
Template load and register function0.00030.019910.0003
states
state_id_array0.00140.082610.0014
state_identifier_array0.00260.157520.0013
Override
Cache load0.00160.0952210.0001
Sytem overhead
Fetch class attribute can translate value0.00090.057320.0005
Fetch class attribute name0.00150.093940.0004
XML
Image XML parsing0.00080.046820.0004
class_abstraction
Instantiating content class attribute0.00000.000940.0000
General
dbfile0.00160.0994170.0001
String conversion0.00000.000540.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
6content/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
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs