Thursday 16 December 2004 7:09:49 am
Hi Martin. I would actually recommend you avoid the multiple location route. While it makes sense at first, it grows cumbersome very quickly. I have one site that uses this method and it is a pain to use, and is significantly slower than it should be. For the site that I am currently developing, I am using the Enhanced ObjectRelation contribution.
<b>Setup</b> Under my main node, I have to folders setup, <i>Products</i> and <i>Categories</i>.
I have set up two classes:
<i>Category</i>
- Title [Text Line]
- Short Description [Text Field] - Description [XML Text Field]
<i>Product</i>
- Item Number [Text Line]
- Name [Text Line]
- Image [Image]
- Price [Price]
- Category [Enhanced Object Relation] - Several other fields
In the Product class, the <i>Category</i> Enhanced Object Relation has the following settings:
- Required
- Selection Method: List with Checkboxes (Allows multiple categories) - Default Selection Node: 'Categories' (the folder that holds all of my categories) So, when an editor adds a new product, all they have to do is click the checkboxes next to the categories that are associated with the item. They can choose as many as they would like, as long as they choose at least one.
<b>Template Code</b> I use this code to display all items within a category:
{default with_children=true()
is_editable=true()
is_standalone=true()}
{let page_limit=15
list_count=and($with_children,fetch('content',
'list_count',
hash(parent_node_id,
$node.node_id,
depth_operator,eq)
)
)
}
{default content_object=$node.object
content_version=$node.contentobject_version_object
node_name=$node.name}
{* Reverse relation *}
{let reverse_related=$node.object.current.reverse_related_object_list}
<ul>
{section name=ReverseObject loop=$reverse_related show=$reverse_related}
<li><a href={$ReverseObject:item.main_node.url_alias|ezurl}>{$ReverseObject:item.name}</a></li>
{/section}
</ul>
{/let}
Enhanced ObjectRelation: http://ez.no/community/contribs/datatypes/enhanced_objectrelation
Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]
<i>When in doubt, clear the cache.</i>
|