Share » Forums » Setup & design » attribute_filter with strings

attribute_filter with strings

attribute_filter with strings

Tuesday 07 December 2004 2:13:19 am - 7 replies

Author Message

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]')}

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu