Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7875791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:03:34+00:00 2026-06-03T03:03:34+00:00

I am trying to modify the way a category list is drawn on the

  • 0

I am trying to modify the way a category list is drawn on the front end of a Magento website (simple idea). I have a list of categories that I want to seperate and use with jquery accordiation, so for EG. I want a header “2010 and older” under which sit categories with IDs 1 to 10. Then I want a heading “2011” under which live categories with IDs 11 to 20.

The default category code below just loops through the IDs and echos out the category list in a <UL> – but I want to customise the <UL>:

<?php $collection = $this->_getCollection(); ?>
<?php if (count($collection) > 0) : ?>



    <?php foreach ($collection as $_category ) : ?>            

                <li>
                    <a href="<?php echo $this->getUrl('gallery/category/view/', array('id' => $_category->getId())); ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a>
                </li>

    <?php endforeach ?>

<?php endif; ?>

I can’t see the wood for the trees! – I figured to pull the IDs into an array and draw the new structure based on IF statements, but no luck in building the array.

Can anyone see a quick way that I can break the loop to say, if IDs are 1 to 10 then list in <li class="2010">, then move on for IDs 11 to 20 in <li class="2011"> for eg.?

Many Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:03:36+00:00Added an answer on June 3, 2026 at 3:03 am

    Try to check for category id’s you don’t want to display and use continue; to get the next:

    <?php foreach ($collection as $_category ): ?>
    <?php if ($_category->getId() == 10) { continue; } ?>
        <li>
            <a href="<?php echo $this->getUrl('igallery/category/view/', array('id' => $_category->getId())); ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a>
        </li>
    <?php endforeach ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shopping cart script that I am trying to modify to support
I have a ListBoxItem Style that I am trying to modify so that it
I have a Rails engine (someone else's gem) that I am trying to modify
I have a javascript file from a wordpress plugin that I'm trying to modify.
I have an Accordian that Im trying to modify because the Accordian is too
I'm trying to modify the way FOSUSerBundle validates the username/email when the user registers,
I am trying to modify the script below to click a button that looks
I'm trying to modify items in a list using a for loop, but I
I'm trying to modify an object on a click. Here's what I have. <form>
I'm trying to modify a serial program that reads from a database, and writes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.