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}

 

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 18:40:52
Script start
Timing: Jan 18 2025 18:40:52
Module start 'layout'
Timing: Jan 18 2025 18:40:52
Module start 'content'
Timing: Jan 18 2025 18:40:52
Module end 'content'
Timing: Jan 18 2025 18:40:52
Script end

Main resources:

Total runtime0.7689 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0042 589.2734152.6563
Module start 'layout' 0.00420.0028 741.929739.5078
Module start 'content' 0.00700.7603 781.4375411.4844
Module end 'content' 0.76740.0015 1,192.92198.1094
Script end 0.7689  1,201.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.3895160.0002
Check MTime0.00120.1603160.0001
Mysql Total
Database connection0.00050.062210.0005
Mysqli_queries0.730294.9637460.0159
Looping result0.00050.0667440.0000
Template Total0.743796.720.3718
Template load0.00230.293320.0011
Template processing0.741496.418420.3707
Template load and register function0.00020.023310.0002
states
state_id_array0.00120.152410.0012
state_identifier_array0.00060.083920.0003
Override
Cache load0.00180.2317170.0001
Sytem overhead
Fetch class attribute can translate value0.00080.099210.0008
Fetch class attribute name0.00060.073010.0006
XML
Image XML parsing0.00010.012110.0001
class_abstraction
Instantiating content class attribute0.00000.000410.0000
General
dbfile0.00060.0825100.0001
String conversion0.00000.001440.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
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.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: 7
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs