Keyword

K2 item in Multiple Categories

  • Simon Wells
  • Simon Wells's Avatar Topic Author
  • Offline
  • Platinum Member
More
15 years 2 months ago #79109 by Simon Wells
K2 item in Multiple Categories was created by Simon Wells
Heres a little challenge.How to get a K2 item to appear in more than one category without coyping it?Any ideas?Thanks.SimonK2Joom.com

Please Log in or Create an account to join the conversation.

More
15 years 2 months ago #79110 by Ivan Descartes
Replied by Ivan Descartes on topic K2 item in Multiple Categories
This is such an important feature for K2, and the implementation is not impossible. First, I will say why this is important: Users should be able to navigate content listings, and find an item by different paths, without copying content between categories. So unless K2 can make NESTED TAGS (which would effectively be the same as multiple categories), this is still important. Think about Ebay or another retailer that puts links to items under "Bestsellers" and also "Video Games".

So how to implement? Here is the best way:

First, from the item creation, it can be assigned to multiple categories. 1 category is set as the primary category, and this category is stored in catid in the database (for compatibility). All other categories are stored in a new database table that maps items to categories by paths. The schema for this table:

ID (primary key) ItemID CatID PathID (optional)

The ID is just the primary key. The ItemID stores the article ID. The cat ID stores the CatID. The PathID is an optional parameter that reflects if this is path 1, path 2, path 3, .... to get to this item.

Any time an item is created, we make unique entries for each category assignment. This puts the database load on the item creation rather than search (if we had put all of the categories comma-separated in the original items table). When a category listing is requested, we just find all of the items in this Paths table that match, and list them. Other modules that use K2 should start using this table.

So for URLs, there is an SEO way and a non-SEO way, I want to highlight both, and suggest the SEO way.

SEO way: only 1 url per article. Unless some magical cookies or database are used, the page cannot reflect which category the user arrived by.
non-SEO way: multiple urls per article. This allows the URL to reflect the category that the viewer reached the item by. However, it also means that there are multiple URLs for the same item. This could be done simply by appending the "path" to the end of the URL to allow K2 breadcrumbs to properly display the path, or the whole url would be set correctly (the latter being preferable).

Let me know if this makes sense. The feature is quite important if K2 wants to be THE content solution.

Please Log in or Create an account to join the conversation.

More
15 years 2 months ago #79111 by Ivan Descartes
Replied by Ivan Descartes on topic K2 item in Multiple Categories
Another way, which is much easier: Add catid2, catid3 .... catidx to the k2_items table. This would work well, but means that K2 will dictate how many categories an item can be added to. I think 3 categories is a reasonable limit. Of course, this results in a performance hit, since all of the fields in ITEMS must be checked for a listing, even if an item is only listed in 1 category. So in the worst case, where all items appear in just 1 category, there is a 3x hit. In the best case, where all items are in 3 categories, it is the same cost as the previous suggestion.

Please Log in or Create an account to join the conversation.

More
15 years 2 months ago #79112 by FeSys
Replied by FeSys on topic K2 item in Multiple Categories
Hello Simon...
I guess this is the easiest way for now.. Give it a try.. works for me fine.

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #79113 by Danny Malouin
Replied by Danny Malouin on topic K2 item in Multiple Categories
Hi,

Has this been adressed ?

I would like to assign items to more than one category as well.

Thanks,

Danny
www.6degres.ca
Évoluez sur le 3W!

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #79114 by Oceanwatcher
Replied by Oceanwatcher on topic K2 item in Multiple Categories
I have a case right now where I would love to be able to set several categories for one article. For now, it has been solved with the use of tags, and I suspect this is how we will have to use it in the future.

It might just be that we are used to think in a certain way and we got used to this by using a different software/system. I am also using WordPress for a couple of sites and like some of the things there a lot. And I am used to the category system there.

But maybe it is better to switch this for the tags. Maybe that is a more flexible way of doing it? Opinions?

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #79115 by FidelGonzales
Replied by FidelGonzales on topic K2 item in Multiple Categories
I don't think the concept of the single-category per item content structure is a way of thinking that is advanced and, therefore, a reason to change the content construction strategy and our subsequent way of thinking. It is merely a huge limitation in the way K2 works, and the way in which virtually every other blogging and CCK software functions.

While there are unique and very favorable advantage to using K2, the aforementioned issue is a huge drawback to many of its other unique features, one that Fotis has no interest in solving, as per blog posts and Tweets. I am certain there is some purpose to his reasoning, but I have yet to hear it nor cannot fathom any reason that would justify remaining the course on this methodology.

Personally, if tags were given the ability to possess content description, photos and process Joomla plugins, the problem would be solved and produce some beautiful content, an intuitive interface and some excellent SEO.

With that said, here's a semi-related topic I created.

community.getk2.org/forum/topics/process-joomla-plugins-in-k2?commentId=3536014%3AComment%3A66364

Svein Wisnaes said:I have a case right now where I would love to be able to set several categories for one article. For now, it has been solved with the use of tags, and I suspect this is how we will have to use it in the future.
It might just be that we are used to think in a certain way and we got used to this by using a different software/system. I am also using WordPress for a couple of sites and like some of the things there a lot. And I am used to the category system there.

But maybe it is better to switch this for the tags. Maybe that is a more flexible way of doing it? Opinions?

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #79116 by william white
Replied by william white on topic K2 item in Multiple Categories
Whatever is done will modify the core, but will work.
How about putting the category id's in a field like the xtra filelds and teach the core to parse them out.
Its changing the way things work - not likely to happen unless a module like followeyes points to can do it for you

Ivan Descartes said:Another way, which is much easier: Add catid2, catid3 .... catidx to the k2_items table. This would work well, but means that K2 will dictate how many categories an item can be added to. I think 3 categories is a reasonable limit. Of course, this results in a performance hit, since all of the fields in ITEMS must be checked for a listing, even if an item is only listed in 1 category. So in the worst case, where all items appear in just 1 category, there is a 3x hit. In the best case, where all items are in 3 categories, it is the same cost as the previous suggestion.

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #79117 by Danny Malouin
Replied by Danny Malouin on topic K2 item in Multiple Categories
Not sure how the rest would be affedcted but creating a table to join category ID's is pretty simple as far as database modeling goes ... That being said, I don't wan't to judge how and why it's the way it is, it simply is :-)

Maybe the developpers would like to say a word ?

Danny

Please Log in or Create an account to join the conversation.

More
14 years 8 months ago #79118 by Abdul Muhaymin
Replied by Abdul Muhaymin on topic K2 item in Multiple Categories
Sir,
I have added table, now how to bring selecting option in backend, pls solve it. Where, in which page we have to edit changes.

Thanks
Abdul Muhaymin

Ivan Descartes said:Another way, which is much easier: Add catid2, catid3 .... catidx to the k2_items table. This would work well, but means that K2 will dictate how many categories an item can be added to. I think 3 categories is a reasonable limit. Of course, this results in a performance hit, since all of the fields in ITEMS must be checked for a listing, even if an item is only listed in 1 category. So in the worst case, where all items appear in just 1 category, there is a 3x hit. In the best case, where all items are in 3 categories, it is the same cost as the previous suggestion.

Please Log in or Create an account to join the conversation.

More
14 years 8 months ago #79119 by Oceanwatcher
Replied by Oceanwatcher on topic K2 item in Multiple Categories
FidelGonzales:

As I am not a programmer, it is a little bit difficult for me to look at things deeper down, but I did a little experiment.

I have a couple of sites that run on WordPress, and in WP, you can easily add an article to as many categories as you want. So I checked the database.

In the wp_posts table, there is something about category, but it is not used. Instead, there are three tables

wp_terms
wp_term_relationships
wp_term_taxonomy

Checking these makes it clear that the terms are merely a form of tags that are grouped into different functions according to the taxonomy table (forgive me for describing this in laymans terms - non-programmer, remember? :-D ).

So depending on the taxonomy, a term can be either a "category", a "link_category" or a "post_tag".

I have no idea how big hit the database in WP takes by doing it this way, but it can not be too bad as WP runs with a lot of big sites...

Please Log in or Create an account to join the conversation.

More
14 years 7 months ago #79120 by krmr
Replied by krmr on topic K2 item in Multiple Categories
@Svein Wisnaes
Using tags to organise content is for sure lot more flexible, but there comes the tags view in k2, that is so much more limited than the catview. No author is displayed in tags view (the generic.php template) for example? And that is simply not acceptable in certain site formats. like a publication

Please Log in or Create an account to join the conversation.

  • kiril Hristov Yovev
  • kiril Hristov Yovev's Avatar
  • Offline
  • Junior Member
More
14 years 7 months ago #79121 by kiril Hristov Yovev
Replied by kiril Hristov Yovev on topic K2 item in Multiple Categories
with the component "Zoo" you can add item un multiple categories. I think that the k2 developers should do something about this... this is a must have feature... it is really really important. When few months ago i've opened new thread about this you've said to me that this problem is solved with the tags-but it's not the same. There are huge diferenses between tags and multiple categories... DOn't understand me wrong-i love k2.....but i really miss this great feature...

(SOrry for my bad english)

Please Log in or Create an account to join the conversation.

More
14 years 7 months ago #79122 by FidelGonzales
Replied by FidelGonzales on topic K2 item in Multiple Categories
You're English is good. And we understand your frustration. Zoo has its advantages but, after my limited testing, as a whole, it does not compare to the complete package K2 offers. Though, as you stated, perhaps one of the most intuitive and necessary functionality, multi-category publishing of a single item, does not exist in K2 but does in Zoo. I have much time and effort into K2, but I actually have tested Zoo to consider migrating to it due to this limitation in K2. I'm not hopping the fence anytime soon but am keeping an open mind. Thanks for your comments.

kiril Hristov Yovev said:with the component "Zoo" you can add item un multiple categories. I think that the k2 developers should do something about this... this is a must have feature... it is really really important. When few months ago i've opened new thread about this you've said to me that this problem is solved with the tags-but it's not the same. There are huge diferenses between tags and multiple categories... DOn't understand me wrong-i love k2.....but i really miss this great feature...
(SOrry for my bad english)

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #79123 by HankBrown
Replied by HankBrown on topic K2 item in Multiple Categories
Hello everyone ... I am currently keeping myself busy with K2 too and just as all the other here I am looking for multi-category publishing of a single item! However, during my research for a solution I came across a thread in people.joomla.org ... check it out: people.joomla.org/groups/viewdiscussion/112-Multiple+Categories+for+Items.html?groupid=47

Apparently this guy, named Jason Hart, did some work on an own MultiCat-solution for K2 already. Sure, it is only an Aplha-Version and only in combination with K2 v.2.2 but it might be a good start for a complete solution to our all problem ... don't you think so too? I am unfortunately not a professional progammer myself but maybe you guys or the people of the K2-development team can give this guy Jason Hart a hand in what he already has started ...

Here is his website with the current Alpha-Version of K2 MultiCat as download: www.developmii.com/downloads/k2-multicat.html

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #79124 by Tafadzwa Makura
Replied by Tafadzwa Makura on topic K2 item in Multiple Categories
I use tags! By giving tags similar names to categories and locking them so that the user cannot add their own custom tags I then allow users to add their article to one "primary" category in the category list and choose as many "category-tags" as they want in the tag list! This means that if a user/publisher publishes their article entitled "Major Health Issues Sportsman and Artists Face" and they want it to appear in the Health, Sports and Arts categories they will have to choose the primary category in the category list which in this case could be the Health category, this is where the article will be stored and linked to. If the user however adds the Sports, and Arts tags to their article the article will also appear in these categories as related items in the item layout of the Sports and Arts categories!

I haven't tried this though but i'm sure by adding the (Related Items by Tag) code block in the category list view i can also make all items that share one of their tags with the current Category appear in that Category's list! The major drawback is that users won't be able to user their own custom tags.

 

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #79125 by Tafadzwa Makura
Replied by Tafadzwa Makura on topic K2 item in Multiple Categories
In future K2 versions I think this can be easily achieved by employing the Primary and Secondary Category model as I mentioned in my previous post! What this will mean is that each item on creation will have a primary Category this is the "Host/Primary category" where the item will be stored and linked to! In addition an article could have a number of Secondary Categories much like a tag  but they will have similar names to existing categories since they will get their names from the k2 cartegories table this way they become dynamic. If a Primary Category is created then a Secondary Category is automatically created as well, when a Primary Category is deleted then the corresponding  Secondary Category is deleted as well. Users/Editor/Admin etc won't be allowed to add/edit/delete Secondary Category names directly this can only be done by adding/editing/deleting a Primary category.

 

After a user has created their item they choose the primary category they want their item to belong to, this is where the reference article can be stored. Just like tags a user can then add as many multiple Secondary Categories as they need. Secondary Categories only pull the refrence item directly  from it's primary Category without copying or moving it! If the Item is deleted from it's primary category then the Secondary categories will automatically stop linking to it because it disappears with its stored secondary Category (just like tags). 

 

In the category list  a php script will fetch the value of the current primary category title lets call it ($currentPrimCatTitle) and then pull any other items whose secondary category title ($item->secCatTitle ) matches ($currentPrimCatTitle). These articles will then be displayed in the cartegory list with all the other articles that share that Category. This system already works with tags I'm sure it will be much easier to intergrate. 

 

Advantages. 

1.) Only one copy of an item will be used to create multiple instances of it in different cartegories. 

2.) The creation/deletion and edition of Secondary Categories will happen dynamically making sure they remain synced with their Primary Category Counterparts and reducing the workload on the users part.

3.) No additional Data is written to the Database outside the item's database row when an item is added! 

4.) The system is intuitive, meaning a user/editor/admin can easily add and remove  Secondary Categories from their current item.

5.) Changing an item's Primary Category will not break it's connection with it's current Secondary  Categories (Just like Tags)

6.) Parameters and ACL can also be used to block specific Secondary Categories from being attached to a none Admin User's Item i.e (FAQ and Admin Secondary Categories will not be added to to a None Admin Item)  

 

If used please credit this idea/concept to me! 


Tafadzwa Makura said:

I use tags! By giving tags similar names to categories and locking them so that the user cannot add their own custom tags I then allow users to add their article to one "primary" category in the category list and choose as many "category-tags" as they want in the tag list! This means that if a user/publisher publishes their article entitled "Major Health Issues Sportsman and Artists Face" and they want it to appear in the Health, Sports and Arts categories they will have to choose the primary category in the category list which in this case could be the Health category, this is where the article will be stored and linked to. If the user however adds the Sports, and Arts tags to their article the article will also appear in these categories as related items in the item layout of the Sports and Arts categories!
I haven't tried this though but i'm sure by adding the (Related Items by Tag) code block in the category list view i can also make all items that share one of their tags with the current Category appear in that Category's list! The major drawback is that users won't be able to user their own custom tags.

 

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #79126 by Tafadzwa Makura
Replied by Tafadzwa Makura on topic K2 item in Multiple Categories
You can achieve category images, descriptions, etc. by calling the relevant tags in the category view instead of viewing them in the tag list. What this means is that your related by tag articles will appear below the actual articles in the category view including category images, descriptions, etc. Since all changes are made in the custom template folder there is no hacking involved!

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #79127 by Nick
Replied by Nick on topic K2 item in Multiple Categories
use an xref table. Easy. That way you can link multiple categories to 1 item id. Or you can go the cheap way and store all the categories inside a new row and have php then parse out the id's. This can be done with explode() and implode()

As for the back end you can have a new drop down appear after you select a category. I have over 200 categories so a tag based system or a simple list system wouldn't work for me (unless the list is inside a frame)

It's really not hard to do guys.. I could code it in several days.. i'm just working on college stuff right now.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago #79128 by juju
Replied by juju on topic K2 item in Multiple Categories
Nick : If you could do that, it will be really great, and I think it should be integrated to the next version of K2....

 

Thanks ;)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum