Fetching Specific Nodes - Best Practices?

Author Message

Hal Gatewood

Monday 05 April 2010 8:03:37 am

I'm interested in how others fetch specific nodes in the template.

We currently have a custom ini that has an array like this:

[SpecificNodeIds]
Recipes=1355
RecipesTopRated=4674
Courses=1965
Meals=1945

Then when we want to fetch the node for a link in the template we do something like this:

{def $recipeNode = fetch( content, node, hash( node_id, ezini('SpecificNodeIds','Recipes','hal.ini')))}

The problem is that we have different node ids on each environment we work with or if an editor removes a node and recreates it then our ini is out of sync.

How do you handle these types of fetches? how can we make this more dynamic? fetch path? Any tips, suggestions or links are appreciated.

Thanks,
Hal Gatewood

Gaetano Giunta

Monday 05 April 2010 3:44:36 pm

Using the remote_id of anode makes it a little bit better, as remote_ids survive moving to a remote server via packaging

Principal Consultant International Business
Member of the Community Project Board

Nicolas Pastorino

Tuesday 06 April 2010 3:05:53 am

Hi,

Using remote IDs could do the deal indeed, you'd need to use either of these fetch functions :

  • content/node : http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/content/fetch_functions/node
  • content/object : http://ez.no/doc/ez_publish/technical_manual/4_x/reference/modules/content/fetch_functions/object

And specify the remote_id parameter accordingly. Please note that in the first case above the object's remote_id is used, while the node's is used in the second case.

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

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