Forums / Setup & design / Displaying contents from subfolders

Displaying contents from subfolders

Author Message

Tom Erik Thorsen

Monday 29 September 2003 5:42:49 am

OK, lets say I have a folder with several sub-cats.

For example:
Cat 1
- sub 1.1
- sub 1.2
- sub 1.3
- sub 1.4
--sub 1.4.1
- sub 1.5
Cat 2
- sub 2.1
...and so on....

What I want to do, is to display the contents (which is articles)from all subfolders from cat1.

Any ideas?

PS! Great CMS, though a bit hard to get "under the hood" ;)

Paolo Tramontani

Monday 29 September 2003 9:42:39 am

Normally fetch instruction retrieve only 1-level children.
This is the code:

{section name=myloop loop=fetch( content, list, hash( parent_node_id, $node.node_id )}
<div>
{node_view_gui view=line content_node=$myloop:item}
</div>
{/section}

This code retrieve only the children of your main folder so it display 1.1, 1.2, ..., 1.5 but not 1.4.1
If you want display every level in the subtree you have only to change the second parameter in the fetch function from "list" to "tree":

{section name=myloop loop=fetch( content, tree, hash( ...

Unfortunately this code don't distinguish the level and you'll find all nodes displayed in the same way. You have to add other code to indent or distinguish the level of each node. If you have only two level you can try to use the $myloop:item.parent_node_id.
Otherwise you should search in the docs some other property that indicate the deep of the node.

If you discover something interesting about it let us know,
Paolo

Albert Berenguer

Thursday 02 October 2003 8:49:56 am

hi, i found a way to do it...
it only displays the folders (or any content) contained by the actual node and also the content of theese folders, it also provides the links to them.

Here it goes:

{let folder_list=fetch('content','list',hash(parent_node_id, $node.node_id)}
{section name=Folder loop=$folder_list}
<a href={concat("/content/view/full/", $Folder:item.node_id,"/")|ezurl}>{$Folder:item.name|wash}</a><br>

{let subfolder_list=fetch('content','list',hash(parent_node_id, $Folder:item.node_id)}
{section name=Subfolder loop=$Folder:subfolder_list}
 <a href={concat("/content/view/full/", $Folder:Subfolder:item.node_id,"/")|ezurl}>{$Folder:Subfolder:item.name|wash}</a><br>
{/section}
{/let}

{/section}
{/let}

if you only want to display folders, and not other content (sthg useful for menus and so), replace the corresponding lines of the code below with theese:

{let folder_list=fetch('content','list',hash(parent_node_id, $node.node_id,),class_filter_type,"include",class_filter_array,array(1)))}

{let subfolder_list=fetch('content','list',hash(parent_node_id, $Folder:item.node_id,),class_filter_type,"include",class_filter_array,array(1)))}

i hope it helps you, bye!!

PS: Paolo, i found an attribute called 'depth' which provides de depth of a node, in your example the code would be "$myloop:item.depth"

berto

Gard Guldhav

Wednesday 08 October 2003 9:43:39 am

I have just started using ezpublish for a site and have a need for several sub-cats...
The code probably works but where should i put it?

eZ debug

Timing: Jan 31 2025 04:29:42
Script start
Timing: Jan 31 2025 04:29:42
Module start 'content'
Timing: Jan 31 2025 04:29:42
Module end 'content'
Timing: Jan 31 2025 04:29:42
Script end

Main resources:

Total runtime0.1719 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.0313180.8281
Module start 'content' 0.00610.0076 768.859497.7734
Module end 'content' 0.01370.1582 866.6328526.8281
Script end 0.1719  1,393.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00341.9556200.0002
Check MTime0.00130.7641200.0001
Mysql Total
Database connection0.00070.384010.0007
Mysqli_queries0.126473.50491410.0009
Looping result0.00110.66171390.0000
Template Total0.157891.710.1578
Template load0.00080.458810.0008
Template processing0.157091.288210.1570
Override
Cache load0.00050.307110.0005
Sytem overhead
Fetch class attribute can translate value0.00090.502010.0009
XML
Image XML parsing0.00030.154210.0003
General
dbfile0.00814.7227200.0004
String conversion0.00000.002830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs