$node not available when viewCaching is enabled?

Author Message

Sven Ryen

Friday 04 July 2003 8:46:17 am

Hi!

I'm experiencing "instability" in 3.1-1 when viewCaching is enabled.

According to Debug output, the $node variable is not avilable:
<<Unknown template variable 'node' in namespace ''>>

What's odd is that if I disable viewCaching, the error goes away. Does anybody know a cure for this, or is this a bug in 3.1-1?

Jerry Jalava

Friday 04 July 2003 10:14:13 am

Hi Sven,

$node is not available when you use viewCaching, but you can use this instead: {$module_result.node_id}

Regards,
Jerry

Sven Ryen

Friday 04 July 2003 12:19:27 pm

I also need to access the parent of a node. Can that be achieved through $module_result.node_id?

Tony Wood

Friday 04 July 2003 12:24:15 pm

Hi Sven,

Try adding the following to your tpl, its really handy for finding out what variables are available.

<br>module_result.content
{$module_result.content|attribute(show, 1)}
<br>DesignKeys:used
{$DesignKeys:used|attribute(show, 1)}

I hope this helps

--tony

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

Paul Forsyth

Monday 07 July 2003 2:40:55 am

If you know the node id then you can run a 'fetch' using it to get the real node and its parent.

It would be better if the whole business with DesignKeys and caching was resolved. It is very confusing having to consider when variables are available and when they are not.

Ez, plans to improve this?

paul

Karsten Jennissen

Monday 07 July 2003 3:00:05 am

I added a page to the new open documentation to reflect this. If you find things out / know more (I am not into the topic), could you please add details to the following pages:

http://ez.no/developer/ez_publish_3/documentation/customization/templates/caching/variables_in_cached_templates
http://ez.no/developer/ez_publish_3/documentation/customization/templates/caching

Regards,
Karsten

Valentin Svelland

Monday 29 September 2003 3:09:41 am

This thread was very useful, but I still can't fetch out the published date of my nodes when turning on cache..

This is the original code working when not cahced:
{$node.object.published|l10n(datetime)}

Tried this, but it won't work:
{$module_result.node.object.published|l10n(datetime)}

Please, anyone know the solution to this cache-problem?

(My eZ version : 3.1-1 Revision: 2703 )

Shurbann Martes

Monday 29 September 2003 3:26:41 am

Shouldn't this be:

node_id instead of node

Good luck,
Shurban

Valentin Svelland

Monday 29 September 2003 3:35:04 am

Well, this still doesn't work when cached..
({$module_result.node_id.object.published|l10n(datetime)})

All my code:

{let article_list=fetch('content','list', hash(parent_node_id,$module_result.node_id,
sort_by,$module_result.node_id.sort_array,
offset, $view_parameters.offset,
class_filter_type, 'include',
class_filter_array, array( 2 ) ))
}
{section name=bottomlist loop=$article_list max=50 offset=8}
<li><a href={concat("/content/view/full/", $bottomlist:item.node_id, "/")|ezurl}>{$bottomlist:item.name|wash}</a>
( {$node.object.published|l10n(datetime)})</li>

{/section}</ul>
{/let}

Paul Forsyth

Monday 29 September 2003 3:03:28 pm

Remember that node_id is just a number. Take a look at this article:

http://ez.no/content/view/full/32420

so to get your node you still need to fetch it:

{let my_node=fetch(content,node,hash(node_id, $module_result.node_id))}

Now you can use it as you expect:

{$my_node.object.published|l10n(datetime)}

Paul

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 15:55:53
Script start
Timing: Jan 18 2025 15:55:53
Module start 'layout'
Timing: Jan 18 2025 15:55:53
Module start 'content'
Timing: Jan 18 2025 15:55:54
Module end 'content'
Timing: Jan 18 2025 15:55:54
Script end

Main resources:

Total runtime0.7696 sec
Peak memory usage4,096.0000 KB
Database Queries88

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.0469152.6406
Module start 'layout' 0.00640.0030 740.687539.4766
Module start 'content' 0.00940.7586 780.1641798.0234
Module end 'content' 0.76800.0016 1,578.187520.1250
Script end 0.7695  1,598.3125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4733160.0002
Check MTime0.00130.1658160.0001
Mysql Total
Database connection0.00080.109710.0008
Mysqli_queries0.689089.5292880.0078
Looping result0.00080.1023860.0000
Template Total0.729794.820.3649
Template load0.00170.222220.0009
Template processing0.728094.597620.3640
Template load and register function0.00010.015710.0001
states
state_id_array0.00130.171310.0013
state_identifier_array0.00120.158020.0006
Override
Cache load0.00160.2074750.0000
Sytem overhead
Fetch class attribute can translate value0.00050.067270.0001
Fetch class attribute name0.00080.0988120.0001
XML
Image XML parsing0.00140.187570.0002
class_abstraction
Instantiating content class attribute0.00000.0025130.0000
General
dbfile0.00420.5515220.0002
String conversion0.00000.001140.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
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/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: 44
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs