name of a parent

Author Message

Jack Rackham

Thursday 14 April 2005 7:43:35 am

Is it possible to fetch the name of a parent folder?

J-A Eberhard

Thursday 14 April 2005 7:59:48 am

$module_result.content_info.parent_node_id will gives you the parent node id

Open Source Solution Provider
Open-Net Ltd Switzerland
http://www.open-net.ch

kracker (the)

Thursday 14 April 2005 8:59:57 am

I did this just today, does anyone have some ideas on how I could improve this solution?

The approach I took was to call a second fetch to get the current item's parent's name.

Abbreviated:
{set parent_id=$cnews.parent_node_id}
{set parent=fetch('content','node', hash('node_id', $parent_id , limit, 1 , sort_by, array(array(published, false() )) )) }
{set news_category=$parent.name}
New Objects: <br />
<span style="font-size: 11px;">
  {set news_id=344}
  {set news_limit=4}

  {let recent=fetch( content, tree, hash( parent_node_id, $news_id, limit, $news_limit, 'class_filter_type', 'include', 'class_filter_array', array( 'article' ) , sort_by, array(array(published, false() )))) }
  {section show=$recent|count|gt(0)}
    {section var=cnews loop=$recent}
      {set news_title=$cnews.name}
      {set news_intro=$cnews.data_map.intro.data_text}
      {set news_date_formated=$cnews.object.current.created |datetime( 'custom', '%m/%d/%Y @ %h:%i' )}

      {set parent_id=$cnews.parent_node_id}
      {set parent=fetch('content','node', hash('node_id', $parent_id , limit, 1 , sort_by, array(array(published, false() ) ) )) }
      {set news_category=$parent.name}
      <div style="padding-top: 2px; padding-bottom: 8px;"><span><a href="{$cnews.url_alias}" style="color:#004A84;">{$news_title|shorten(348)}</a></span><div align="right"><span style="font-style: italic;">Added to Category: {$news_category}<br /><span style="font-size: 10px; color: grey;">Released: {$news_date_formated}</span></div></div>
    {/section}
  {/section}
 {/let}
</span>

//kracker

mst3k : why study industrial arts?

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Łukasz Serwatka

Friday 15 April 2005 1:33:28 am

Here is the code.

{$node.parent.name}

or

{$node.parent_node_id}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Ekkehard Dörre

Friday 15 April 2005 7:18:56 am

... and the grandparent:
How to find the parent and grandparent of an object.
http://ez.no/ez_publish/documentation/incoming/how_to_find_the_parent_and_grandparent_of_an_object

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Łukasz Serwatka

Friday 15 April 2005 7:23:09 am

... and ;)

{$node.parent.parent_node_id} //grandparent id

It`s always good to view attributes, btw

{$node|attribute}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Ekkehard Dörre

Saturday 16 April 2005 2:38:39 am

... and ;-))

there are more interestings thinks to look after:

module_result <br />{$module_result|attribute(show,2)}
designkeys <br />{$DesignKeys:used|attribute(show,2)}
view_parameters <br />{$view_parameters|attribute(show)}
uri_string {$uri_string} <br />
site <br />{$site|attribute(show)}
ezinfo <br /> {$ezinfo|attribute(show)}

@Lukasz: Thank You, nice surprise ;-) ,at pinboard now.

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Jack Rackham

Saturday 16 April 2005 7:02:45 am

Strangely {$node.parent.name} work on my page, I did not think that $node worked in pagelayout overrides!

Bertrand Dunogier

Monday 29 August 2005 10:41:15 am

Jack, don't use it in pagelayout... it works as long as ViewCaching is disabled. Once enabled, you'll run into baaaad surprises :)

Use $module_result.content_info.node_id to fetch what you need (for instance) but don't use $node as is.

To knowledgeable people: is it right to use .parent and .children for nodes once fetched ? With those, as far as I can see, you can theorically browse the entire structure tree in one go... like

{$node.parent.parent.parent.children[0].children[1]...

What's the cost of that ?

Jack Rackham

Thursday 01 September 2005 2:55:55 am

There was a bug in 3.5 so when I upgraded to 3.6 I kept the bug.
http://ez.no/community/bugs/smart_cache_is_impossible_to_disable_in_3_5_2_and_3_6

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 22:12:13
Script start
Timing: Jan 18 2025 22:12:13
Module start 'layout'
Timing: Jan 18 2025 22:12:13
Module start 'content'
Timing: Jan 18 2025 22:12:13
Module end 'content'
Timing: Jan 18 2025 22:12:13
Script end

Main resources:

Total runtime0.0151 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 587.7891152.6094
Module start 'layout' 0.00510.0025 740.398439.4063
Module start 'content' 0.00760.0053 779.8047105.3906
Module end 'content' 0.01290.0021 885.195346.3047
Script end 0.0150  931.5000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002516.4160140.0002
Check MTime0.00127.7552140.0001
Mysql Total
Database connection0.00085.571710.0008
Mysqli_queries0.002214.645830.0007
Looping result0.00000.072810.0000
Template Total0.001711.410.0017
Template load0.00095.904210.0009
Template processing0.00085.457710.0008
Override
Cache load0.00064.137210.0006
General
dbfile0.00128.184280.0002
String conversion0.00000.044340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs