Forums / Setup & design / attribute_filter with strings

attribute_filter with strings

Author Message

Ulrich L.

Tuesday 07 December 2004 2:13:19 am

Hi,
I just don't get it... I'm dealing with 'fetch' and the attribute_filter, but obviously there is still a synthax error. Can anybody help me?

{let string_node_name=concat("'", $node.name, "'")}
{let cds_by_artist=fetch( 'content', 'list', 
     hash( parent_node_id, 109, depth, 255, 
     class_filter_type, "include", class_filter_array, array(28),
     attribute_filter, array( 237, '=', $string_node_name) ) ) }

This piece of code shall give back all nodes under parent '109' which have the class_id '28' and the class_attribute_id with value of string_node_name.

(Application: I'd like to fetch all CDs by a certain artist, the name of the artist is stored in class_attribute 237).

Perhaps I made a very basic mistake, but I'm really struggling with the documentation on 'fetch' at the moment. However, I'm very impressed what can be achieved.

Hope anybody can help me.

Silke Fox

Tuesday 07 December 2004 2:48:35 am

attribute_filter expects an array of arrays as parameter.

Snippet from this documentation:
http://ez.no/ez_publish/documentation/development/libraries/ez_template/operators/data_fetch

fetch( 'content', 'list', 
          hash( parent_node_id, $node.node_id, 
                attribute_filter, array( array( 'article/title', '=', 'abc' ) ) ) )

This is because you can specify more than one filter option, like for example

... attribute_filter, array( array( 'article/id', '>', 100 ), array( 'article/id', '<', 200 ) ) ...

Ulrich L.

Tuesday 07 December 2004 6:06:19 am

Thank you, Silke.

My solution looks now like this:

{let cds_by_artist=fetch( 'content', 'list', 
   hash( parent_node_id, 109, depth, 63, 
   attribute_filter, array( array( 237, '=', $node.name ) ) ) ) }

I understand now that filtering an attribute makes it obsolet to filter the class_id first, because the attribute always belongs to a certain class. Is that right?

Silke Fox

Tuesday 07 December 2004 6:18:07 am

Yes, you're right, Ulrich.

And remember that you can use "class_identifier/class_attribute_identifier" instead of "attribute_id".
Improves readability and will still work after moving the class to another system (e.g. with package export/ import), while the ids will probably change.

Ulrich L.

Tuesday 07 December 2004 6:35:24 am

Thank you for this very useful hint.
Is there a similar way to deal with the numbers of the node IDs, can they be replaced by plain text as well?

Silke Fox

Wednesday 08 December 2004 12:50:00 am

As far as I know there is no way to avoid node ids completely, but at least you can avoid to use them <i>in templates</i>.

Have a look at the fetch_alias mechanism
http://ez.no/ez_publish/download/changelogs/ez_publish_3_3/template_fetch_by_alias
http://ez.no/ez_publish/documentation/reference/template_functions/miscellaneous/fetch_alias

Using this you can change ids in your fetchalias.ini.append while using more descriptive names in the templates.

Ulrich L.

Wednesday 08 December 2004 1:08:28 am

fetch_alias doesn't look too newbie-compatible...

(Probably) last question concerning this topic:
There is no way to define constant values in a global way?
Or perhaps I could use a kind of 'include' for this purpose?

Silke Fox

Wednesday 08 December 2004 4:55:58 am

One possibility might be to add a new ini file with the node ids you need
and read them from the template with

{ezini('[section]','[variable]','[ini file]')}

eZ debug

Timing: Jan 18 2025 18:42:05
Script start
Timing: Jan 18 2025 18:42:05
Module start 'content'
Timing: Jan 18 2025 18:42:05
Module end 'content'
Timing: Jan 18 2025 18:42:06
Script end

Main resources:

Total runtime0.8994 sec
Peak memory usage4,096.0000 KB
Database Queries209

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.8438180.8359
Module start 'content' 0.00680.7240 769.6797540.4844
Module end 'content' 0.73070.1686 1,310.1641341.8203
Script end 0.8993  1,651.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.4922210.0002
Check MTime0.00160.1734210.0001
Mysql Total
Database connection0.00090.095510.0009
Mysqli_queries0.819391.09072090.0039
Looping result0.00280.31452070.0000
Template Total0.871496.920.4357
Template load0.00200.222820.0010
Template processing0.869496.665620.4347
Template load and register function0.00020.017310.0002
states
state_id_array0.00130.144110.0013
state_identifier_array0.00060.071320.0003
Override
Cache load0.00160.1823440.0000
Sytem overhead
Fetch class attribute can translate value0.00250.273030.0008
Fetch class attribute name0.00150.171780.0002
XML
Image XML parsing0.00070.078530.0002
class_abstraction
Instantiating content class attribute0.00000.001680.0000
General
dbfile0.00220.2466210.0001
String conversion0.00000.000730.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
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
15content/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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 37
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs