Share » Forums » General » attribute_filter on fetch content list?

attribute_filter on fetch content list?

attribute_filter on fetch content list?

Thursday 24 July 2008 7:38:49 am - 7 replies

Author Message

Ivo Lukac

Thursday 24 July 2008 8:49:31 am

You are using 'list' function insteda of 'tree'

Try this:

{def $child=fetch('content', 'tree', 
        hash( 'parent_node_id', $node.node_id, 
                 'depth', '2',
                 'class_filter_type', 'include', 
                 'class_filter_array', array('product'),
                 'attribute_filter', array(
                                                array( 'product/support', '=', $view_parameters.support)
                                                )
                )
        )
} 

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

herve croce

Friday 25 July 2008 1:57:45 am

Thanks for trying,
but it give me the same result... nothing.
And if I suppress

'attribute_filter', array(array( 'product/support', '=', $view_parameters.profil))

It give me all products like with 'list'

I mix the examples from http://ez.no/doc/ez_publish/technical_manual/3_9/reference/modules/content/fetch_functions/list
Example 10

{fetch( 'content', 'list',
        hash( 'parent_node_id',   42,
              'attribute_filter', array( 'or',
                                        array( 152, '=', 'abc' ),
                                        array( 153, '=', '42' ) ) ) )}

This example demonstrates how to do attribute filtering. Only nodes that have attributes number 152 and 153 set to "abc" and 42 respectively will be included in the result.
Example 11

{fetch( 'content',
        'list',
        hash( 'parent_node_id',   42,
              'attribute_filter', array( array( 'article/title',
                                        'like',
                                        '*story*' ) ) ) )}

This example demonstrates how to do attribute filtering. Instead of specifying the ID number of the attribute (as in the previous example), the identifier of the class and the attribute is used. Only article nodes that contain the text "story" in their title attribute will be included in the result.

Thank's for someone who have a answer to this.

Ivo Lukac

Friday 25 July 2008 2:37:13 am

What value does your $view_parameters.support have?

AFAIK for selection filtering you must use selection id.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

herve croce

Friday 25 July 2008 7:24:38 am

It give me the result of the choosen 'product/support/options'.
Options:
DVD-Rom
OnLine
I tried with

{def $child=fetch('content', 'list', 
        hash( 'parent_node_id', $node.node_id, 
                 'depth', '2',
                 'class_filter_type', 'include', 
                 'class_filter_array', array('product'),
                 'attribute_filter', array(
                                                array( '209', '=', $view_parameters.support)
                                                )
                )
        )
}

the option_id=209
no result either...
Thanks for time you give on this.

Ivo Lukac

Friday 25 July 2008 9:18:48 am

You can't use selection text for attribute filtering.
Every selection item has text and id.

If you use {attribute_view_gui attribute=$node.data_map.your_selection} you will get selection text, if you use {$node.data_map.your_selection.content} you will get selection id.

Use selection id for filtering

NOTE: if the selection attribute is multiple you can't filter with standard attribute_filter, you must make custom extended_attribute_filter

Hope this is more clear :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

herve croce

Monday 28 July 2008 7:25:17 am

Thank's a lot!!
It's clear now.

code who generate GET parameters
i replace

$options.name

by

$options.id
  {def $tab_options=$class_product.data_map.support.content.options}
    {foreach $tab_options as $options}
      {if eq($module_result.view_parameters.support, $options.id)}
      <b>{$options.name}</b>
      {else}
        {if $module_result.view_parameters.language}
        <a href={concat( $Menu_produits[0].path[2].path_identification_string ,"/(support)/",
                     $options.id, "/(language)/",
                     $module_result.view_parameters.language
                     )|ezurl}>{$options.name}</a>
        {else}
        <a href={concat( $Menu_produits[0].path[2].path_identification_string ,"/(support)/",
                     $options.id
                     )|ezurl}>{$options.name}</a>
      	{/if}
      {/if}
    {delimiter}
    <br/>
    {/delimiter}
  {/foreach}

And now

{def $child=fetch('content', 'list', 
        hash( 'parent_node_id', $node.node_id, 
                 'depth', '2',
                 'class_filter_type', 'include', 
                 'class_filter_array', array('product'),
                 'attribute_filter', array(
                                                array( 'product/support', '=', $view_parameters.support)
                                                )
                )
        )
}

work's. :o)

Ivo Lukac

Monday 28 July 2008 8:29:12 am

Superb :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

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

36 542 Users on board!

Forums menu