Keyword

Link to single item from Subcat with only1 item?

  • Michael Tull
  • Michael Tull's Avatar Topic Author
  • Offline
  • New Member
More
11 years 7 months ago #110531 by Michael Tull
HI there,

I have an "is it possible" question regarding K2. I have a number of reasonably modified override sets for multiple categories using K2. I have a situation where I am displaying only sub categories of the main category ( no items ) - These categories have varying numbers of items within then, some with many items, and a few of them with ( and will only ever be ) 1 item.

I am wondering if any of the very clever people here might have any thoughts on how / if it might be possible, that when a link on any subcat containing only 1 item is clicked, that the item itself is loaded rather than the subcat containing only the 1 item? This would stop users having to click twice to get to those items.

I realise that this is probably not something many people would want to do and I have never run into the issue before, but in this particular case it would actually improve the site usability.

These are my thoughts so far:

I can see the foreach loop for the subcats, and I can see that $subCategory->numOfItems is available to check... but if I want to display the standard subcat format/image etc, but link to the one item URL within that particular category, then the rest of the code is in the category_item.php

In VERY simple terms I am guessing I would have to do a check on the numOfItems before writing the URL to the SubCat item and if < 2. then write the item URL instead... but how if at all might I get the item URL? ... that where my logic/through process is falling down. Is it possible all?

As I mentioned above, I have / can modify K2 templates, and I can make basic changes, cut and paste PHP etc, but my skills are not great.

If anyone out there might at least point me in the right general direction ( or tell me if I am barking up the wrong tree... or the whole idea is too difficult etc : ) it would be greatly appreciated.

Many thanks in advance.

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


Powered by Kunena Forum