Forums / Developer / Display contents of child Folder?

Display contents of child Folder?

Author Message

David Jones

Thursday 10 August 2006 7:51:09 am

I have a page of defined class Text Page.

A child of which is a folder.
This folder contains a list of links.

I wish to display the links on the parent page. (i.e. the text page)

How do I do this?

Thanks

Marcin Drozd

Thursday 10 August 2006 12:54:25 pm

Hi
I'm not sure, you have:

-Text Page
  |- Folder A
     |- Link A
     |- Link B
  |- Folder B
     |- Link C
     |- Link D

right?
try code:

{def $links=fetch( content, tree, hash( parent_node_id, TEXT_PAGE_NODE_ID,
              'class_filter_type',  'include',
              'class_filter_array', array( 'link' )
 ) ) }
  {foreach $links as $link}
    {node_view_gui view=line content_node=$link}
  {/foreach}
{undef $links}

on the Text Page U can use TEXT_PAGE_NODE_ID=$node.node_id

http://ez-publish.pl

David Jones

Friday 11 August 2006 4:39:54 am

Thanks for yout reply

That is pretty much what I have.

Text Page
     |- Folder: Realted Links Block A
          |- Link A
          |- Link B
     |- Folder: Related Links Block B
          |- Link C
          |- Link D

What I need to happen is for Link A & Link B to be listed on text page. Link C & Link D are a differnt typw of link and I would like them also listed on the text page but in a different place.

THis is the code i have tried. But it doesn't display anything.

{TEXT_PAGE_NODE_ID=$node.node_id}
		
		{def $links=fetch(content, tree, hash( parent_node_id, TEXT_PAGE_NODE_ID, 'class_filter_type', 'include', 'class_filter_array',array('link')) ) }
			{foreach $links as $link}
				{node_view_gui view=line content_node=$link}
			{/foreach}
		{undef $links}

Help gratefully recieved

Marcin Drozd

Friday 11 August 2006 5:03:31 am

Hi
it should be:

{def $TEXT_PAGE_NODE_ID=$node.node_id}

but tree function fetches all links ('class_filter_array',array('link'))
and list (insteed of tree) fetches children of a node

Let node id of Text Page=10, FolderA=20.
fetch(content, tree, hash( parent_node_id, 10 ) fetches all links (A B C D)
fetch(content, list, hash( parent_node_id, 20 ) fetches only links A and B
and
fetch(content, list, hash( parent_node_id, 10 ) fetches no links
more http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list

maybe U can use related_objects function:
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/related_objects

http://ez-publish.pl

David Jones

Friday 11 August 2006 5:43:47 am

Great thanks

What if Text Page = 10, Folder A = 20, Folder B =30 , Folder C = 40

How do I display just the contents on Folder A and C on my text page

Thanks again

Marcin Drozd

Friday 11 August 2006 6:12:56 am

<i>How do I display just the contents on Folder A and C on my text page</i>

U can use fetch twice (for parent_node_id=20, and =40)
or use extended_attribute_filter (Example 17 on http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list )
or maybe:

{def $children=fetch(content, tree, hash( parent_node_id, 10 ) )
      {foreach $children as $child}
          {if or( $child.parent_node_id|eq(20), $child.parent_node_id|eq(40) )
               {node_view_gui view=line content_node=$child}
          {/if}
      {/foreach}

http://ez-publish.pl

David Jones

Tuesday 15 August 2006 3:10:48 am

Marcin, that's great thanks for your help.

However what that is doing is displaying a link to a view of the item in the folder. ie. I click link 1 and it takes me to a page which displays all the fields I set up for the class, link.

What I want to do is to pull out one of the fields.

So instead of displaying a link to the url. I want to display the URL.

Does that make sense?

Thanks again.

Coulibaly Ibrahim

Tuesday 15 August 2006 5:04:09 am

What I want to do is to pull out one of the fields.

So instead of displaying a link to the url. I want to display the URL.

Does that make sense?

What do you exactly mean??
give an example.

Of course You can do what you want with nodes after the fetch. ( ie: in foreach loop)

Marcin Drozd

Tuesday 15 August 2006 5:23:33 am

Im not sure but I think I know what do U want:
I think, U want to make a link, which goes to another (external) site, but now the link goes to full view of node, right?
try this:

{foreach $items as $item}
  {if eq( $item.content_class.identifier, "link" )}
       <a href={$item.data_map.location.content|ezurl}>{$item.object.name|wash}</a>
  {else}
       <a href={$item.url_alias|ezurl}>{$item.name|wash}</a>
  {/if}
{/foreach}

U can see /base/templates/menu/flat_top.tpl - there is the similar code

http://ez-publish.pl

David Jones

Tuesday 15 August 2006 5:54:31 am

Marcin,

Thankyou, that is exactly what I want to do but that doesn't seem to be producing any output.

Any idea why?

THe code below. The top portion produces a link to the full node the bottom portion (your addition) produces no output.

	Related Links <br />
		
		
		{def $links=fetch(content, tree, hash(parent_node_id,$TEXT_PAGE_NODE_ID, 'class_filter_type', 'include', 'class_filter_array',array('link')) ) }
					{foreach $links as $link}
						{node_view_gui view=line content_node=$link}<br />
					{/foreach}
		{undef $links}
		
		<br /><br />
		
		{foreach $items as $item}
			{if eq($item.content_class.identifier, "link" )}
				<a href={$item.data_map.location.content|ezurl}>{$item.object.name|wash}</a>
			{else}
				<a href={$item.url_alias|ezurl}>{$item.name|wash}</a>
			{/if}
		{/foreach}

Marcin Drozd

Tuesday 15 August 2006 8:35:55 am

Hi David
no no, my code was an examlpe only, use this:

{def $links=fetch(content, tree, hash(parent_node_id,$TEXT_PAGE_NODE_ID, 'class_filter_type', 'include', 'class_filter_array',array('link')) ) }

                {foreach $links as $link}
                        {if eq($link.content_class.identifier, "link" )}
                                <a href={$link.data_map.location.content|ezurl}>{$link.object.name|wash}</a>
                        {else}
                                <a href={$link.url_alias|ezurl}>{$item.name|wash}</a>
                        {/if}
                {/foreach}
{undef $links}

or

{def $links=fetch(content, tree, hash(parent_node_id,$TEXT_PAGE_NODE_ID, 'class_filter_type', 'include', 'class_filter_array',array('link')) ) }

                {foreach $links as $link}
                        {if eq($link.content_class.identifier, "link" )}
                                <a href={$link.data_map.location.content|ezurl}>{$link.object.name|wash}</a>
                        {else}
                                {node_view_gui view=line content_node=$link}<br />
                        {/if}
                {/foreach}
{undef $links}

U can also change node/view/line.tpl for link class

btw:
U cannot use {foreach $items as $item} because U've never defined a variable called {$items}

U can also use your code, but change $items to $links and $item to $link

http://ez-publish.pl

David Jones

Wednesday 16 August 2006 1:37:18 am

Thanks again for your time but it seems we are going in circles.

The first block of code you've given me out puts nothing.

The second out puts the same thing as I had already. That is a link to the full node description.

I want a direct link to the location defined in the node description.

Is this possible?

Thanks again

Marcin Drozd

Wednesday 16 August 2006 2:12:16 am

Hi
I think it is my mistake:
change
{if eq($link.content_class.identifier, "link" )}
to
{if eq($link.class_identifier, "link" )}
Im sorry, I mislead

but U fetch only links, so U can use:
{def $links=fetch(content, tree, hash(parent_node_id,$TEXT_PAGE_NODE_ID, 'class_filter_type', 'include', 'class_filter_array',array('link')) ) }
{foreach $links as $link}
<a href={$link.data_map.location.content|ezurl}>{$link.object.name|wash}</a>
{/foreach}
{undef $links}

http://ez-publish.pl

eZ debug

Timing: Jan 18 2025 16:26:12
Script start
Timing: Jan 18 2025 16:26:12
Module start 'content'
Timing: Jan 18 2025 16:26:13
Module end 'content'
Timing: Jan 18 2025 16:26:13
Script end

Main resources:

Total runtime0.8667 sec
Peak memory usage4,096.0000 KB
Database Queries226

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.8359180.8281
Module start 'content' 0.00600.7371 769.6641678.9766
Module end 'content' 0.74310.1235 1,448.6406349.1563
Script end 0.8666  1,797.7969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.4900210.0002
Check MTime0.00160.1863210.0001
Mysql Total
Database connection0.00110.130510.0011
Mysqli_queries0.767788.57862260.0034
Looping result0.00190.22462240.0000
Template Total0.841897.120.4209
Template load0.00240.274520.0012
Template processing0.839496.845820.4197
Template load and register function0.00030.030010.0003
states
state_id_array0.00080.095210.0008
state_identifier_array0.00070.077520.0003
Override
Cache load0.00220.25531050.0000
Sytem overhead
Fetch class attribute can translate value0.00150.173340.0004
Fetch class attribute name0.00140.1614130.0001
XML
Image XML parsing0.00070.086540.0002
class_abstraction
Instantiating content class attribute0.00000.0024130.0000
General
dbfile0.00220.2534210.0001
String conversion0.00000.000630.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
13content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
27content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
14content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
11content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 67
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs