crehp中类似于相关和成果页要分好几个,其实只要对controller中传入一个值即可解决
也就是说要在各个网页基本上一致时,通过URL传一个值就可以实现一个html实现多个页
网址用http://localhost:8080/crehp/index.php?s=/Home/Nav/other/id/57.html
这样就可以传入一个id值
public function other($id){
$row=10;
switch ($id) {
case '57':
$class11="light-active";
break;
case '58':
$class12="light-active";
break;
case '59':
$class13="light-active";
break;
default:
break;
}
$cateinfo = D('Category')->info($id);
$Document = D('Document');
/* 模板赋值并渲染模板 */
$this->assign('cateinfo', $cateinfo);
$this->assign('row',$row);
$this->assign('class11',$class11);
$this->assign('class12',$class12);
$this->assign('class13',$class13);
$this->display();
}
URL参数控制页面展示
本文介绍了一种通过URL传递参数来控制不同页面显示的方法。利用这种方法可以减少代码重复,提高开发效率。具体实现上,通过PHP控制器接收URL中的id参数,并根据不同的id值设置相应的页面样式和内容。





