Using the mod_articles_categories module. I am writing an override but want to add a class to each li within foreach().

I have the following code:

foreach ($list as $item) : ?>

How can I add a class to the li?


If you have numbered classes, (someclass_0, someclass_1 etc) you can use something like this:

foreach ($list as $key =>$item) : ?>
    <li class="someclass_<?php echo $key  ?>">
| improve this answer | |
  • Always glad to help :) – JeffT Jun 23 '15 at 9:50

Try this:

foreach ($list as $item=>$key) : ?>
<li class="sample_<?php echo $key; ?>"> </li>
<?php end foreach ?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.