Last 5 articles in a nested hierarchy?

Last 5 articles in a nested hierarchy?

Wednesday 16 April 2003 1:44:02 pm - 6 replies

Author Message

Paul Borgermans

Wednesday 16 April 2003 1:50:27 pm

Nothing special really (no hierarchy walk necessary), its all in the fetch function parameters:

pay special attention to the depth: set it to a large number or choose 0 (this appears to be unlimited depth) and then sort by published (ascending or descending -- try it out) should do the trick.

I used something similar for the forum enhancement. See

http://ez.no/developer/ez_publish_3/documentation/ez_publish_3/howtos/how_to_fetch_function_parameters_and_examples

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

arthur foelsche

Wednesday 16 April 2003 2:12:55 pm

thanks for the fast reply
here's the code snipit that i am using to just traverse the whole list:

{let test=fetch( 'content', 'list', hash(parent_node_id, 159, "sort_by", array("name", true()), "depth", 0)) }
{section name=Child loop=$test}
{node_view_gui view=line content_node=$Child:item}<br>
{/section}

which does work. now i just gotta figure out how to only return the most recent 5 :)

arthur foelsche

Wednesday 16 April 2003 2:26:50 pm

so this is the code that i used to grab the 5 most recent stories. Has there been any thought to developing a code library for snipts of code like this so that newbies (like myself) can easily grab commonly need functions? I think it would be super helpful.

{* change node id 159 to match your node *}
{let test=fetch( 'content', 'list', hash(parent_node_id, 159, class_filter_type, "include", class_filter_array, array(2), "sort_by", array("name", true()), "depth", 0)) }
{section name=Child loop=$test max=5}
{node_view_gui view=line content_node=$Child:item}
<br>
{/section}

Paul Borgermans

Thursday 17 April 2003 4:44:58 am

>Has there been any thought to developing a code library for
> snipts of code like this so that newbies (like myself) can easily
> grab commonly need functions? I think it would be super helpful.

Well, post your code snippet in the user contributed docs or the "contributions". If many of us do that, we have a code library.

The template system is very powerful; only by providing such real world examples the true power is revealed.

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Sergiy Pushchin

Wednesday 23 April 2003 1:41:17 am

I think this way is more nice:
fetch(content,list,hash(parent_node_id,16,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2)))

you don't need to limit in loop since you are able to limit in fetch function. Another thing you need to sort by published attribute, not name.

Jørgen Skogstad

Saturday 03 May 2003 3:25:29 am

Does the last one work with v3.0.2?? I have 3.0.2 on my laptop which works.. but my hosted on v3.0.1 .. it does not .. for some strange reason .. perhaps a typo, but I have redone this several times now already!

Kindest,
Jørgen Skogstad

You must be logged in to post messages in this topic!

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