Php 标签中的错误
我正在尝试执行以下代码 但是在ul中显示错误 语法错误: 预期:exit、if、identifier、variable、echo、do、while、for、foreach、endforeach、declare、switch、break、continue、function、return、try、throw、use、global、unset、isset、empty、class、interface、array、{、include、include_once、eval、require、require_once、print、“;”、+、-、-、!、+、-、@、new、static、abstract、final、(,$ 我的代码是Php 标签中的错误,php,magento,Php,Magento,我正在尝试执行以下代码 但是在ul中显示错误 语法错误: 预期:exit、if、identifier、variable、echo、do、while、for、foreach、endforeach、declare、switch、break、continue、function、return、try、throw、use、global、unset、isset、empty、class、interface、array、{、include、include_once、eval、require、require_on
<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>
航行
请帮助我的任何人可能是:
<?php endforeach ;?>
你错过了最后三行的
;
。我想你还有一个多余的
<?php end if ?>
在
之后
请检查……这是代码
<?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 ?>
航行
//(此处删除了一个endif)
我不能100%确定您想做什么,因为$cnt始终等于0,所以您不需要检查$cnt
航行
为什么要在每一行上打开和关闭php标记?您忘记了::我认为有3条if语句,只有2条if关闭语句。
<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>