Forums / Developer / problem with $view_parameters in cache

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!!!

eZ debug

Timing: Jan 18 2025 05:21:18
Script start
Timing: Jan 18 2025 05:21:18
Module start 'content'
Timing: Jan 18 2025 05:21:19
Module end 'content'
Timing: Jan 18 2025 05:21:19
Script end

Main resources:

Total runtime0.9066 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.0058 587.7344180.8281
Module start 'content' 0.00580.7852 768.5625543.8359
Module end 'content' 0.79100.1155 1,312.3984332.7734
Script end 0.9065  1,645.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4435210.0002
Check MTime0.00150.1678210.0001
Mysql Total
Database connection0.00060.065410.0006
Mysqli_queries0.842092.87261940.0043
Looping result0.00180.19761920.0000
Template Total0.879497.020.4397
Template load0.00220.243520.0011
Template processing0.877296.758020.4386
Template load and register function0.00020.021210.0002
states
state_id_array0.00090.094810.0009
state_identifier_array0.00160.172220.0008
Override
Cache load0.00180.2029210.0001
Sytem overhead
Fetch class attribute can translate value0.00100.111030.0003
Fetch class attribute name0.00080.091940.0002
XML
Image XML parsing0.00090.101930.0003
class_abstraction
Instantiating content class attribute0.00000.000940.0000
General
dbfile0.00270.2942280.0001
String conversion0.00000.000530.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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