Forums / Setup & design / excluding duplicates in a template

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

eZ debug

Timing: Jan 18 2025 16:11:16
Script start
Timing: Jan 18 2025 16:11:16
Module start 'content'
Timing: Jan 18 2025 16:11:16
Module end 'content'
Timing: Jan 18 2025 16:11:16
Script end

Main resources:

Total runtime0.1794 sec
Peak memory usage4,096.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 587.7344180.8281
Module start 'content' 0.00670.0084 768.5625102.0078
Module end 'content' 0.01520.1642 870.5703532.3281
Script end 0.1793  1,402.8984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.0839200.0002
Check MTime0.00130.7094200.0001
Mysql Total
Database connection0.00120.654910.0012
Mysqli_queries0.119666.67431410.0008
Looping result0.00130.72561390.0000
Template Total0.163891.310.1638
Template load0.00100.536710.0010
Template processing0.162890.756410.1628
Override
Cache load0.00070.369510.0007
Sytem overhead
Fetch class attribute can translate value0.00100.561810.0010
XML
Image XML parsing0.00020.116910.0002
General
dbfile0.01206.6841200.0006
String conversion0.00000.003130.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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