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

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