Keyword

K2 item in Multiple Categories

  • Simon Wells
  • Simon Wells's Avatar Topic Author
  • Offline
  • Platinum Member
More
14 years 3 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
14 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
14 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
14 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
13 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
13 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
13 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
13 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
13 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
13 years 9 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.


Powered by Kunena Forum