-1

以下のようなコードを実行しようとしています

しかし、 ulにエラーが表示 されます

構文エラー: 予想: exit、if、識別子、変数、エコー、do、while、for、foreach、endforeach、declare、switch、break、continue、function、return、try、throw、use、global、unset、isset、empty 、クラス、インターフェイス、配列、{、include、include_once、eval、require、require_once、print、';'、+、-、!、~、++、-、@、new、static、abstract、final、( 、$

私のコードは

<div class="footer">
    <div class="footer_top">
        <?php $helper = $this->helper('catalog/category') ?>
        <?php $counts=$helper->getStoreCategories()->count(); ?>
        <?php $cnt=0; $row=0; foreach ($helper->getStoreCategories() as $_category): ?>
             <?php if(($i==0)&&($cnt<$count)) ?>
                <?php $row++; ?>
                    <div class="footer_part">
                        <?php if($row==1):$no=4; ?>
                            <h2>Navigation</h2>
                        <?php else : $no=3; ?>
                            <h2></h2>
                        <?php endif ?>
                     <ul>
            <?php endif; ?>
            <li><a href="<?php echo Mage::getModel('catalog/category')->setData($_category->getData())->getUrl(); ?>" title="<?php echo $_category->getName() ?>"><?php echo $_category->getName() ?></a></li>
                <?php  $i++; if($i==$no):?>
                    <?php $i=0;?>
                    </ul>
                </div>
               <?php endif; ?>
       <?php endforeach ?>

       </div>
</div>

誰でも私を助けてください

4

3 に答える 3

1

$cnt は常に 0 になるため、何をしようとしているのか 100% わかりません。$cnt<$count配列/オブジェクトの数が 0 より大きい場合にのみ foreach がループするため、実際に確認する必要はありません。

<div class="footer">
    <div class="footer_top">
        <?php $helper = Mage::helper('catalog/category'); ?>
        <?php //$counts = $helper->getStoreCategories()->count(); ?>

        <?php $cnt = 0;
        $row = 0;
        $i == 0;
        foreach ($helper->getStoreCategories() as $_category): ?>
             <?php if (($i == 0)):  $row++; ?>
                <div class="footer_part">
                    <?php if ($row == 1): $no = 4; ?>
                        <h2>Navigation</h2>
                    <?php else : $no = 3; ?>
                        <h2></h2>
                    <?php endif; ?>
                    <ul>
             <?php endif; ?>
                        <li><a href="<?php echo $_category->getUrl(); ?>" title="<?php echo $_category->getName() ?>"><?php echo $_category->getName() ?></a></li>
            <?php $i++; ?>  
            <?php if ($i == $no):  $i = 0; ?>
                    </ul>
                </div>
           <?php endif; ?>
       <?php endforeach ?>

    </div>
</div>
于 2012-11-12T12:09:52.123 に答える
0

多分 :

<?php endforeach ;?>

;最後から 3 番目の行を見逃しました。

于 2012-11-12T06:29:24.603 に答える
0

私はあなたが余分を持っていると思います

<?php end if ?>  

<ul>

確認してください...ここにコードがあります....

 <?php $helper = $this->helper('catalog/category') ?>
    <?php $counts=$helper->getStoreCategories()->count(); ?>
    <?php $cnt=0; $row=0; foreach ($helper->getStoreCategories() as $_category): ?>
         <?php if(($i==0)&&($cnt<$count)) ?>
            <?php $row++; ?>
                <div class="footer_part">
                    <?php if($row==1):$no=4; ?>
                        <h2>Navigation</h2>
                    <?php else : $no=3; ?>
                        <h2></h2>
                    <?php endif ?>
                 <ul>
        //(deleted one endif here)
        <li><a href="<?php echo Mage::getModel('catalog/category')->setData($_category->getData())->getUrl(); ?>" title="<?php echo $_category->getName() ?>"><?php echo $_category->getName() ?></a></li>
            <?php  $i++; if($i==$no):?>
                <?php $i=0;?>
                </ul>
            </div>
           <?php endif; ?>
   <?php endforeach ?>
于 2012-11-12T06:30:39.897 に答える