简体   繁体   中英

Shopp: How to sort categories by slug

I need to display categories sorted by slug. can anyone help me?

This is my code so far:

 <?php if(shopp('catalog','has-categories')): ?>
 <ul class="products">
    <li class="row">
        <ul>
        <?php while(shopp('catalog','categories')): ?>
            <li class="product">
                <div class="frame">
                    <a href="<?php shopp('category','url'); ?>"><?php shopp('category','coverimage','setting=thumbnails'); ?></a>
                    <a href="<?php shopp('category','url'); ?>" class="category-link"><h3><?php shopp('category','name'); ?></h3></a>
                </div>
            </li>
        <?php endwhile; ?>
        </ul>
    </li>
  </ul>
<?php endif; ?>

Another approach would be something like

$categories = shopp('storefront.category-list','load=true&orderby=slug');
foreach ($categories as $category){
   // the category markup code goes here
}

You'll have to add some li and ul tags

if you just need a linked list use

shopp('storefront.category-list','orderby=slug');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM