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?

2 Answers 2

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  ?>">
...
1
  • Always glad to help :)
    – JeffT
    Commented Jun 23, 2015 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 and acknowledge you have read our privacy policy.

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