More filtering

Author Message

Pål Messenlien

Thursday 20 October 2005 1:25:28 am

This time im struggling with filtering away folders in a menu. My code looks like this without filtering:

{def $meny_elementer=fetch('content','list',
				hash('parent_node_id', 2,
				'class_filter_type',  'include',
               'class_filter_array', array( 'folder' ),
				'sort_by',        array( 'priority', true() )
				))}
	
	{*$meny_elementer|attribute(show,1)*}
	
	{foreach $meny_elementer as $meny_element}
		<a href={$meny_element.url|ezurl}>
			{$meny_element.name}
		</a>
	{/foreach}

I want to not show one folder in the list. This can be done by removing every folder with priority = 0, or i add a option in the folder class to show or not... My problem is that i cant get the code together todo any of this. Ive tried attribute_filter, but i cant get it to work. Anyone?

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

Kristof Coomans

Thursday 20 October 2005 5:33:52 am

Please post the code with the attribute_filter you've tried.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Pål Messenlien

Friday 21 October 2005 12:49:44 am

This is how ive tried to get the attribute filter to function:

{def $meny_elementer=fetch('content','list',
				hash('parent_node_id', 2,
				'class_filter_type',  'include',
               'class_filter_array', array( 'folder' ),
			   'attribute_filter', array( array( 'folder/vis_meny',
                                                '=',
                                                'yes' )),
				'sort_by',        array( 'priority', true() )
				))}

The field 'vis_meny' is a checkbox. I have also tried to set 'yes' to true().
Also tried to controll this with

'attribute_filter', array( 'priority', '=>', '1' ),

Attribute filter always returns false

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

Pål Messenlien

Friday 21 October 2005 1:49:02 am

Got it working thanks to Kristian Hole. Istead of doing the check in the fetch i use a if sentence instead. The working code ended up like this:

{def $meny_elementer=fetch('content','list',
				hash('parent_node_id', 2,
				'class_filter_type',  'include',
               'class_filter_array', array( 'folder' ),
				'sort_by',        array( 'priority', true() )
				))}
	

	{foreach $meny_elementer as $meny_element}
		{if and( is_set( $meny_element.data_map.vis_meny), $meny_element.data_map.vis_meny.content) )}
		<a href={$meny_element.url|ezurl}>
			{$meny_element.name}
		</a>
		{if}
	{/foreach}

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

Kristof Coomans

Sunday 23 October 2005 4:26:24 am

I think you need to use the values 1 and 0 (checked and uncheked) when you want to filter on an attribute with datatype checkbox, because it's stored as an integer in the database.

Your attribute filter will be:

array( array( 'folder/vis_meny',
               '=',
               1
             )
     )

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

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 19 2025 06:07:40
Script start
Timing: Jan 19 2025 06:07:40
Module start 'layout'
Timing: Jan 19 2025 06:07:40
Module start 'content'
Timing: Jan 19 2025 06:07:40
Module end 'content'
Timing: Jan 19 2025 06:07:40
Script end

Main resources:

Total runtime0.0170 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 589.0313152.6094
Module start 'layout' 0.00570.0036 741.640639.4063
Module start 'content' 0.00930.0059 781.046997.4063
Module end 'content' 0.01520.0018 878.453138.3047
Script end 0.0170  916.7578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002414.1259140.0002
Check MTime0.00116.3154140.0001
Mysql Total
Database connection0.00095.524410.0009
Mysqli_queries0.003620.845930.0012
Looping result0.00000.147010.0000
Template Total0.00158.910.0015
Template load0.00074.239210.0007
Template processing0.00084.650810.0008
Override
Cache load0.00052.912010.0005
General
dbfile0.00158.686980.0002
String conversion0.00000.064440.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