Forums / Developer / fetch not working in page_head.tpl

fetch not working in page_head.tpl

Author Message

Oliver Frommel

Friday 05 September 2008 5:15:18 am

Hello,

I have small problem that is about to drive me mad. While trying to implement meta keywords in the html header I tried to fetch the keywords of the currently viewed node. As I need to do that in the page header I include it with a parameter that contains the current node id.

pagelayout.tpl:

...
{include uri="design:page_head.tpl" current_node_id=$module_result.node_id}
...

(I was not sure about whether module_result is accessible in templates included from pagelayout.tpl so I supplied the parameter just to be sure). In page_head.tpl I can print the node id but fetching that node to get to the data map etc fails on most objects.

page_head.tpl:

{def $node=fetch('content','node',hash('node_id',$current_node_id))}

it fails with articles, news and other content objects but works with folders for instance. It is even more disturbing as that same code works on another siteaccess (even without passing a parameter). Any hint on what's going on here is appreciated.

Thanks
Oliver

Pierre Tissot

Monday 08 September 2008 8:12:52 am

Hi:

I never had this sort of problem, but I always use:

$module_result.content_info.node_id

I know that in theory it's the same but try it, maybe this will work

PiR

Oliver Frommel

Thursday 11 September 2008 12:06:06 am

Thanks for the hint. Only it doesn't help because the node_id I get is always ok. It's only the fetch that fails.
best
Oliver

Xavier Serna

Monday 15 September 2008 6:16:43 am

Have you checked that the include is not inside any cache-block? this can cause symptoms like yours...

hth!

--
Xavier Serna
eZ Publish Certified Developer
Departament de Software
Microblau S.L. - http://www.microblau.net
+34 937 466 205

Oliver Frommel

Monday 15 September 2008 7:41:58 am

Unfortunately not. Thanks for the proposal however. The strange thing is that only the fetch fails. I will just paste the few code lines in question:

{def $active_node_id=$module_result.node_id
     $node=fetch('content','node',hash('node_id', $active_node_id))}

<title>
"{$node.name}" - "{$active_node_id}"
</title>

The node id is always shown, the name isn't in most cases. It works only with folders.
Now I am beginning to think that it has to do with localisation, maybe.

Best
Oliver