2013-08-01
展开全部
public function run()
{
//$list = array();
$classify = Clasify::model()->cache()->findAll();
$shop = Shop::model()->cache()->findAll(array(
'condition'=>'prices = 1 AND status = 1',
'order'=>'grounding_time DESC',
'limit'=>5));
$this->render('classify',array('classify'=>$classify,'list'=>$list,'shop'=>$shop));
}
$classify = Clasify::model()->cache()->findAll();YII框架写的一个,从数据库中找你的菜单, foreach ($classify as $classifys)
{
$list[$classifys->son_id][$classifys->classify_id]=$classifys->classify_name;
}组合成数组
$this->render('classify',array('classify'=>$classify,'list'=>$list,'shop'=>$shop));渲染到视图中,
视图代码如下:
<?php if (isset($list)):?>
<?php foreach ($list[0] as $i=>$lists):?>
<dt>
<a href="<?php echo $this->controller->createUrl('shopping/index',array('cfyid'=>$i))?>" title="<?php echo $lists?>"><?php echo $lists?></a>
</dt>
<?php foreach ($list[$i] as $j=>$lists):?>
<dd>
<a href="<?php echo $this->controller->createUrl('shopping/index',array('sonid'=>$j))?>" title="<?php echo $lists?>"><?php echo $lists?></a>
</dd>
<?php endforeach;?>
<?php endforeach;?>
</dt>
<?php endif;?>
你看得懂的!
{
//$list = array();
$classify = Clasify::model()->cache()->findAll();
$shop = Shop::model()->cache()->findAll(array(
'condition'=>'prices = 1 AND status = 1',
'order'=>'grounding_time DESC',
'limit'=>5));
$this->render('classify',array('classify'=>$classify,'list'=>$list,'shop'=>$shop));
}
$classify = Clasify::model()->cache()->findAll();YII框架写的一个,从数据库中找你的菜单, foreach ($classify as $classifys)
{
$list[$classifys->son_id][$classifys->classify_id]=$classifys->classify_name;
}组合成数组
$this->render('classify',array('classify'=>$classify,'list'=>$list,'shop'=>$shop));渲染到视图中,
视图代码如下:
<?php if (isset($list)):?>
<?php foreach ($list[0] as $i=>$lists):?>
<dt>
<a href="<?php echo $this->controller->createUrl('shopping/index',array('cfyid'=>$i))?>" title="<?php echo $lists?>"><?php echo $lists?></a>
</dt>
<?php foreach ($list[$i] as $j=>$lists):?>
<dd>
<a href="<?php echo $this->controller->createUrl('shopping/index',array('sonid'=>$j))?>" title="<?php echo $lists?>"><?php echo $lists?></a>
</dd>
<?php endforeach;?>
<?php endforeach;?>
</dt>
<?php endif;?>
你看得懂的!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询