Forums / Developer / More filtering

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

eZ debug

Timing: Jan 19 2025 03:43:16
Script start
Timing: Jan 19 2025 03:43:16
Module start 'content'
Timing: Jan 19 2025 03:43:17
Module end 'content'
Timing: Jan 19 2025 03:43:18
Script end

Main resources:

Total runtime1.1454 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0090 588.8203180.8516
Module start 'content' 0.00900.9915 769.6719566.5703
Module end 'content' 1.00050.1449 1,336.2422337.3984
Script end 1.1454  1,673.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.3579210.0002
Check MTime0.00150.1320210.0001
Mysql Total
Database connection0.00130.113110.0013
Mysqli_queries1.071093.49982000.0054
Looping result0.00210.18271980.0000
Template Total1.111097.020.5555
Template load0.00200.178020.0010
Template processing1.108996.813720.5545
Template load and register function0.00020.016010.0002
states
state_id_array0.00200.177410.0020
state_identifier_array0.00130.116520.0007
Override
Cache load0.00170.1503240.0001
Sytem overhead
Fetch class attribute can translate value0.00180.154730.0006
Fetch class attribute name0.00110.097860.0002
XML
Image XML parsing0.00090.080430.0003
class_abstraction
Instantiating content class attribute0.00000.001470.0000
General
dbfile0.00170.1487270.0001
String conversion0.00000.000530.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs