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.

eZ debug

Timing: Jan 31 2025 01:26:06
Script start
Timing: Jan 31 2025 01:26:06
Module start 'layout'
Timing: Jan 31 2025 01:26:06
Module start 'content'
Timing: Jan 31 2025 01:26:06
Module end 'content'
Timing: Jan 31 2025 01:26:06
Script end

Main resources:

Total runtime0.0204 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.2344151.2109
Module start 'layout' 0.00430.0033 739.4453220.6875
Module start 'content' 0.00770.0114 960.13281,005.9297
Module end 'content' 0.01900.0013 1,966.062541.9922
Script end 0.0204  2,008.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002512.1615140.0002
Check MTime0.00115.2081140.0001
Mysql Total
Database connection0.00063.135610.0006
Mysqli_queries0.00199.096030.0006
Looping result0.00000.049110.0000
Template Total0.00094.610.0009
Template load0.00073.620410.0007
Template processing0.00020.925310.0002
Override
Cache load0.00052.529310.0005
General
dbfile0.00031.268780.0000
String conversion0.00000.030440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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