繁体   English   中英

显示结果的类别在PHP?

[英]Display results in terms of category in PHP?

朋友们。 我正在构建一个开源电子商务模板!

下面的代码列出了商店列表的前3个结果。

<?php 
  if(count($this->store_list)>0){
            $number_output = 0;
foreach($this->store_list as $store){
$number_output++;
if($number_output > 3) break;
        ?>

   <div id="menu">  
  <span class="cons_title fl"><a href="<?php echo PATH.'store/'.$store->title_url.'.html'; ?>"><h2><?php echo ucfirst($store->name); ?></h2></a></span>

             <div class="cons_bot fl clr">

                  <ul>
                    <li><h4><?php echo $store->address1; ?>,</h4></li>
                    <li><h4><?php echo $store->address2; ?>,</h4></li>
                    <li><h4><?php echo $store->area_name; ?>,</h4></li>
                    <li><h4><?php echo ucfirst($store->city_name); ?>,</h4></li>
                    <li><h4><?php echo $store->pin; ?></h4></li>
                    <li><h4>PH:</h4><h4><?php echo $store->phone; ?></h4></li>
                  </ul>
                  </div>

这是显示类别明智的其他代码!

 <?php if(count($this->category_list)>0){
            foreach($this->category_list as $category){ ?>
      <a href="<?php echo PATH;?>store-listing/cat/<?php echo $category->category_url; ?>.html" class="<?php if($category->category_url == url::title($cat_active)){ echo 'active';}?>"><?php echo ucfirst($category->category_name); ?></a>

我可以将下面的代码集成到上面的代码中,它仅向我显示单个类别的结果。 你能指导我吗

不清楚哪个对象是上级商店或类别

最好将类别限制为1,例如

/*possibly a parent loop to process everything over this category - if store is super*/
<?php if(count($this->category_list)>0){
         $categoryLimit = 1;
            foreach($this->category_list as $category){
                 if($categoryLimit == 1){ ?>
      <a href="<?php echo PATH;?>store-listing/cat/<?php echo $category->category_url; ?>.html" class="<?php if($category->category_url == url::title($cat_active)){ echo 'active';}?>"><?php echo ucfirst($category->category_name); ?></a>

......
<? 
  /*possibly a sub loop to process everything within this category - if store is child to category*/
                    $categoryLimit++;
                } ## end if ?>

希望这个帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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