This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Setup & design » $node.node_id doesn't work in ez...
expandshrink

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

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

Thursday 10 June 2004 12:26:15 pm - 18 replies

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

Thursday 10 June 2004 1:36:57 pm

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

Thursday 10 June 2004 5:43:54 pm

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

Thursday 10 June 2004 5:58:59 pm

Maybe happy.gif Emoticon

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

paul

--
http://www.visionwt.com

Modified on Thursday 10 June 2004 5:59:10 pm by Paul Forsyth

Thursday 10 June 2004 10: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?

Friday 11 June 2004 9: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_re...ble_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

Modified on Friday 11 June 2004 9:19:30 am by Christian Lundvang

Friday 11 June 2004 9: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.

Friday 11 June 2004 9:46:11 am

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

christian

Friday 11 June 2004 9: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/documenta.../template_variables_set_by_ezpublish

doesnt mention it so i assume its new...

paul

--
http://www.visionwt.com

Modified on Friday 11 June 2004 9:52:33 am by Paul Forsyth

Friday 11 June 2004 11: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

Friday 11 June 2004 11: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

Friday 11 June 2004 1:43:26 pm

Ok I see! I guess I just needed that spelt out to me in slightly simpler language blunk.gif Emoticon

Friday 11 June 2004 3:16:06 pm

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.

Friday 11 June 2004 3:51:08 pm

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

blunk.gif Emoticon

-paul

Modified on Friday 11 June 2004 3:59:15 pm by Paul Borgermans

Friday 11 June 2004 3:59:41 pm

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.

Friday 11 June 2004 4:17:29 pm

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~

Modified on Friday 11 June 2004 4:19:33 pm by James Packham

Friday 11 June 2004 4:20:45 pm

This thread might be of use too:

http://ez.no/community/forum/setu..._more_efficient_use_of_the_title_tag

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

http://ez.no/community/bug_report...s_have_a_valid_node_object_available

paul

--
http://www.visionwt.com

Thursday 17 June 2004 8:05:18 pm

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

Friday 18 June 2004 10: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

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from