$node.node_id doesn't work in ez publish 3.4

Author Message

James Packham

Thursday 10 June 2004 3:26:15 am

Hi,

Is it just me who has this problem? I've found that I have to replace $node.node_id with $module_result.node_id in my templates, as $node.node_id no longer works in 3.4! Does anyone know if this is this intentional, or should I report it as a bug?

Regards,

James

Paul Forsyth

Thursday 10 June 2004 4:36:57 am

It works for me. Where do you use this? In override templates, pagelayouts, or in modules where there is no node (ie user/login/ content/search etc).

Have you switched cache on recently?

paul

--
http://www.visionwt.com

James Packham

Thursday 10 June 2004 8:43:54 am

I was viewing a folder node. This is an upgrade from ez 3.3, could this be something to do with it?

Paul Forsyth

Thursday 10 June 2004 8:58:59 am

Maybe :)

It sounds like a cache issue. Can you test whether $DesignKeys:used.node is valid?

paul

--
http://www.visionwt.com

Mark Marsiglio

Thursday 10 June 2004 1:34:34 pm

I am having the same problem. I am using it primarily in pagelayout.tpls or in .tpls that are included in the main pagelayout. I tried disabling the view cache, but it was still a problem. It has broken one of my fetch functions to the point that it calls nothing.

I tested the template variables and found that only DesignKeys and and Module_result had any variable set. None of the node variables worked.

I spent 8 hours trying to rewrite this one fetch without using $node, and I have found it to be impossible (or so obtuse that it would not be worth it).

I also upgraded (though from 3.2-4). However, I tried it on several of my installations, including one that I updated from 3.3-4 and one clean 3.4-0 install. $node.name does not work in any of them. The documentation clearly seems to show that this should work.

Very frustrating. Paul - under what circumstances are you using the $node variables?

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Christian Lundvang

Friday 11 June 2004 12:16:07 am

Hi everyone.

I reported a bug on it, and it was marked unvalid. Check it out: http://www.ez.no/community/bug_reports/not_able_to_show_nodeid_in_pagelayout_tpl.

Before 3.4 I used

$node.node_id.path_array[4]

but this doesn't work in 3.4, but neither does this:

$module_result.node_id.path_array[4]

Any suggestions?

Thanks in advance.

Christian

--
Best Regards
Christian Lundvang
http://www.nxc.no

Jan Borsodi

Friday 11 June 2004 12:31:04 am

Just to clear things up.

The <i>$node</i> variable you accessed earlier was a leftover of the module that was run (in the case content/view), it was set before the module fetched it's template and was passed over to the pagelayout.
However this variable was never intended to be accessed globally (pagelayout.tpl) after the module is done, for instance it will not be available when caching is on since the template system is not used in that case.

We created the <i>$module_result</i> variable for this cause, it contains all information from the module even in cached made. Replace your <i>$node.node_id</i> with <i>$module_result.content_info.node_id</i> and it will work.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Christian Lundvang

Friday 11 June 2004 12:46:11 am

Ok. Thanks for clearing that up for me, Jan.

christian

--
Best Regards
Christian Lundvang
http://www.nxc.no

Paul Forsyth

Friday 11 June 2004 12:51:00 am

Jan,

Could someone from eZ update the documents to cover the $module_result.content_info variable? The main doc:

http://ez.no/ez_publish/documentation/customization/custom_design/template_variables_set_by_ezpublish

doesnt mention it so i assume its new...

paul

--
http://www.visionwt.com

James Packham

Friday 11 June 2004 2:20:32 am

Wow, didn't expect I'd have caused such a long debate!

It was pretty easy for me to work out the $module_result solution, as I already had a function that dumps all the variables to the screen, but I think this must be very frustrating to anyone else - especially as we've been told ever since we started using ez that we should be using $node variable to get node ids, names, object data_maps etc. Will ez systems be updating the documentation too?

Regards,

James

Paul Borgermans

Friday 11 June 2004 2:51:35 am

$node is to be used in view templates only
$module_result is to be used in pagelayout templates only

Best regards

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

James Packham

Friday 11 June 2004 4:43:26 am

Ok I see! I guess I just needed that spelt out to me in slightly simpler language ;)

Jan Borsodi

Friday 11 June 2004 6:16:06 am

Actually some elements are available right trough <em>$module_result</em>.
So

$module_result.node_id

will work (just tested it myself).

So the doc page is correct.

Allthough it should probably mention <em>content_info</em> as well.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Paul Borgermans

Friday 11 June 2004 6:51:08 am

Pew, the book is still right then (it mentions both)

;-)

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Mark Marsiglio

Friday 11 June 2004 6:59:41 am

Is there an equivalent to $node.main_node_id in the $module_result? I could not find one when I viewed the attributes. The problem that I am facing is that some of my content which is displayed from an alternate location needs to display the children of the main location. I was using the main_node_id to pull the children of the main location of the node.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

James Packham

Friday 11 June 2004 7:17:29 am

Mark,

My latest work around is to do this:

At the top of pagelayout.tpl I inserted a fetch statement for $module_result.node_id to a variable called $current_node
Then all I needed to do was replace all my $node statements for $current_node (very quick and easy in a *nix system)

Your results for $current_node will be the same as your old results for $node were, meaning you don't have to make as many template changes when you migrate from 3.3 to 3.4.

For example $current_node.main_node_id will work.

~James~

Paul Forsyth

Friday 11 June 2004 7:20:45 am

This thread might be of use too:

http://ez.no/community/forum/setup_design/search_engine_optimisation_more_efficient_use_of_the_title_tag

There is sample code, plus mention of this suggestion...

http://ez.no/community/bug_reports/always_have_a_valid_node_object_available

paul

--
http://www.visionwt.com

Mark Marsiglio

Thursday 17 June 2004 11:05:18 am

James,

I tried your workaround but could not get it to work. When I fetched the node_id it was just a number. The number did not have any attributes such as main_node_id that could be returned.

I ended up fixing my issue by placing the elements that relied on the $node variables in the full.tpl override rather than in the pagelayout.tpl. This fixed it without changing any of the fetches.

Mark

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

James Packham

Friday 18 June 2004 1:40:22 am

Sorry,should have put the code in instead:

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

Will give you a variable called $current_node.

Regards,

James

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.