Author
|
Message
|
Dominik Stoeppel
|
Thursday 11 August 2005 4:43:39 am
hi, I try to filter content (like the bugsystem) but it doesn't work. I make an override template for a folder. The class has the attribute : branche ([Selektion] (id:279))with 3 options.
<div class="content-view-full">
<h1>{$node.object.data_map.name.content|wash()}</h1>
<form action={"content/action"|ezurl} method="post">
<input type="hidden" name="DestinationURL" value="{$node.url_alias}" />
<SELECT name="(filter)" size="1">
<OPTION value="service">Service</OPTION>
<OPTION value="industry">Industry</OPTION>
<OPTION value="healthcare">Healthcare</OPTION>
</SELECT>
<input type="submit" name="Submit" value="Go" />
</form>
{section show=or($view_parameters.filter) }
{let referencelist=fetch( 'content', 'list', hash( 'parent_node_id', 116,
'attribute_filter', array( 'and', array( 'branche', '=', $view_parameters.filter ) ) ) )}
{section var=filterlist loop=$referencelist sequence=array(bglight,bgdark)}
{node_view_gui view=line content_node=$filterlist}
{/section}
{$view_parameters.filter}
{/section}
{section-else}
{let page_limit=10
list_items=array()
list_count=0}
{set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id,
offset, $view_parameters.offset,
sort_by, $node.sort_array,
limit, $page_limit ) )}
{set list_count=fetch_alias( children_count, hash( parent_node_id, $node.node_id ) )}
<div class="content-view-children">
{section var=child loop=$list_items sequence=array(bglight,bgdark)}
{node_view_gui view=line content_node=$child}
{/section}
</div>
{include name=navigator
uri='design:navigator/google.tpl'
page_uri=$node.url_alias
item_count=$list_count
view_parameters=$view_parameters
item_limit=$page_limit}
{/let}
{/section}
</div>
If no parameters given, the section-else display normal list. If I select one from the form the URL looks ok. http://..../hc/referenzen/(filter)/industry Can someone help ? best regards dominik
|
Dominik Stoeppel
|
Wednesday 24 August 2005 6:14:59 am
Anyone ?
|
Kristof Coomans
|
Wednesday 24 August 2005 11:27:36 pm
There are some errors in your template. The let tag for defining the variable referencelist should be closed. There's a section-else for {section show=or($view_parameters.filter)}, but you've already closed this section. Maybe this solves the problem.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Dominik Stoeppel
|
Thursday 25 August 2005 4:15:31 am
thx for helping.
I correct the code but nothing changed :( Debug output don't show any errors.
|
Marko Žmak
|
Thursday 25 August 2005 5:44:40 am
Try with attribute ID instead of attribute identifier. Also make sure your template code is correct. A good idea would be to test just a small piece of your code, the one that you think isn't working.
--
Nothing is impossible. Not if you can imagine it!
Hubert Farnsworth
|
Kristof Coomans
|
Thursday 25 August 2005 7:01:26 am
The attribute filter seems to be incorrect.
attribute_filter', array( 'and', array( 'branche', '=', $view_parameters.filter ) ) )
If you specify an attribute identifier, you also have to specify the class identifier in front of it. I don't know which class you are trying to filter, but let's presume the class identifier is "testclass". The correct attribute filter would be
attribute_filter', array( 'and', array( 'testclass/branche', '=', $view_parameters.filter ) ) )
If that doesn't immediately work, maybe the class "testclass" (or the class attribute "branche") isn't cached yet in the class identifier cache. You can try to clear the class identifier cache through the admin interface.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Dominik Stoeppel
|
Thursday 25 August 2005 7:39:33 am
thx. it must be a problem with selection attribute. I have another attribute year (textline). Using this for testing my filter works.
{section show=or($view_parameters.filter) }
{let referencelist=fetch( 'content', 'list', hash( 'parent_node_id', 116,
'attribute_filter', array( 'and', array( 'referenz/jahr', '=', $view_parameters.filter ) ) ) )}
{section var=filterlist loop=$referencelist sequence=array(bglight,bgdark)}
{node_view_gui view=line content_node=$filterlist}
{/section}
{$view_parameters.filter}
{/let}
{section-else}
......
|
Kristof Coomans
|
Thursday 25 August 2005 10:58:03 pm
I found out that ezselection does not store the text value of the selected option. It stores the option's id. This id is also stored in sort_key_string. The value attribute of an HTML option should contain this id.
<SELECT name="(filter)" size="1">
<OPTION value="0">Service</OPTION>
<OPTION value="1">Industry</OPTION>
<OPTION value="2">Healthcare</OPTION>
</SELECT>
The order of id's depends on the order you entered your options when creating your content class. It starts counting with 0.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Kristof Coomans
|
Thursday 25 August 2005 11:20:02 pm
To make the list more dynamic, you could get the class attribute and loop over the options:
{def $classAttributes=fetch( 'class', 'attribute_list', hash( 'class_id', $class_id ) )}
{foreach $classAttributes as $classAttribute}
{if $classAttribute.identifier|eq('branche')}
{def $options=$classAttribute.content.options}
{foreach $options as $option}
<option value="{$option.id}">{$option.name|wash( xhtml )}</option>
{/foreach}
{undef $options}
{/if}
{/foreach}
{undef $classAttributes}
Replace $class_id with the id of your content class. You'll have to fetch a list of class attributes because there's no function to fetch a specific class attribute.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Kristof Coomans
|
Thursday 25 August 2005 11:33:26 pm
I made a mistake in my last post, there seems to be a function to fetch a class attribute in the content module. See http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/class_attribute
{def $classAttribute=fetch( 'content', 'class_attribute', hash( 'attribute_id', $classattribute_id ) )}
{def $options=$classAttribute.content.options}
{foreach $options as $option}
<option value="{$option.id}">{$option.name|wash( xhtml )}</option>
{/foreach}
{undef $options}
{undef $classAttribute}
Replace $classattribute_id with the desired class attribute id.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Dominik Stoeppel
|
Friday 26 August 2005 2:31:58 am
big thx Kristof. Dynamic list in the form and filter is working. Here is the complete template :
<div class="content-view-full">
<h1>{$node.object.data_map.name.content|wash()}</h1>
<form action={"content/action"|ezurl} method="post">
<input type="hidden" name="DestinationURL" value="{$node.url_alias}" />
<SELECT name="(filter)" size="1">
{def $classAttribute=fetch( 'content', 'class_attribute', hash( 'attribute_id', 279 ) )}
{def $options=$classAttribute.content.options}
{foreach $options as $option}
<option value="{$option.id}">{$option.name|wash( xhtml )}</option>
{/foreach}
{undef $options}
{undef $classAttribute}
</SELECT>
<input type="submit" name="Submit" value="Go" />
</form>
{section show=or($view_parameters.filter) }
{let referencelist=fetch( 'content', 'list', hash( 'parent_node_id', 116,
'attribute_filter', array( 'and', array( 'referenz/branche', '=', $view_parameters.filter ) ) ) )}
{section var=filterlist loop=$referencelist sequence=array(bglight,bgdark)}
{node_view_gui view=line content_node=$filterlist}
{/section}
{/let}
{section-else}
{let page_limit=10
list_items=array()
list_count=0}
{set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id,
offset, $view_parameters.offset,
sort_by, $node.sort_array,
limit, $page_limit ) )}
{set list_count=fetch_alias( children_count, hash( parent_node_id, $node.node_id ) )}
<div class="content-view-children">
{section var=child loop=$list_items sequence=array(bglight,bgdark)}
{node_view_gui view=line content_node=$child}
{/section}
</div>
{include name=navigator
uri='design:navigator/google.tpl'
page_uri=$node.url_alias
item_count=$list_count
view_parameters=$view_parameters
item_limit=$page_limit}
{/let}
{/section}
</div>
|