Forums / Developer / $node not available when viewCaching is enabled?

$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

eZ debug

Timing: Jan 18 2025 11:24:16
Script start
Timing: Jan 18 2025 11:24:16
Module start 'content'
Timing: Jan 18 2025 11:24:17
Module end 'content'
Timing: Jan 18 2025 11:24:17
Script end

Main resources:

Total runtime1.2929 sec
Peak memory usage4,096.0000 KB
Database Queries225

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0114 588.9609180.8125
Module start 'content' 0.01141.1556 769.7734803.1172
Module end 'content' 1.16700.1258 1,572.8906345.3047
Script end 1.2928  1,918.1953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.3303210.0002
Check MTime0.00170.1343210.0001
Mysql Total
Database connection0.00430.329710.0043
Mysqli_queries1.192592.23072250.0053
Looping result0.00230.17892230.0000
Template Total1.251896.820.6259
Template load0.00230.179920.0012
Template processing1.249596.641620.6248
Template load and register function0.00020.018110.0002
states
state_id_array0.00110.085510.0011
state_identifier_array0.00200.157620.0010
Override
Cache load0.00220.1719750.0000
Sytem overhead
Fetch class attribute can translate value0.00140.110680.0002
Fetch class attribute name0.00110.0835120.0001
XML
Image XML parsing0.00280.220280.0004
class_abstraction
Instantiating content class attribute0.00000.0018130.0000
General
dbfile0.00230.1765330.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 44
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs