inushome 发表于 2015-8-24 16:33:27

php section

  介绍php section使用
  {section name = name loop = $varName[, start = $start, step = $step, max = $max, show = true]}

name: section的名称,不用加$
$loop: 要循环的变量,在程序中要使用assign对这个变量进行操作。
$start: 开始循环的下标,循环下标默认由0开始
$step: 每次循环时下标的增数
$max: 最大循环下标
  $show: boolean类型,决定是否对这个块进行显示,默认为true
  
  
  例子
  配置文件
  

<?php
$attach_sort['id']=0;
$attach_sort['name']="全部";
$attach_sort['num']=30;
$attach_sort['id']=1;
$attach_sort['name']="用户通讯";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="文献综述";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="认证认可";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="仪器资料";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="实验方法";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="分析方法";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="标准";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="会议论文";
$attach_sort['num']=30;
$attach_sort['id']=2;
$attach_sort['name']="课件讲义";
$attach_sort['num']=30;


$smarty->assign("attach_sort", $attach_sort);      //分类


?>
  html 模板




{section name=sortloop=$attach_sort}
<a href="list.php?sort={$attach_sort.id}{if $keyword}&keyword={$keyword}{/if}" {if $sort=={$attach_sort.id}}class="fox"{/if}>{$attach_sort.name}</a>
{/section}
  
页: [1]
查看完整版本: php section