EZenhanceObject Relation - are class and node filters mutually exclusive?

Author Message

rudy demo

Friday 01 April 2005 1:02:28 am

Hello.
I use last version of EZenhanceObject Relation on latest 3.4 version.
I notice the following behaviour:
1) class and node filtering
- I create an attribute and set <b>default selection node</b> AND <b>class</b> filters
- under the node specified I have objects from several classes and I see also these objects(i.e. users and user groups).
I was wondering if this is the normal behaviour of the extension?
2) I got an Error when using DropDown presentation
In the datatype/edit template(line 29)

$node.node_id

is accessed.
I got an error message there which is (I believe) correct because at that place, no access to a local var

$node

and not even to the global

$node

(because we're in edit mode so no access to global $node).
Is that correct?
Thank you.

Xavier Dutoit

Friday 01 April 2005 3:37:31 am

Hello,

I'm afraid we never needed to put both the node id and the class. For what I remembern that an OR.

If you know the template language and willing to try to modify the behavior, yo that's this template : extension/enhancedobjectrelation/design/standard/
templates/content/datatype/edit/ezenhancedobjectrelation.tpl

I'd be delighted to add your enhancement.

http://www.sydesy.com

rudy demo

Monday 04 April 2005 3:25:37 am

OK, Xavier, here's my pick then:
1. We should now have 3 filter options (Node), (class) , and (node and class).
2. I supposed the following(also deducing from your code :-)
2.1 if (Node) => All objects below that node(LIST fetch)
2.2 if (Class) => All objects of (Class) below the root node (2)(TREE fetch)
2.3 if (Node and Class) => All objects of (Class) below (Node)(LIST fetch)

Even, implemented like this for the time being, I would recommend the followings:
1. Let the user choose if he wants a list of tree by recording this in the datatype
2. Allow to select multiple nodes

I would really pleased to update the TPL script part for you, if you implement these two features in the PHP part.
These two extra-features really open up the possibilities of your datatype.

Back to the code, I added a new dadatype presentation too.
<b>1. the class edit datatype</b>
Please, note that I changed slightly the names of presentations so that they are technically more accurate(in my humble opinion, Xavier). So here are the changes...

<div class="element">
<label>{'Selection method'|i18n( 'design/standard/class/datatype' )}</label><div class="labelbreak"></div>

<select name="ContentClass_ezobjectrelation_selection_type_{$class_attribute.id}">
    <option value="4" {eq( $content.selection_type, 4 )|choose( '', 'selected="selected"' )}>{'Multiple select box'|i18n( 'design/standard/class/datatype' )}</option>
    <option value="3" {eq( $content.selection_type, 3 )|choose( '', 'selected="selected"' )}>{'Check boxes list'|i18n( 'design/standard/class/datatype' )}</option>
    <option value="1" {eq( $content.selection_type, 1 )|choose( '', 'selected="selected"' )}>{'Dropdown list'|i18n( 'design/standard/class/datatype' )}</option>
    <option value="2" {eq( $content.selection_type, 2 )|choose( '', 'selected="selected"' )}>{'Radio buttons list'|i18n( 'design/standard/class/datatype' )}</option>
{*    <option value="0" {eq( $content.selection_type, 0 )|choose( '', 'selected="selected"' )}>{'Browse'|i18n( 'design/standard/class/datatype' )}</option>*}
</select>
</div>

<b>2. content edit template</b>

<fieldset>
{* DO NOT EDIT THIS FILE! Use an override template instead. *}
{default attribute_base=ContentObjectAttribute}
{let class_content=$attribute.contentclass_attribute.content}

{switch match=$class_content.selection_type}

{case match=0} {* Browse *}
This choice shouldn't show up. Please select another selection method, and inform me (xavier) on the forum about this message.
    {section show=$attribute.content}
        <p class="box">{content_view_gui view=text_linked content_object=$attribute.content}</p>
    {section-else}
        <p class="box">{"No relation"|i18n("design/standard/content/datatype")}</p>
    {/section}

    <input type="hidden" name="{$attribute_base}_data_object_relation_id_{$attribute.id}" value="{$attribute.data_int}" />
    {section show=$attribute.content}
        <input class="button" type="submit" name="BrowseObjectButton_{$attribute.id}" value="{'Replace object'|i18n('design/standard/content/datatype')}" />
        <input class="button" type="submit" name="RemoveObjectButton_{$attribute.id}" value="{'Remove object'|i18n('design/standard/content/datatype')}" />
    {section-else}
        <input class="button" type="submit" name="BrowseObjectButton_{$attribute.id}" value="{'Find object'|i18n('design/standard/content/datatype')}" />
    {/section}
    <input type="hidden" name="CustomActionButton[{$attribute.id}_set_object_relation]" value="{$attribute.id}" />

{/case}

{case match=1} {* Dropdown list *}
    <div class="buttonblock">
    <select name="{$attribute_base}_data_object_relation_id_list_{$attribute.id}[{cond(is_set($node.node_id),$node.node_id}]">
        {section show=$attribute.contentclass_attribute.is_required|not}
            <option value="" {section show=eq( $attribute.data_int, '' )}selected="selected"{/section}>{'No relation'|i18n( 'design/standard/content/datatype' )}</option>
        {/section}
        {let parent_node=fetch( content, node, hash( node_id, $class_content.default_selection_node ) )}
        {section var=node loop=fetch( content, list,
                                      hash( parent_node_id, $parent_node.node_id,
                                            sort_by, $parent_node.sort_array ) )}
            <option value="{$node.contentobject_id}" {$attribute.content.id_list|contains($node.contentobject_id)|choose( '', 'selected="selected"' )}>{$node.name|wash}</option>
        {/section}
        {/let}
    </select>

    </div>
{/case}

{case match=2} {* radio button *}
        {section show=$attribute.contentclass_attribute.is_required|not}
            <input type="radio" name="{$attribute_base}_data_object_relation_id_list_{$attribute.id}[single]" {section show=eq( $attribute.data_int, '' )}selected="selected"{/section}>{'No relation'|i18n( 'design/standard/content/datatype' )}</input><br />
        {/section}
        {let parent_node=fetch( content, node, hash( node_id, $class_content.default_selection_node ) )}
        {section var=node loop=fetch( content, list,
                                      hash( parent_node_id, $parent_node.node_id,
                                            sort_by, $parent_node.sort_array ) )}
           <input type="radio" name="{$attribute_base}_data_object_relation_id_list_{$attribute.id}[single]" value="{$node.contentobject_id}" {$attribute.content.id_list|contains($node.contentobject_id)|choose( '', 'checked="checked"' )}>{$node.name|wash}</input>  <br/>
        {/section}
        {/let}
{/case}


{case match=3} {* check box *}
{section show=$class_content.default_selection_node}
        {let parent_node=fetch( content, node, hash( node_id, $class_content.default_selection_node ) )}
        {section var=node loop=fetch( content, list,
                                      hash( parent_node_id, $parent_node.node_id,
                                            sort_by, $parent_node.sort_array ) )}
           <input type="checkbox" name="{$attribute_base}_data_object_relation_id_list_{$attribute.id}[{$node.node_id}]" value="{$node.contentobject_id}" {$attribute.content.id_list|contains($node.contentobject_id)|choose( '','checked="checked"' )}>{$node.name|wash}</input>  <br/>
        {/section}
        {/let}
{/section}

{section show=$class_content.filter_class}
{section var=node loop=fetch( 'content', 
        'tree', 
        hash( 'parent_node_id',     2,
              'class_filter_type',  'include',
              'class_filter_array', array( $class_content.filter_class ) ) )}
           <input type="checkbox" name="{$attribute_base}_data_object_relation_id_list_{$attribute.id}[{$node.node_id}]" value="{$node.contentobject_id}" {$attribute.content.id_list|contains($node.contentobject_id)|choose( '','checked="checked"' )}>{$node.name|wash}</input>  <br/>
        {/section}
{/section}

{*{$attribute.content|attribute(show)}*}


{/case}
{case match=4} {* list box*}
    <div class="buttonblock">
    <select name="{$attribute_base}_data_object_relation_id_list_{$attribute.id}[{cond(is_set($node.node_id),$node.node_id}]" size="$10" multiple>
        {section show=$attribute.contentclass_attribute.is_required|not}
            <option value="" {section show=eq( $attribute.data_int, '' )}selected="selected"{/section}>{'No relation'|i18n( 'design/standard/content/datatype' )}</option>
        {/section}
        {* parent_node is default_selection_node or root(2) *}
        {let parent_node=cond(is_set($class_content.default_selection_node),fetch( content, node, hash( node_id, $class_content.default_selection_node ) ),2)
        		 nodesList=cond(is_set($class_content.filter_class),
        		 					fetch( content, list,
                                      hash( parent_node_id, $parent_node.node_id,
                                            sort_by, $parent_node.sort_array ,
                                            class_filer_type,'include',
                                            class_filter_array, array($class_content.filter_class)) ),
                           fetch( content, list,
                                      hash( parent_node_id, $parent_node.node_id,
                                            sort_by, $parent_node.sort_array ) )
                           )
        }
        {section var=node loop=$nodesList}
            <option value="{$node.contentobject_id}" {$attribute.content.id_list|contains($node.contentobject_id)|choose( '', 'selected="selected"' )}>{$node.name|wash}</option>
        {/section}
        {/let}  
    </select>
    </div>  
{/case}
{/switch} 
{*Display objects marked for editing *}
<fieldset>
{section loop=$attribute.content.edit_id_list}
	ID: {$:item}
	{let object=fetch( content, object, hash( object_id, $:item) )}
	{section name=Attribute loop=$object.contentobject_attributes}
		<div class="block">
		{section show=$:item.display_info.edit.grouped_input}
				<fieldset>
				<legend>
					{$:item.contentclass_attribute.name}
				</legend>
					{attribute_edit_gui attribute_base=concat( $attribute_base, '_ezorl_edit_object_', $:item.contentobject_id ) html_class='half' attribute=$:item}
				</fieldset>
		{section-else}
				<label>
					{$:item.contentclass_attribute.name}:
				</label>
				{attribute_edit_gui attribute_base=concat( $attribute_base, '_ezorl_edit_object_', $:item.contentobject_id ) html_class='half' attribute=$:item}
		{/section}
	{/section}
	{/let}
{/section}
</fieldset>
{*End displaying objects marked for editing*}
<input class="button" type="submit" value="Create New" name="CustomActionButton[{$attribute.id}_new_object]" />
{/let}
{/default}
</fieldset>

Keep me posted about what you think of my suggestions please.

Xavier Dutoit

Monday 04 April 2005 5:18:03 am

Lots of very good suggestions.

Could you contact me by email to discuss about how to make things move (eg, you use pubsvn to commit your patches).

ez .at. sydesy .dot. com

Talk to you soon

P.S. I'm going to add a suggestion for ez: let the authenticated users see other users email.

http://www.sydesy.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.