exponential.earth / exponential / documentation / building an ez publish site / the links page / 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. *}   <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