Keyword

Link to article from SubCat if only 1 item exists?

  • Michael Tull
  • Michael Tull's Avatar Topic Author
  • Offline
  • New Member
More
11 years 6 months ago #111612 by Michael Tull
Hi there,

I am looking to do something perhaps a little 'tricky' and maybe even flat out not possible, and wondering if anyone might have any suggestions on how to achieve this, or might have some code to share if it has been done before. I searched the forum but its a little difficult to search for.

What I am trying to do is if subcategory count = 1 , link directly to the article rather than to the subcategory containing just the one item.

I have for example one category that has 15 subcats ... and about 5 of them currently have only one article and may never have more ( think a product catalog type of thing )

I have created and customized several different K2 templates already for this one site so I understand the basics and know that I would need to make major changes... and have found the code in category.php and can check the count with $subCategory->numOfItems, and this is were my idea came from... but my PHP kung fu is a little weak :) and that is were I am stuck....

How - (if at all possible) might I get the article URL for the single item in the subcat ?

Obviously in category_item.php I use - echo $this->item->link; - but category_item is in the loop and already knows the current article... thus the $this->item

I realize that this might be flat out impossible but I am hoping that some of the brainiacs out there might have some kind of idea how this might be achieved if it is possible.

Any thoughts, snippets or even a 'just dont bother' :) would be appreciated.

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

More
11 years 6 months ago #111613 by Dick Verwey
Hi,

I have exact the same question!

I have a site with multiple subcategories, some of them contain multiple k2 items, some of them just 1.

Would be nice to link that one directly to k2 item if clicked on that subcategory.

Thanks in advance.

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


Powered by Kunena Forum