【phpcms-v9】無子欄目的欄目如何既能顯示頻道頁又能顯示列表頁.
第一:默認情況下,如果當前欄目沒有子欄目,則點擊當前欄目時,默認顯示的是后臺設定的列表頁而不是頻道頁,那么如何在當前欄目下同時顯示頻道頁和列表頁呢?如當點擊當前欄目時,首先顯示的是當前欄目的頻道頁,再次點擊【更多精彩內容。。?!繒r,顯示的是當前欄目的列表頁.
第二:需要修改index.php控制器中lists方法:
- if($type==0) { //0-內部欄目 1-單網頁 2-外部鏈接
- $arrparentid = explode(',', $arrparentid); //當前欄目所有的父欄目組成的父欄目id數組
- $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid;//當前欄目的頂級欄目id
- //此行代碼為weiyanhui添加,主要用來控制當前欄目下沒有子欄目時,顯示當前欄目設置的列表模板
- if(isset($_GET['y']) && $_GET['y'] == 1){//用來控制顯示當前欄目的列表頁【當前欄目無子欄目】
- $template=$template_list;//顯示列表頁模板,控制當前欄目顯示列表頁
- }else{
- if($top_parentid == 10){//控制當前欄目顯示頻道頁模板
- $template = $template;//顯示頻道頁模板
- }else{//正常情況
- $template = $child ? $template : $template_list;//$child,是否有子欄目: 1-有 0-沒有
- }
- //$template = $child ? $template : $template_list;//$child,是否有子欄目: 1-有 0-沒有
- }
- //$template = $child ? $template : $template_list;//此行為系統自帶代碼,暫時被weiyanhui注釋
- //$arrparentid = explode(',', $arrparentid); //當前欄目所有的父欄目組成的父欄目id數組
- //$top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid;//當前欄目的頂級欄目id
- $array_child = array(); //當前欄目下一級欄目的id組成的數組
- $self_array = explode(',', $arrchildid); //當前欄目的所有子欄目組成的id數組,包含當前欄目id自身
- //獲取一級欄目ids //開源軟件:Vevb.com
- foreach ($self_array as $arr) {
- if($arr!=$catid && $CATEGORYS[$arr][parentid]==$catid) {
- $array_child[] = $arr;//當前欄目下一級欄目id組成的數組,不包含當前欄目id
- }
- }。。。}
新聞熱點
疑難解答