- Posts: 38
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- Best way for categories/items to dynamically display module?
Best way for categories/items to dynamically display module?
- Brian
-
Topic Author
- Offline
- Junior Member
Less
More
10 years 5 months ago #134439
by Brian
Best way for categories/items to dynamically display module? was created by Brian
Hi, I am trying to limit the amount of hardcoding in my site. I have category pages that all follow a similar format and I am trying to figure out the best way to have their category page views consistently display the same info without having to edit the category content in the control panel. So you can imagine a category and subcategory. Call it cat 1, with sub cats subcat1, subcat2.
Cat1 page displays (using the xperts tab module for instance)
[Description]
[Tab 1 - Latest Documents across all subcats] [Tab 2 - Latest News across all subcats]
Then likewise for the subcats - a description, but then the tabs would be subcat specific.
So I just need to know where in the code (as much as I do not want to edit core K2 code, but in this case I have to, right?) to add the logic to do this:
- If cat is cat1, render description, render xpert tabs with latest documents and news across this cat
- If parent cat is cat1, render description, render xpert tabs with latest documents and news across this subcat
Thanks!!
Cat1 page displays (using the xperts tab module for instance)
[Description]
[Tab 1 - Latest Documents across all subcats] [Tab 2 - Latest News across all subcats]
Then likewise for the subcats - a description, but then the tabs would be subcat specific.
So I just need to know where in the code (as much as I do not want to edit core K2 code, but in this case I have to, right?) to add the logic to do this:
- If cat is cat1, render description, render xpert tabs with latest documents and news across this cat
- If parent cat is cat1, render description, render xpert tabs with latest documents and news across this subcat
Thanks!!
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 5 months ago #134446
by Lefteris
Replied by Lefteris on topic Best way for categories/items to dynamically display module?
Hi. You can do this in a K2 template override. Information regarding this can be found at getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates . Then you can just assign the cat1 to use the default template and the subcats to use a custom template override you created.
Please Log in or Create an account to join the conversation.
- Brian
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
10 years 5 months ago #134619
by Brian
Replied by Brian on topic Best way for categories/items to dynamically display module?
Interesting. So should I not use the category content editor and just do everything in the template? Right now I have things looking pretty good using {loadposition} calls but what I need is for the category description to be first, followed by subcat listing, then the {loadposition} results. Right now the subcat listing is last. Thanks!
Please Log in or Create an account to join the conversation.
- Brian
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
10 years 5 months ago #134620
by Brian
Replied by Brian on topic Best way for categories/items to dynamically display module?
Meant to ask, if I put all the loadposition calls in the template, will they be parsed? What would the syntax be? Just echo the calls using standard php echo call?
Please Log in or Create an account to join the conversation.
- Brian
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
10 years 5 months ago #134651
by Brian
Replied by Brian on topic Best way for categories/items to dynamically display module?
Hi,
I just tried to echo {loadposition pos} in caregories.php and that did not work. So I take it I am missing something and there is some way to properly implement loadposition in categories.php?
Thanks!!
I just tried to echo {loadposition pos} in caregories.php and that did not work. So I take it I am missing something and there is some way to properly implement loadposition in categories.php?
Thanks!!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 5 months ago #134664
by Krikor Boghossian
Replied by Krikor Boghossian on topic Best way for categories/items to dynamically display module?
Hello,
This thread will help you.
www.joomlaworks.net/forum/k2-en/37262-getting-a-module-to-display-before-comments#132284
This thread will help you.
www.joomlaworks.net/forum/k2-en/37262-getting-a-module-to-display-before-comments#132284
Please Log in or Create an account to join the conversation.
- Brian
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
10 years 5 months ago #134720
by Brian
Replied by Brian on topic Best way for categories/items to dynamically display module?
Thanks!!
That seems to be getting me closer to what I am trying to do. But I am trying to avoid creating the modules. I have subcategory pages, 9 of them, and each will have 3 tabs that display 3 types of content. So to use xperttabs, for example, I would have to create 27 modules and edit them all when I want to make changes. So I am trying to figure out how to have the template override render the module dynamically, perhaps using module display params from one actual module instance, but then rendering the item list for each tab dynamically, depending on current subcategory. That make sense? Thanks! I hope to soon answer questions and not just ask them!
That seems to be getting me closer to what I am trying to do. But I am trying to avoid creating the modules. I have subcategory pages, 9 of them, and each will have 3 tabs that display 3 types of content. So to use xperttabs, for example, I would have to create 27 modules and edit them all when I want to make changes. So I am trying to figure out how to have the template override render the module dynamically, perhaps using module display params from one actual module instance, but then rendering the item list for each tab dynamically, depending on current subcategory. That make sense? Thanks! I hope to soon answer questions and not just ask them!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 5 months ago #134788
by Krikor Boghossian
Replied by Krikor Boghossian on topic Best way for categories/items to dynamically display module?
i do not think that this is possible.
The module needs to be present in order to be displayed.
You can use multiple module areas in your template, some depending on your current category's id, but the module has to be both created and published
The module needs to be present in order to be displayed.
You can use multiple module areas in your template, some depending on your current category's id, but the module has to be both created and published
Please Log in or Create an account to join the conversation.
- Brian
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
10 years 5 months ago #135177
by Brian
Replied by Brian on topic Best way for categories/items to dynamically display module?
Finally went live with the site:
www.pfp-consortium.org
I really need to look at dynamically implementing the tabs on the Working Group and Products pages. It will be a nightmare to have to edit modules. I need to revisit the discussion about ajax and on another forum, or maybe here, there was a recommendation to use the bootstrap framework to do the tabs, but I wasn't sure what that meant.
Thanks for all the help!!!!
www.pfp-consortium.org
I really need to look at dynamically implementing the tabs on the Working Group and Products pages. It will be a nightmare to have to edit modules. I need to revisit the discussion about ajax and on another forum, or maybe here, there was a recommendation to use the bootstrap framework to do the tabs, but I wasn't sure what that meant.
Thanks for all the help!!!!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 4 months ago #135229
by Krikor Boghossian
Replied by Krikor Boghossian on topic Best way for categories/items to dynamically display module?
Hello again.
Kudos on the site.
The method I described needs strong JS/ jQuery skills.
You do a similar thing as this plugin github.com/paulirish/infinite-scroll
You get the items from a menu link and load with jQuery in a part of your site.
As for Bootstrap they have good documentation on getbootstrap.com
Kudos on the site.
The method I described needs strong JS/ jQuery skills.
You do a similar thing as this plugin github.com/paulirish/infinite-scroll
You get the items from a menu link and load with jQuery in a part of your site.
As for Bootstrap they have good documentation on getbootstrap.com
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- Best way for categories/items to dynamically display module?