Path

exponential.earth / exponential / documentation / building an ez publish site / the links page / displaying the contents of a folder


Displaying the contents of a folder

These documentation pages are no longer maintained. Please visit the new documentation site.

Whenever a folder is accessed, its contents should be listed directly underneath the name of the folder. This is similar to the visual navigation of a filesystem through a graphical user interface. To achieve this, we must first add some sort of logic that "detects" the folder that is being accessed. We must check if the identification number of the node being listed matches the identification number of the node that is being accessed. We'll use the "section" function combined with the "show" parameter to create an IF-THEN-ELSE like mechanism:

{* Check if this node(folder) is the one that was accessed: *}

{section show=eq( $:item.node_id, $node.node_id ) )}

 

   TEST<br />

 

{* End of if-section. *}

{/section}

When a folder is accessed (clicked), this code will print a "TEST" string directly underneath the target folder.

The "$:item.node_id" variable contains the identification number of the node that is being listed. The "$node.node_id" variable contains the identification number of the node that is being accessed. The "eq" operator is used to compare the two identification numbers. This operator returns true if the numbers are equal (false otherwise). The boolean output from the eq operator is handled by the "show" parameter of the section function. If the show parameter is set to true, the template parser will process the section. If the show parameter is set to false, the section will be skipped. Insert these lines right before the "{* End of sub-folder loop. *}" comment of the code within the "links_tree_menu.tpl" file. At this point, the "links_tree_menu.tpl" file should contain the following lines:

{* Loop through all sub-folders within the "Links" folder. *}

{section loop=fetch( content,

                    list,

                    hash( parent_node_id,    __NODE_ID_OF_LINKS__,

                          class_filter_type, include,

                          class_filter_array, array( 'folder' ),

                          sort_by,           $node.sort_array ) ) }

 

   {* Display the folder-name as a link to a full view of the node. *}

   <b>

       <a href={concat( "/content/view/full/", $:item.node_id, "/" )|ezurl}>

           {$:item.name}

       </a>

   </b>

   <br />

 

   {* Check if this node(folder) is the one that was accessed: *}

   {section show=eq( $:item.node_id, $node.node_id )}

 

   TEST

   <br />

 

   {* End of if/else structure. *}

   {/section}

 

{* End of sub-folder loop. *}

{/section}

Refresh the "Links" page and access/click on the different folders. The "TEST" string will magically appear beneath the folder that was accessed/clicked. Instead of outputting "TEST", we should be looking at the contents of the folder that was accessed. We'll simply loop through and display the contents of the folder. The following template code takes care of this:

{* Loop through all the nodes(links) within this folder. *}

{section loop=fetch( content,

                    list,

                    hash( parent_node_id,    $:item.node_id,

                          class_filter_type, include,

                          class_filter_array, array( 'link' ),

                          sort_by,           $:item.sort_array ) ) }

 

   {* Display the name of each link as a link. *}

   &nbsp&nbsp<a href={$:item.object.data_map.location.content} target="_blank">

       {$:item.name}

   </a>

   <br />

 

{* End of link-list loop. *}

{/section}

Simply replace the "TEST" string (and the line-break) with the code that was presented above. Refresh the "Links" page and try to click on one of the folders again. The folder's contents should be listed. The following screenshot shows what happens when the "Educational sites" folder is clicked:

Comments

Contents

Building an eZ publish site

Prerequisits
Situation
Creating the TSCM site
Testing the interfaces
Setting up the main layout
Creating sections
The welcome page
The news page
The members page
The guestbook
The links page
    Adding content
    Creating the template
    Displaying the sub-folders
    Displaying the contents of a folder
    Creating a tree-style appearence
    Same content at different locations


Created

26/11/2003
5:56:46 pm
by Balazs Halasy

Last updated

24/11/2004
12:05:22 pm
by Raymond Bosman

Authors

Balazs Halasy
kracker
Ole Morten Halvorsen
Raymond Bosman



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.