Forums / Setup & design / How can I use values from enumobject in a class_filter_array for fetch?

How can I use values from enumobject in a class_filter_array for fetch?

Author Message

Daniel Staver

Monday 05 January 2004 5:34:23 am

I've created a class called content_list which a user can embed into their pages to list content from a selected node, select number of elements listed and enable or disable google navigation for the content.

I also want user-defined class filtering for the content, but can't make it work.

I've made an enum element in the class which contains the class ID's the user is allowed to select. How do I convert the values from this enum element into an array that I can pass to class_filter_array in the fetch?

Daniel Staver
http://daniel.staver.no

Wenyue Yu

Wednesday 07 January 2004 1:28:37 am

Hi,

Suppose that you have defined your enum element something like following:
Enum element->Article Enum value->2
Enum element->Image Enum value->5
Enum element->Folder Enum value->1
...
To convert the values from enum object to a array, you can first define a variable in your template, then access the enum object and assign values to the variable, and finally use this variable to filter fetching. Here is a example:
{let myarray=array() enumlist=$node.data_map.your_attribute_identifier.content.enumobject_list}
{section loop=$:enumlist}
{set myarray=$myarray|append($:item.enumvalue)}
{/section}
{let object_list=fetch(content,list,
hash(parent_node_id,
2,
class_filter_type, include,
class_filter_array,$myarray ) )}
{/let}
{/let}

Regards,
wenyue