Keyword

Skip items or set offset to mod_k2_content

  • Carlos
  • Carlos's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 4 months ago #113557 by Carlos
Hi.

How can I skip items on mod_k2_content?

I need to have 2 instances of mod_k2_content on a news site homepage showing recent items, but I need the 2nd one not to show the same items of the first one.

So, in the 1st one I show 2 items, the 2nd one needs to skip those 2.

Thanks, any help will be much appreciated.

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

  • Carlos
  • Carlos's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 4 months ago #113558 by Carlos
I found a way here:

code.google.com/p/getk2/issues/detail?id=162

but requires to edit files outside of my template. Any better solutions?

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

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 4 months ago #113559 by Yiota
There are two ways you can approach this.

1st:
You could simply make the first two items Featured and the 1st module assign it to show only the Featured and for the 2nd one assign it to not show the featured.

2nd:
You can have different instances of the template to achieve that.
If you create a template override of the module you can have 2 different templates. Let's say the Default and the Skipped. All you have to do is copy the default.php located in modules/mod_k2_content/tmpl/Default/ to templates/YOUR_TEMPLATE/html/mod_k2_content/Default. Then copy the Default folder of your template and create the Skipped folder with the same content file.

The Default should contain the default.php with no modifications.
The Skipped should contain the default.php with the modifications.
Right after the foreach statement you can have a check.
If the ($key+1<=2) echo ''; else continue with the default.

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

More
8 years 6 months ago #151843 by Marina Deotti
Replied by Marina Deotti on topic Skip items or set offset to mod_k2_content
I tried the above answer and it didn't work. Plus the link provided from the author is broken.

Is there a recent alternative for latest K2?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 6 months ago #151845 by Krikor Boghossian
Replied by Krikor Boghossian on topic Skip items or set offset to mod_k2_content
Yes, you can try Yiota's suggestion with editing the $key.

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

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

More
8 years 6 months ago #151860 by Marina Deotti
Replied by Marina Deotti on topic Skip items or set offset to mod_k2_content
I changed line 23 to with no effect:
<li class="<?php echo ($key%2) ? "odd" : "even"; if(count($items)==$key+1<=2) echo ' lastItem'; ?>">

What am I missing?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 6 months ago - 8 years 6 months ago #151881 by Krikor Boghossian
Replied by Krikor Boghossian on topic Skip items or set offset to mod_k2_content
it should be directly under the foreach statement
  <?php foreach ($items as $key=>$item):	
     if($key+1<=2){ 
    	echo ''; }
    else { :?> 
    <li class="<?php echo ($key%2) ? "odd" : "even"; if(count($items)==$key+1) echo ' lastItem'; ?>">

Don not forget to close the else statement at the end of the item with:
<?php } ?>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 8 years 6 months ago by Krikor Boghossian.

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


Powered by Kunena Forum