Fetch only object with a checkbox-attribute enabled?

Author Message

Frode Slettum

Saturday 27 May 2006 11:48:13 am

Hi

I have a class with a checkbox attribute. I want to fetch only nodes with this checkbox enabled. This would be my guess, but I'm not able to get it work:

fetch  ( content  , list  , hash  ( parent_node_id , $node.node_id , attribute_filter , array ( array ( 224 , = ,1 ) ) ) ) }

224 is the attribute (checkbox) id.

regards
Frode S.

Marcin Drozd

Saturday 27 May 2006 12:22:37 pm

Hi Frode

try with:

fetch( content, list, hash( parent_node_id, $node.node_id, attribute_filter, array( array( 224, '=', '1' ) ) ) ) }

spaces and single quotes are important

http://ez-publish.pl

Frode Slettum

Saturday 27 May 2006 2:50:17 pm

Hi!

Thanks a lot for a quick and good answer. The spaces in my template didn't look like this i posted here but after I did like you said it works :) Thanks a lot!

Didn't really know that spaces and quotes was that important...

Frode

Marc Boon

Monday 29 May 2006 5:23:42 am

Spaces are irrelevant, but the quotes around = are necessary, and they can be either single or double quotes, as long as they match.
You should technically quote all keys in a hash, since they are supposed to be strings. PHP and the eZ publish template language automatically convert identifiers that start with an alphabetical character to a string. This behaviour promotes sloppy coding, but it's easy so nobody complains about it.
In the case of the = character, which is not alphabetic, this conversion is not done automaticallay, that's why you have to quote it.
The manual specifies all functions with quoted identifiers, by the way. Like fetch('content', 'list', etc.), this is how it should be done. Read the manual!

Kristof Coomans

Monday 29 May 2006 5:49:54 am

Spaces are irrelevant

Spaces are irrelevant when used between the parameters of a template operator, but they shouldn't be used between a template operator and it's opening parenthesis.

Not right:

fetch ( ... )

Right:

fetch( ... )

This rule is also valid for <i>hash</i> and <i>array</i> (they are template operators too), as you can see in post 1 and 2 of this topic.

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 31 2025 01:32:36
Script start
Timing: Jan 31 2025 01:32:36
Module start 'layout'
Timing: Jan 31 2025 01:32:36
Module start 'content'
Timing: Jan 31 2025 01:32:36
Module end 'content'
Timing: Jan 31 2025 01:32:36
Script end

Main resources:

Total runtime0.0252 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.0058 588.3750151.2422
Module start 'layout' 0.00580.0039 739.6172220.7344
Module start 'content' 0.00970.0141 960.35161,001.9453
Module end 'content' 0.02390.0013 1,962.296933.9922
Script end 0.0252  1,996.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002810.9612140.0002
Check MTime0.00114.3108140.0001
Mysql Total
Database connection0.00083.003610.0008
Mysqli_queries0.002710.633530.0009
Looping result0.00000.043410.0000
Template Total0.00093.610.0009
Template load0.00072.634310.0007
Template processing0.00020.915210.0002
Override
Cache load0.00051.822010.0005
General
dbfile0.00072.646680.0001
String conversion0.00000.034940.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