Your Cart is currently empty!
Product update
Coupon
add
Coupon code invalid! Please re-enter!
AJAX loader
You are here: HomeForum
Welcome, Guest

[SOLVED]help with module k2-content
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: [SOLVED]help with module k2-content

[SOLVED]help with module k2-content 7 years, 10 months ago #31273

hi
module k2-content
file : default.php
how can i add more foreach classes in this code :
<?php foreach ($items as $key=>$item): ?>
<li class="<?php echo ($key%2) ? "odd" : "even" ; if(count($items)==$key+1) echo ' lastItem'; ?>">

for now it is 2 classes "odd" and "even" ,
but i want to add more 2 or 3 classes .

thanks
The topic has been locked.
The following user(s) said Thank You: anhqn

Re: help with module k2-content 7 years, 10 months ago #31287

Dear sofian10

You can add your class like:

<?php foreach ($items as $key=>$item): ?>
<li class= "yourclass1 yourclass2 <?php echo ($key%2) ? "odd" : "even" ; if(count($items)==$key+1) echo ' lastItem'; ?>">

Thanks
The topic has been locked.

Re: help with module k2-content 7 years, 10 months ago #31288

no no please understand me :
i dont want add class to all the lists ..
i want to add class for the foreach code , this mean :
currently results in :
<ul>
<li class="even">
<li class="odd">
<li class="even lastItem">
</ul>

What I would like to do is adding more classes so the result would be something like this:
<ul>
<li class="even">
<li class="odd">
<li class="alt">
<li class="mart">
<li class="tara">
<li class="even lastItem"></ul>

in other words :
how to add them to this code :
<?php echo ($key%2) ? "odd" : "even" ;

very thanks
The topic has been locked.

Re: help with module k2-content 7 years, 10 months ago #31293

Dear sofian10

You can add your class like:

<?php foreach ($items as $key=>$item): ?>
<li class= "yourclass1 yourclass2 <?php echo ($key%2) ? "odd" : "even" ; if(count($items)==$key+1) echo ' lastItem'; if($key==2) echo ' alt'; if($key==3) echo ' mart'; if($key==4) echo ' tara' ?>">

Thanks
The topic has been locked.

Re: help with module k2-content 7 years, 10 months ago #31294

<?php foreach ($items as $key=>$item): ?>
<li class= "<?php echo ($key%2) ? "odd" : "even" ; if(count($items)==$key+1) echo ' lastItem'; if($key==2) echo ' alt'; if($key==3) echo ' mart'; if($key==4) echo ' tara' ?>">

this code result now is in :
<li class=" even">
<li class=" odd">
<li class=" even alt">
<li class=" odd mart">
<li class=" even tara">
<li class="odd">
<li class=" even lastItem">

but i want it like this :
<li class="even">
<li class="odd">
<li class="alt">
<li class="mart">
<li class="tara">

please how to edit this code just :
<?php echo ($key%2) ? "odd" : "even" ;

itryed this :
<?php echo ($key%2) ? "odd" : "even" : "alt" : "mart" : "tara";
but not works for me .

thank you
The topic has been locked.

Re: help with module k2-content 7 years, 10 months ago #31296

Dear sofian10

You can use our code before that, so add the css for your class to override our css of the class old, even.

<?php foreach ($items as $key=>$item): ?>
<li class= "yourclass1 yourclass2 <?php echo ($key%2) ? "odd" : "even" ; if(count($items)==$key+1) echo ' lastItem'; if($key==2) echo ' alt'; if($key==3) echo ' mart'; if($key==4) echo ' tara' ?>">

Thanks
The topic has been locked.
  • Page:
  • 1
  • 2
Time to create page: 0.24 seconds

Notification

Please find your issue via Suggested Posts before submitting your question. We have solved the most of issues and maybe your issue was solved before.

Latest My Topics

No posts to display.

Love all our templates?

Join our membership clubs starting at $49 only for access to all of our templates

Join Now
Home Pricing
Your Cart is currently empty!
Product update
Coupon
add
Coupon code invalid! Please re-enter!
AJAX loader
SearchSupport
Magento Themes Magento Extensions Free Magento Extensions Prestashop Themes Prestashop Modules Magento 2 Themes