1

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) : ?>
<li>

How can I add a class to the li?

3

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  ?>">
...
  • Always glad to help :) – JeffT Jun 23 '15 at 9:50
1

Try this:

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

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.