Getting child items of a folder

Author Message

Jan Petter Dale

Thursday 05 January 2006 8:38:13 am

Hi. I'm pretty new to php and ezpublish system, so bare with me with my very rookie
questions here :)

This is what i've done:

Made a class that allows the user to input user data, to be stored in a folder
Made a section connected to that folder that contains the items that the users post,
so that I can easily create override templates with code that changes how the data
is outputted on a browser.

I've succesfully made items after creating the class, and successfully listed the items
with this code:

<div class="pagetitle">

   Member information

</div>

 

<div class="imageleft">

   {* Display a picture of the member. *}

   {attribute_view_gui attribute=$node.object.data_map.picture}

</div>

 

{* Display the attribute names and their values. *}

<table class="member_info" cellspacing="4" cellpadding="3">

   <tr>

       <td><b>{$node.object.data_map.realname.contentclass_attribute.name}:</b></td>

       <td>{attribute_view_gui attribute=$node.object.data_map.realname}</td>

   </tr>

   <tr>

       <td><b>{$node.object.data_map.nickname.contentclass_attribute.name}:</b></td>

       <td>{attribute_view_gui attribute=$node.object.data_map.nickname}</td>

   </tr>

   <tr>

       <td><b>{$node.object.data_map.birthdate.contentclass_attribute.name}:</b></td>

       <td>{attribute_view_gui attribute=$node.object.data_map.birthdate}</td>

   </tr>

   <tr>

       <td><b>{$node.object.data_map.gender.contentclass_attribute.name}:</b></td>

       <td>{attribute_view_gui attribute=$node.object.data_map.gender}</td>

   </tr>

   <tr>

       <td><b>{$node.object.data_map.phone.contentclass_attribute.name}:</b></td>

       <td>{attribute_view_gui attribute=$node.object.data_map.phone}</td>

   </tr>

   <tr>

       <td><b>{$node.object.data_map.email.contentclass_attribute.name}:</b></td>

       <td>{attribute_view_gui attribute=$node.object.data_map.email}</td>

   </tr>

</table>

Which is pretty simple. But before that code is initiated, a list of each item in that folder is presented to me on the screen.
It is very similar to making a folder on admin screen, then adding an article.

You can see an example here: http://www.trav24.no/index.php/portal/travtrenere/soerlandets_travpark

At that example, it lists the items in that folder. Instead I want it to list the content of each item, inside that very folder. So instead of clicking on i.e. 'Arild BerĂ¥s', it will just list the
preformatted item on the first page there, including all the other ones that might lay
in the folder.

Could anyone help me make a code that loops through the items in each folder,
uses the code above to fetch the data and to format it as I want it to be?

Thanks in advance.

Siw Helen Thorslund

Thursday 05 January 2006 10:15:28 am

You can make an override of the list view of your class for the members.
Then make this display whatever content you want in list view.

An example: http://ags.no/ags/om_ags/kontakt_oss

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Jan Petter Dale

Thursday 05 January 2006 11:41:56 am

Thank you for your reply.

I guess the real question in all this is how to loop through the child objects of a node/folder.

I.e.

/ezp/content/info01
/ezp/content/info02
/ezp/content/info03
/ezp/content/info04
/ezp/content/info05

If i then create a section that is connected to that content folder, what code makes me
able to loop through the chile objects of that folder(info01, info02, etc).

From my limited knowledge about programming, I can understand that this code:

{$node.object.data_map.realname.contentclass_attribute.name}:

it takes the current node, fetches the contentclass stored variables and makes you able to print it to the screen. The problem is that when I input this code to an override to the
specified folder(/ezp/content/), it will try to fetch the data from the current folder node, and
not the info01,info02,info03...etc which is the real nodes,items or objects(if that's what you call it) that stored the information i've put in.

Arran Price

Sunday 08 January 2006 4:13:33 pm

Hi,
Im a little confused as to what you are after.
Ive had a look at the link you provided, are you wanting more than just the name and the default icon on that page prior to going into the item itself?
If so you just need to override the line view of the item.

What currently is happening is that the folder by default will list all of its contents using the line view of each of those items. When you click into each item you get the full view of it. Each view can be overriden specifically.
If thats what you are after there is no need to loop through anything as the folder by default will "loop" through to disaply the line view of each element if contains.

If you are looking to do something else entirely which involves getting a number of content objects from somewhere then processing them, you need to do a "fetch" of which there is an examples page in the documentation.

hope thats of some help

Arran

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