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.

eZ debug

Timing: Jan 18 2025 03:12:34
Script start
Timing: Jan 18 2025 03:12:34
Module start 'layout'
Timing: Jan 18 2025 03:12:34
Module start 'content'
Timing: Jan 18 2025 03:12:34
Module end 'content'
Timing: Jan 18 2025 03:12:34
Script end

Main resources:

Total runtime0.8700 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 589.1484152.6406
Module start 'layout' 0.00450.0036 741.789139.4609
Module start 'content' 0.00820.8605 781.2500587.8984
Module end 'content' 0.86870.0013 1,369.148412.1406
Script end 0.8700  1,381.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3687160.0002
Check MTime0.00140.1648160.0001
Mysql Total
Database connection0.00050.053410.0005
Mysqli_queries0.811993.3221590.0138
Looping result0.00060.0710570.0000
Template Total0.842496.820.4212
Template load0.00240.270720.0012
Template processing0.840196.556320.4200
Template load and register function0.00030.034010.0003
states
state_id_array0.00080.087310.0008
state_identifier_array0.00090.108220.0005
Override
Cache load0.00180.2092290.0001
Sytem overhead
Fetch class attribute can translate value0.00170.198630.0006
Fetch class attribute name0.00160.179160.0003
XML
Image XML parsing0.00220.250830.0007
class_abstraction
Instantiating content class attribute0.00000.001260.0000
General
dbfile0.00130.1444280.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs