Author
|
Message
|
David Jones
|
Friday 15 September 2006 8:59:47 am
At least I think it is... The first time I access a page after clearing the cache I can see the content of the objects being displayed. However, if i refresh the page, or click away and come back, the content has vanished and I need to clear the cache again to have the content display. I'm sure I've missed something simple (and fundermental). Help! Thanks
|
Claudia Kosny
|
Friday 15 September 2006 12:10:50 pm
Hello David
Do you try by any chance to access the variable $node in the pagelayout.tpl? If yes, read this post http://ez.no/community/forum/setup_design/page_refresh_causes_custom_meta_tags_etc_to_disappear If this is not the problem try to find out which part of the code does not work after the cache reload. Then post this part here so we can have a look at it. Greetings from Luxembourg Claudia
|
David Jones
|
Monday 18 September 2006 2:18:37 am
It looked like that might be the problem. My pagelayout starts with {def $pagelayout_node=fetch(content,node,hash(node_id,$module_result.node_id))}
Which became {let $nd_id=$module_result.node_id}
{def $pagelayout_node=fetch(content,node,hash(node_id,$nd_id))}
But the problem persists
|
Claudia Kosny
|
Monday 18 September 2006 12:22:37 pm
Hi David Hmm, both version look nice to me. Not sure why this is not working or you. Do I understand you right that $module_result.node_id is empty after reload? Is there any data in the module_result at all? Claudia
|
Norman Leutner
|
Tuesday 19 September 2006 12:04:21 am
Hi David, I think the problem is not your pagelayout which seems to be correct.
Some variables are only existing within the pagelayout and not within all templates. Unfortunately this does only take effect after the cache was generated. In general you have this behavior if you try to fetch the content by a variable (node id) which is empty after the cache is generated.
Mit freundlichen Grüßen
Best regards
Norman Leutner
____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh
|
Norman Leutner
|
Tuesday 19 September 2006 12:06:38 am
Here some more additional information about the variables set by ez: http://ez.no/products/ez_publish/documentation/customization/custom_design/template_variables_set_by_ezpublish
Mit freundlichen Grüßen
Best regards
Norman Leutner
____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh
|
David Jones
|
Tuesday 19 September 2006 5:53:17 am
That just seems really daft. Can i stop it useing th cache?
|
Norman Leutner
|
Tuesday 19 September 2006 6:14:48 am
The cache settings are controlled within the site.ini but it's not recommended to disable the cache.
Mit freundlichen Grüßen
Best regards
Norman Leutner
____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh
|
David Jones
|
Tuesday 19 September 2006 7:13:59 am
Yeah, I noticed that :o) OK, here is something specfic that maybe you can help with. On my news listing page I want to output a number of stories and then some page links to the rest. I have this code: {def $offset=0
$limit=2}
{if is_set($view_parameters.offset)}
{set $offset=$view_parameters.offset}
{/if}
{def $meny=fetch('content','list',
hash( 'parent_node_id', $node.node_id,
'limit', $limit,
'offset', $offset ))}
{def $meny_count=fetch('content','list_count',
hash( 'parent_node_id', $node.node_id ))}
<div id="col2List">
<h3>Other Stories</h3>
<ul>
{foreach $meny as $element}
<li><a href={$element.url_alias|ezurl()}>{attribute_view_gui image_class=original attribute=$element.children[1].data_map.image.content.data_map.image}</a>
<div id="col2ListIndent">
<span class="title"><a href={$element.url_alias|ezurl()}>{attribute_view_gui attribute=$element.object.data_map.date} - {attribute_view_gui attribute=$element.object.data_map.title}</a></span>
<span class="desc"><a href={$element.url_alias|ezurl()}>{attribute_view_gui attribute=$element.object.data_map.main_text}</a></span></div>
</li>
{/foreach}
</ul>
</div>
This code shows the caching problem. I.e. it disappears on reload. As is my understanding this is caused by the use of $node here {def $meny=fetch('content','list',
hash( 'parent_node_id', $node.node_id,
'limit', $limit,
'offset', $offset ))}
{def $meny_count=fetch('content','list_count',
hash( 'parent_node_id', $node.node_id ))}
I have tried replacing this with $pagelayout_node.node_id which does stop the content dissappearing but also prevents the pagination working properly. The URL changes to /(offset)/2 but displays the content from the first page. THe pagination works if I $node but only for one page load. Any ideas, thanks for you help. PS the image doesnt display either but that is an issue for another day *smile*
|
Norman Leutner
|
Tuesday 19 September 2006 8:43:25 am
Using $node.node_id should work fine within your template. What happens if you set the Cache time to 0?
{set-block scope=root variable=cache_ttl}0{/set-block}
Have you ever tried setting a specific cache block within the pagelayout.tpl?
More information here on cache blocks: http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_functions/miscellaneous/cache_block This should work fien for your images:
{attribute_view_gui image_class=original attribute=$element.data_map.image
href=$element.url_alias|ezurl()}
instad of
<a href={$element.url_alias|ezurl()}>{attribute_view_gui image_class=original attribute=$element.children[1].data_map.image.content.data_map.image}</a>
Mit freundlichen Grüßen
Best regards
Norman Leutner
____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh
|
David Jones
|
Tuesday 19 September 2006 11:19:59 am
Thanks for your help. Using $node leave me with the dissappearing content problem. You image code gives me nothing. I've never tried setting a cache block, ill look into that. It seems I'm not having much luck :o(
|
André R.
|
Tuesday 19 September 2006 12:20:46 pm
Hi David. If the code you where posting is inside a node template and not a page template using $node should not be a problem. Have you tried turning debugoutput and templatedebug on and look for warnings / errors ?
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom
|
Claudia Kosny
|
Tuesday 19 September 2006 12:28:46 pm
Hello David
I think there is a bit of confusion here so I'll try to clarify a bit: It is not possible to use $node in the pagelayout.tpl. If you want to use it there you have to fetch the node again by using $module_result.node_id (which will only be filled if you are viewing a node). If you use another template using $node should work just fine provided there is a node to view (no matter what the cache settings are). Every item you can see in the treemenu in the admin view is such a node. When you call up a template for such anode EZ fills the variable $node with the information about this item. An example for a template which does not have a node is the basket (or the confirmorder, I forgot).
So if your code is part of the pagelayout you have to use $module_result.node_id (as far as I know there is no variable $pagelayout_node.node_id). If it is in a separate template I am wondering now how you call up this template. Do you include it from within another template? Please elaborate on that if this is the case. Now to the problem with the pagination: At the beginning of you code insert the line
{$view_parameters|attribute('show', 2)}
This will show you the content of the view_parameters variable. Does offset have a value in there? Depending on how you call up the template the view parameters might not survive. This happesn especially if you include this template in another template as in this case the other template recieves the view parameters and has to relay them to the included template (check the doc for include if necessary).
Regarding the image problem: Normans code displays the image of $element, not of the first child. So you might want to try this:
{attribute_view_gui attribute=$element.children[0].data_map.image
href=$element.children[0].url_alias|ezurl()}
Although please note that the children array of a node might not be sorted according to whatever sort order you have defined for this node. If the sort order matters you have to fetch the first child node using the fetch function as you can sort there.
So if the problems persist please tell us
- in which template is the code is gave us?
- how do you call up this template? (best give the precise codeline and/or an example url)
- what is the content of $view_parameters if you use the pagination?
- are there any interesting infos in the debug output? - whatever interesting info you come up with Greetings from Luxembourg Claudia
|
David Jones
|
Wednesday 20 September 2006 5:54:08 am
Claudia, Thanks again for all your time. The problem seems to be that the $view_parameters does not persist once the cache kicks in. It has no attirbutes at all. My template, called listing, is an overide for pagelayout.tpl thanks
|
Claudia Kosny
|
Wednesday 20 September 2006 12:58:41 pm
Hmm, I am not sure whether this is a bug or whether view_parameters are only provided by the module responsible for viewing content. I suggest to file a bug report about the disappearing view_parameters and see what happens.
So at the moment it looks like there is no way to do what you want to do in the way that you are doing it as long as caching is enabled (which it should be).
The only way out I can see right now is to put the code in another template which is called like anode template. Depending on how your main page is supposed to look like there are two variations:
If your entire startpage consists of the listing and no other dynamic content and the listing is not supposed to appear on any other pages, just put your code into an override for node 2 (or whatever you starting node is). There you can use $node.node_id and everything should be fine. If the listing is supposed to appear on all pages you need to include the listing template on all templates you use and replay the offset to the included template. Unfortunately this can be a nightmare with regards to design and maintenance so hopefully some has a better solution... Alternatively you might need to change your site concept a bit. Display only the first few items on the frontpage and provide a link to another page which shows all items. This is the easiest solution and fairly standard for EZ so you should not run into any problems there. Good luck Claudia
|
David Jones
|
Thursday 19 October 2006 2:39:14 am
Hi Claudia, Sorry, I've only jsut got back to this one. I seem to have problems with everything I touch in ezp. It's safe to say I'm less than a fan *smile* Anyway, I'm sorry, I don't quite understand what it is you think I should try to do. Below is the code for the relevant part of the page
{def $offset=0
$limit=2}
{if is_set($view_parameters.offset)}
{set $offset=$view_parameters.offset}
{/if}
{def $meny=fetch('content','list',
hash( 'parent_node_id', $module_result.node_id,
'limit', $limit,
'offset', $offset ))}
{def $meny_count=fetch('content','list_count',
hash( 'parent_node_id', $module_result.node_id ))}
<div id="col2List">
<h3>Other Stories</h3>
<ul>
{def $inner_related_other_image=''}
{foreach $meny as $element}
<li>
{set $inner_related_other_image = fetch('content','related_objects',hash('object_id',$element.object.id,'all_relations', true()))}
{foreach $inner_related_other_image as $inner_related_other}
<a href={$element.url_alias|ezurl()}><img src={$inner_related_other.data_map.image.content.original.full_path|ezroot} alt="image1" border="0" /></a>
{/foreach}
<div id="col2ListIndent">
<span class="title"><a href={$element.url_alias|ezurl()}>{attribute_view_gui attribute=$element.object.data_map.title}</a></span><br/>
<span class="date">{attribute_view_gui attribute=$element.object.data_map.date} </span>
<span class="desc">{attribute_view_gui attribute=$element.object.data_map.excerpt}</span></div>
</li>
{/foreach}
</ul>
</div><!--end of news list-->
<!-- Record set navigation bottom start -->
{include uri="design:navigator/google.tpl"
page_uri=$pagelayout_node.url_alias
item_count=$meny_count
view_parameters=$view_parameters
item_limit=$limit}
Should all of this go into a template? And then just include it like the google.tpl is included above?
|
Andreas Tremel
|
Monday 29 January 2007 6:56:57 am
Hello David, had exactly the same problem. $node does not wok after reloading for whatsoever reason. Try overwriting it this way:
{if and( is_set($module_result.node_id), is_unset($node) )}
{def $node = fetch( content, node, hash( node_id, $module_result.node_id ) )}
{/if}
For my part, this helped. You can now use $node, which still holds attribute values after page reloading.
Regards,
Mit freundlichen Grüßen Andreas Tremel
|