Forums / General / name of a parent

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