Keyword

Load category items in tabs (content module override)

  • Pedro Santos
  • Pedro Santos's Avatar Topic Author
  • Offline
  • New Member
More
9 years 3 weeks ago #141666 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:
<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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 weeks 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.

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

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

  • Pedro Santos
  • Pedro Santos's Avatar Topic Author
  • Offline
  • New Member
More
9 years 3 weeks ago #141705 by Pedro Santos

Hello Pedro,

Hello!

How did you come up with these variables "$CATEGORY.ITEMS.description " ?

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.
I tried pasting some code from other k2 php files there but in it didn't work out.

I would suggest that you use K2's default variables.

Exactly! What are those? As I said, I am not able to use them right.
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.

Furthermore you will need two loops (foreach) one for printing the category names and one for the items.

Indeed.

Thanks for the reply,
Pedro

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 weeks 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

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