Keyword

K2 Category view from url

  • JM Bonnerot
  • JM Bonnerot's Avatar Topic Author
  • Offline
  • New Member
More
4 years 3 weeks ago - 4 years 3 weeks ago #177335 by JM Bonnerot
K2 Category view from url was created by JM Bonnerot
Hello,

I'm using this kind of url to make an ajax request :

xmlhttp.open("GET", '../index.php?option=com_k2&view=itemlist&layout=category&task=category&id='+varId+'&format=raw',true);

and it's working fine.

My question is, is there any way to use a specific template by calling special parameters (i'd like my category view to only shows subcategories, item being only shown from thesubcategory), or creating a specific view that i could call from this.

What are the different views, layoust and tasks i can call and what are the differences ?

Also the prob is the same category may be called from another page where i would like it to show both subcategories and items (so i'd like to find an other than just setting a template override for the category itself).

Maybe use an extension like aditionnal categories for K2, set a custom template on that additionnal category and ajaw request on that additionnal category ?

What would be the best way to achieve something like this ?

(ps: would be awesome to have a specific CSS loaded for that specific view)

Thanks in advance and have a great day !
Last edit: 4 years 3 weeks ago by JM Bonnerot.

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

More
4 years 3 weeks ago #177339 by JoomlaWorks
Replied by JoomlaWorks on topic K2 Category view from url
Technically speaking, it's not hard to do any of the things you ask.

However, because most of what you ask is probably "pro level" stuff, these requests can't be generally identified and implemented in K2.

If you need to load a different category template you can check for the category ID at the top of your category.php override and then split your code to 2 or more sub-templates. Combine this check with menu item IDs and you'll be able to call the same category with a different layout based on where the visitor currently is.

You can follow a similar practice to load a CSS file based on category ID, parent category, category name etc.

In general you have your views (item, itemlist, latest), layouts for the itemlist view (category, tag, user etc.) & formats (html, feed/xml, json, jsonp, raw).

If you need a very specific example, please ask.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • JM Bonnerot
  • JM Bonnerot's Avatar Topic Author
  • Offline
  • New Member
More
4 years 3 weeks ago #177344 by JM Bonnerot
Replied by JM Bonnerot on topic K2 Category view from url
It helped me a lot and successfully managed to set my template based on both category and menu ID.

I'm still a newb and will surely face more prolbmes in the next days but you got me on the right direction.

Thanks a lot !!

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

More
4 years 3 weeks ago #177350 by JoomlaWorks
Replied by JoomlaWorks on topic K2 Category view from url
You're welcome JM :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum