Forums / Setup & design / Change header image in pagelayout depending on content

Change header image in pagelayout depending on content

Author Message

Nabil Imran

Wednesday 18 March 2009 4:11:42 am

Hi,

I want to make the header image at the top of the page change depending on the current node or path.

As the header image is part of the pagelayout, I added some code to pagelayout.tpl, that searches for alternative header images in the current path ($module_result.path). If an image is found under any node of the current path, it will be displayed at the top of the page. Otherwise a default image should be shown.

- When I delete the cache and reload the page, it works perfectly.
- When I reload the page several times after that, it works perfectly as well.
- BUT if I wait for some hours, and reload the page again, it always shows the default image!
- When I delete the cache again, it starts working for some hours again ...

What coult that be??

The code for this is located in the pagelayout.tpl, above the menu and the actual content. It is NOT in any cache-block.

I think this is NOT a problem in my code, but more a problem of pagelayout concept, or cache

<b>Any idea what might be the cause of this strange behaviour?</b>

Thank you for any help!!

Here is the code (just for helping you to understand, what I am trying):


                {* look for banner images somewhere in the current path *}
		{def $path_node_ids = array()}
		{foreach $module_result.path as $path_part}
			{set $path_node_ids = $path_node_ids|append($path_part.node_id)}
		{/foreach}
		{def $banner=fetch( 'content', 'list', hash( 'parent_node_id', $path_node_ids,
		                                              'sort_by', array( 'depth', false() ),
		                                              'class_filter_type', 'include',
		                                              'class_filter_array', array( 'banner' ),
		                                              'limit', 1 ) ) }
                {* if there is none, show default image *}
		{if not($banner[0])}
			{set $banner = fetch( 'content', 'list', hash( 'parent_node_id', ezini( 'NodeSettings', 'RootNode', 'content.ini' ),
		                                              'sort_by', array( 'depth', false() ),
		                                              'class_filter_type', 'include',
		                                              'class_filter_array', array( 'banner' ),
		                                              'limit', 1 ) ) }
		{/if}
                {* show the image*}
		{node_view_gui view='line' content_node=$banner[0] id='headerimage'}
		{undef $banner}

 

eZ debug

Timing: Jan 18 2025 14:51:13
Script start
Timing: Jan 18 2025 14:51:13
Module start 'content'
Timing: Jan 18 2025 14:51:13
Module end 'content'
Timing: Jan 18 2025 14:51:14
Script end

Main resources:

Total runtime0.1509 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.0703180.8125
Module start 'content' 0.00540.0058 769.882893.9609
Module end 'content' 0.01120.1396 863.8438525.3750
Script end 0.1508  1,389.2188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00332.1707200.0002
Check MTime0.00130.8859200.0001
Mysql Total
Database connection0.00070.444710.0007
Mysqli_queries0.108772.05901410.0008
Looping result0.00181.16011390.0000
Template Total0.139292.310.1392
Template load0.00070.447510.0007
Template processing0.138691.840610.1386
Override
Cache load0.00050.308210.0005
Sytem overhead
Fetch class attribute can translate value0.00090.584610.0009
XML
Image XML parsing0.00030.218710.0003
General
dbfile0.00251.6890200.0001
String conversion0.00000.003330.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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