- Posts: 2
COMMUNITY FORUM
Load category items in tabs (content module override)
- Pedro Santos
-
Topic Author
- Offline
- New Member
Less
More
10 years 2 months ago #141666
by Pedro Santos
Load category items in tabs (content module override) was created by Pedro Santos
Hello.
I am making a product catalog with a k2 module and I wanted to make a category filter for the display. I didn't want it to load a new page in the process, so I tought in using a simple html tabs mechanism with a loop scan in a mod_k2_content override. That's seemed a quite simple task and I arranged the following code structure that seemed to solve my problem:
The caps is the code I think I need. I tried copying code from other k2 phps that's seemed to fit but I got the messege that they were out of context, and then I looked up for snippets - I don't have good programming skills, as a begginer I am - but could find them.
If such a get function can be used inside this override I ask for a snippet.
And maybe there is another way of getting that filter function I desire?
Thanks in advance,
Pedro
I am making a product catalog with a k2 module and I wanted to make a category filter for the display. I didn't want it to load a new page in the process, so I tought in using a simple html tabs mechanism with a loop scan in a mod_k2_content override. That's seemed a quite simple task and I arranged the following code structure that seemed to solve my problem:
<div class="tabs">
<!-- Tabs menu -->
<ul class="tab-links">
<li class="active"><a href="#features">Features</a></li>
FOREACH(CATEGORY){
<li><a href="#$CATEGORY.name">$CATEGORY.name</a></li>
}
</ul>
<!-- Content loading -->
<div class="tab-content">
<div id="features" class="tab active">
<p>$FEATURED.ITEMS.description</p> etc.
</div>
FOREACH(CATEGORY){
<div id="$CATEGORY.name" class="tab">
<p>$CATEGORY.ITEMS.description </p> etc.
</div>
}
</div>
</div>
The caps is the code I think I need. I tried copying code from other k2 phps that's seemed to fit but I got the messege that they were out of context, and then I looked up for snippets - I don't have good programming skills, as a begginer I am - but could find them.
If such a get function can be used inside this override I ask for a snippet.
And maybe there is another way of getting that filter function I desire?
Thanks in advance,
Pedro
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 2 months ago #141686
by Krikor Boghossian
Replied by Krikor Boghossian on topic Load category items in tabs (content module override)
Hello Pedro,
How did you come up with these variables "$CATEGORY.ITEMS.description " ? I would suggest that you use K2's default variables.
Furthermore you will need two loops (foreach) one for printing the category names and one for the items.
How did you come up with these variables "$CATEGORY.ITEMS.description " ? I would suggest that you use K2's default variables.
Furthermore you will need two loops (foreach) one for printing the category names and one for the items.
Please Log in or Create an account to join the conversation.
- Pedro Santos
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 2
10 years 2 months ago #141705
by Pedro Santos
I tried pasting some code from other k2 php files there but in it didn't work out.
The closest thing I've got was a messege saying that the ("this") selector was out of context.
I don't know how to deal it.
Thanks for the reply,
Pedro
Replied by Pedro Santos on topic Load category items in tabs (content module override)
Hello!Hello Pedro,
That's the point: I don't know how to call these, I don't even know the php syntax very well. That's just the pseudo-code for what I need.How did you come up with these variables "$CATEGORY.ITEMS.description " ?
I tried pasting some code from other k2 php files there but in it didn't work out.
Exactly! What are those? As I said, I am not able to use them right.I would suggest that you use K2's default variables.
The closest thing I've got was a messege saying that the ("this") selector was out of context.
I don't know how to deal it.
Indeed.Furthermore you will need two loops (foreach) one for printing the category names and one for the items.
Thanks for the reply,
Pedro
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 2 months ago #141720
by Krikor Boghossian
Replied by Krikor Boghossian on topic Load category items in tabs (content module override)
You can find the the default variables in the category_item.php file.
You will also find the needed loop in the category.php file.
Finally this should be done in your overrides instead of editing core files.
Read here how to do this: getk2.org/documentation/tutorials/174
You will also find the needed loop in the category.php file.
Finally this should be done in your overrides instead of editing core files.
Read here how to do this: getk2.org/documentation/tutorials/174
Please Log in or Create an account to join the conversation.