Category / sub-category question - how do I achieve this?

Author Message

Martin Crockett

Wednesday 15 December 2004 12:54:52 pm

Hi there,

Excuse my ignorance here but I am fairly new to eZ publish.

I seem to have hit a brick wall with developing a website using eZ publish (currently running version 3.5.0rc2).

I want my news articles to "belong" to one of ,say, 10 main categories and one or more of sub-categories specific to their "parent".

I'm thinking this is possible in eZ publish but have exhausted many hours trying to get something working.

Can anyone point me in the right direction?

I'm thinking 'object relation lists' are the way to go but have had no success with these as yet.

Drink(s) are on me for the right answer. :)

Thanks!

Sébastien Prud'homme

Wednesday 15 December 2004 1:06:55 pm

The simplest way to do that is to create one folder per category and sub-folders for sub-categories. Then you can use locations to put one article in different folders/categories.

Martin Crockett

Wednesday 15 December 2004 1:45:15 pm

Thanks for the reply - I had already taken the same path you mentioned as it seemed the most logical.

The problem is, the client has been sold on a "magical" drop-down menu solution.

i.e. You select from the main category drop-down field, and the sub-category drop-down is dynamically populated.

Is something like this possible?

Alex Jones

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>

Badger Mushroom

Friday 21 January 2005 11:57:51 am

Hi Alex,

Just curious, does that Enhanced Object Relation work with EZ 3.5?

Also, I have a new site with this structure using 'add location' to display content in 2-3 locations. I use a trick provided by one of the moderators to eventually hyperlink all the 'objects' under Folder (4) URL. eg. All object links point to /folder4/object_x instead of having 3 different URLs pointing to the same content. I don't want /folder1/object_x, /folder2/object_x, /folder3/object_x, all of which contain the same content.

Anyhow, my question is whether or not my method is good or should I adopt your Enhanced Relation Object trick. Thanks much.

Folder (1)
- Sub-folder -> Object A, B, C

Folder (2)
- Sub-folder -> Object D, E, F

Folder (3)
- Sub-folder -> Object G, H, I

Folder (4)
- Object A
- Object B
- Object C
- Object D
- Object E
- Object F
- Object G
- Object H
- Object I

Łukasz Serwatka

Friday 21 January 2005 12:28:11 pm

Hi,

Just curious, does that Enhanced Object Relation work with EZ 3.5?

This functionality is build in eZ publish 3.5. I use this functionality in FAQ when the one object is releated to another.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Bruce Nordstrand

Wednesday 22 February 2006 4:04:09 pm

Hmmm, should I be excited about this? I have been searching high and low for another CMS that has the ability to assign an article to multiple categories and was going to settle on Drupal because of it's taxonomy. However, I have been keeping an eye on eZ since version 2. something, hoping to use it instead. You see I want to structure things like this:

Information (defined as single "select")
-Media Release
-News Item

Region
-Australia
-New Zealand
-United States
-Other Region

Division
-Sprintcars
-Midgets
-Street Stocks
-Litre Sprints
-Junior Sedans
-Solos/Sidecars
-Speedway Karts
-Other Division

Now, a user creates an article as then tags it with Media Release, Australia, Sprintcars and Midgets

I can then display all the Media Releases or all the Australian Region articles or all the Sprintcar articles and the new article would appear in all of the returned listings.

Can this be accomplished with Enhanced Object Relation? Please say yes :)

Cheers
Bruce

Xavier Dutoit

Thursday 23 February 2006 1:38:05 am

@Badger Mushroom

enhanced object relation works fine with ez 3.5, follow the install instruction, if I remember properly, it involves a simple modification on the database structure (adding a field in one table).

X+

http://www.sydesy.com

Xavier Dutoit

Thursday 23 February 2006 5:20:22 am

@Bruce Nordstrand

Can this be accomplished with Enhanced Object Relation? Please say yes :)

Short answer: yes

Long answer:
you create 3 attributes (of type enhanced object relation)

1) Information (defined as single "select", I'd choose radio button as selection method)
put
-Media Release
-News Item
under a node "dummy" and select it as the location/placement

2) Region (multiple with check box or list or radio button)
choose type "region" and create the following objects a region (location not important)
-Australia
-New Zealand
-United States
-Other Region

3) Division (multiple selection with check box)
as region: create a type division and create the following region object:
on eor, select class division
-Sprintcars
-Midgets
-Street Stocks
-Litre Sprints
-Junior Sedans
-Solos/Sidecars
-Speedway Karts
-Other Division

I can then display all the Media Releases or all the Australian Region articles or all the Sprintcar articles and the new article would appear in all of the returned listings.

Modify the display of division, region so it displays the reverse related objects (ie objects that have selected this division as enhanced related object.

Life is great and you owe me a bier ;)

X+

http://www.sydesy.com

Bruce Nordstrand

Thursday 23 February 2006 5:38:53 am

@Xavier Dutoit

Excellent! Now I am excited!! :)

The clincher will be if, at a future date, I decide to expand my category listings. For example, I receive a good number of articles that have been posted in the "Other ..." categories. I decide that a couple of new categories are in order to accomodate some of those articles. Can I then go into each article and reassign them to the new categories, taking them out of the "Other ..." categories at the same time?

Oh, and life IS great and if I can figure out how to get a beer from Australia to you I will!

Cheers
Bruce

Xavier Dutoit

Thursday 23 February 2006 11:36:19 pm

Hi Bruce,

Yes you can update the list of available categories and update the existing objects to associate them with these new categories. And you can of course "unassociate" them from any existing category (eg. other) in the same step.

I suggest you to go directly to pubsvn, as version of enhanced object relation hasn't been updated on the community/contrib section of this website since... ages.

X+

http://www.sydesy.com

Bruce Nordstrand

Friday 24 February 2006 4:25:22 am

Thanks Xavier

Great news. And thanks also for the advice of grabbing the component from pubsvn, I will certainly do that.

I am *very* early in implementing an eZ site. I am installing Joomla (I know, I know) in the meantime to get something running. It will all be transferred to eZ once I get confortable with the inner workings. Drupal got dropped because of aupport issues and lack of image support in articles....

Cheers
Bruce

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