How to get grandparent folder

Author Message

RW Wood

Sunday 21 September 2003 1:59:21 pm

I've figured out that I can produce a list of folders within the current folder with the following code:

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

However, once I get to the bottom of the folder tree, I get a list of articles, which is fine, but if I then open one of those articles, the list is empty. What I'd like to have is that the same list of articles stays there when any one of them is open. Is there an easy way to do this with a {section show} and {section-else} or some other solution?

Thanks.
RWW

Bjørn Kaarstein

Monday 22 September 2003 1:51:35 am

When you're viewing your folderlist, I assume you have written an override for your folder class, displaying your list of articles.

When you switch to viewing an article, instead of a folder, you'll be using another template to show your article. Within that template, you could reproduce your article listing in addition to displaying your full article. I think you can fetch (parent_node_id, $parent_node.node_id) or something like that.
Just use the |attribute(show) to check what you can access.

Regards Bjørn

RW Wood

Monday 22 September 2003 7:27:27 am

I haven't written an override because this code is part of the pagelayout.tpl for my design. The purpose is to have a list of folders appear in the left column without any details about the folders. The code in my original post does that quite well.

I also know that if I change $node.node_id to $parent_node.node_id, I'll get a list of what's in the parent folder, which is what I want when I'm viewing an article itself and not a list of what's in a folder.

My problem is how to I structure the {section} and {section-else} statements so that essentially ezP is told "If you are displaying a folder that has contents, either sub-folders or articles, show a list of those folder or article titles. But if you're displaying an article, show a list of all the articles or sub-folders that are in the folder the current article is found in."

In other words when I've reached the bottom of the folder tree, using the above code the list would be empty, using the $parent_node.node_id code, the list would be populated with a list of articles and sub-folders, one of which being the current article.

If {section} and {section-else} is not the way to accomplish this, what is.

Thanks.
RWW

Bjørn Kaarstein

Wednesday 24 September 2003 2:06:24 am

Could you try to use a switch/case statement based on class?

Something like this: (I assume folder is class 1 and article class 2)

{switch match=$node.object.contentclass_id}
{case match=1} {*folder*}
List articles from current folder
{/case}
{case match=2} {*article*}
List articles from parent folder
{/case}
{/switch}

If all articles is on the same depth, you could also check on $node.depth

Regards Bjørn

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

eZ debug

Timing: Jan 18 2025 22:19:54
Script start
Timing: Jan 18 2025 22:19:54
Module start 'layout'
Timing: Jan 18 2025 22:19:54
Module start 'content'
Timing: Jan 18 2025 22:19:55
Module end 'content'
Timing: Jan 18 2025 22:19:55
Script end

Main resources:

Total runtime1.0660 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9141152.6250
Module start 'layout' 0.00540.0025 740.539139.4453
Module start 'content' 0.00791.0569 779.9844489.6016
Module end 'content' 1.06480.0012 1,269.585912.1641
Script end 1.0660  1,281.7500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2943160.0002
Check MTime0.00120.1166160.0001
Mysql Total
Database connection0.00070.063110.0007
Mysqli_queries1.020995.7654600.0170
Looping result0.00050.0433580.0000
Template Total1.037597.320.5188
Template load0.00200.188720.0010
Template processing1.035597.138820.5178
Template load and register function0.00020.021410.0002
states
state_id_array0.00200.187110.0020
state_identifier_array0.00220.203320.0011
Override
Cache load0.00170.1619380.0000
Sytem overhead
Fetch class attribute can translate value0.00060.055220.0003
Fetch class attribute name0.00100.093440.0002
XML
Image XML parsing0.00020.017920.0001
class_abstraction
Instantiating content class attribute0.00000.000640.0000
General
dbfile0.00050.0503100.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs