excluding duplicates in a template

Author Message

Christiane Kloss

Thursday 31 March 2005 10:33:40 am

For a toolbar I need to display "termine" which can have several locations in the subtree.
But I don't want to display duplicate entries.

So I tried the following.
But the {section show=$objects|contains( $termin.contentobject_id )} doesn't seem to work.

After the loop $objects contains all the object_ids,
$nodes all the node_ids. So the values should be right.
But nothing gets excluded....;-(((((

Any ideas why it's not working?

After fiddling around with this for hours, scanning the documentation, forum and the book - I'm sure it should work, but it doesn't.
What am I missing?
Any hints are very welcome!!!

{let termine=fetch( 'content', 
        			'tree', hash( 'parent_node_id',     168,
              'class_filter_type',  'include',
              'class_filter_array', array( 'termin' ),
              'depth', '5' ) )
 objects=array()
 nodes=array()
}

{section var=termin loop=$termine}

    <b>{section show=$objects|contains( $termin.contentobject_id )}</b>	

	{section-else}

		{append-block scope=root variable=objects}
			{$termin.contentobject_id}
		{/append-block}
		{append-block scope=root variable=nodes}
			{$termin.node_id}
		{/append-block}
	
	{/section}	
	
{/section}
	
{section var=termin loop=$termine}
    <b>{section show=$nodes|contains( $termin.node_id )}</b>
	<p>{$termin.name}</p>
    {/section}
{/section}

Thanks in advance

Christiane

Łukasz Serwatka

Thursday 31 March 2005 9:31:46 pm

Hi Christiane,

main_node_only should help, have you tried?

{let termine=fetch( 'content', 'tree', hash( 'parent_node_id', 168,
                                             'class_filter_type',  'include',
                                             'class_filter_array', array( 'termin' ),
                                             'depth', '5',
                                             'main_node_only', true() ) )

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Christiane Kloss

Friday 01 April 2005 2:04:42 am

Hi Lukasz!

Sorry, can't use it, as the main_nodes are located in the media section. Which I want to use as a data-pool even for another sideaccess.
And I want to generate links to the nodes...

I tried the codesnippet with section-exclude, section-include, match...
but the result is always the same.

Now I found out, the condition will be checked properly, when the code looks like this:

{section show=array('216')|contains( $termin.contentobject_id )}

But it is not working for the global array $objects.
How do I have to call my array objects in the showcondition ?

Greetings

Christiane

Łukasz Serwatka

Friday 01 April 2005 2:20:47 am

This should work, test it please ;)

{let termine=fetch( 'content', 'tree', hash( 'parent_node_id', 168,
                                             'class_filter_type', 'include',
                                             'class_filter_array', array( 'termin' ),
                                             'depth', '5' ) )
     objects=array()
     nodes=array()
}

{section var=termin loop=$termine}

	{section show=$objects|contains( $termin.contentobject_id )}

	{section-else}
		{set objects=$objects|append( $termin.contentobject_id )}
		{set nodes=$nodes|append( $termin.node_id )}
	{/section}	
	
{/section}

{section var=termin loop=$termine}
	{section show=$nodes|contains( $termin.node_id )}
		<p>{$termin.name}</p>
    {/section}
{/section}

{/let}	

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Christiane Kloss

Friday 01 April 2005 2:53:20 am

Hi Lukasz!

Thanks a lot - it's working!!! Jippieh

But you have to admit I was close to the right way..;-)
I still have problems to fully understand the {set..}, {set-block...}, {append-block...} statements, which statement to use in which case.
May be sometimes its better, not to think too much before but just give it try.... ;-))

Greetings Christiane

Łukasz Serwatka

Friday 01 April 2005 3:39:41 am

Great :) I`m glad I could help you :)

Here you can read more about {set-block}
http://ez.no/ez_publish/documentation/reference/template_functions/variables/set_block

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

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