帝国cms 主导航条下拉菜单功能实现,模板功能扩展
微wx笑
2019-08-05【帝国CMS】
510
8
0关键字:
帝国cms
主导航条下拉菜单样式:实现步骤1、在公共模板变量》页面头部模板中使用以下标签来加载菜单项 [listshowclass]'0',13,0,0[/listshowclass]“13”对应的是标签模板》
主导航条下拉菜单样式:
实现步骤
1、在公共模板变量》页面头部模板中使用以下标签来加载菜单项
1 | [listshowclass]'0',13,0,0[/listshowclass] |
“13”对应的是标签模板》新建的一个模板
2、新建标签模板
页面模板内容(*)
1 2 3 4 5 6 7 8 9 10 | < li class = "[!--class-menu--]" >< a href = "[!--bclassurl--]" >[!--bclassname--]</ a > [!--empirenews.listtemp--] < ul class = "sub" > [!--empirenews.listtemp--] <!--list.var1--> [!--empirenews.listtemp--] </ ul > < span ></ span > [!--empirenews.listtemp--] </ li > |
列表内容模板(list.var) (*)
1 | < li >< a href = "[!--classurl--]" title = "[!--classname--]" >[!--classname--]</ a ></ li > |
3、模板功能扩展
由于有的功能无法实现,所以需要进行扩展
比如:[!--class-menu--] 这是一个根据有没有子菜单来替换为不同内容的标签;
比如:[!--empirenews.listtemp--] 标签可以出现四次,原本是只能出现两次;
相关文件:EmpireCMS_7.5_SC_UTF8/upload/e/class/t_functions.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | //栏目导航标签-循环 function sys_GetShowClassMore( $bclassid , $bcr , $tr , $bno , $bnum , $show =0){ global $empire , $class_r , $public_r , $dbtbpre ; //取得模板 $listtemp = $tr [temptext]; $subnews = $tr [subnews]; $listvar = $tr [listvar]; $rownum = $tr [rownum]; $formatdate = $tr [showdate]; if ( empty ( $rownum )) { $rownum =1;} //替换变量 $listtemp = str_replace ( "[!--bclassname--]" , $bcr [classname], $listtemp ); $bclassurl =sys_ReturnBqClassname( $bcr ,9); //栏目链接 $listtemp = str_replace ( "[!--bclassurl--]" , $bclassurl , $listtemp ); $listtemp = str_replace ( "[!--bclassid--]" , $bclassid , $listtemp ); $bclassimg = $bcr [classimg]? $bcr [classimg]: $public_r [newsurl]. "e/data/images/notimg.gif" ; //栏目图片 $listtemp = str_replace ( "[!--bclassimg--]" , $bclassimg , $listtemp ); $listtemp = str_replace ( "[!--bintro--]" , nl2br ( $bcr [intro]), $listtemp ); //栏目简介 $listtemp = str_replace ( "[!--bno--]" , $bno , $listtemp ); $listtemp = str_replace ( "[!--bnum--]" , $bnum , $listtemp ); //列表 $list_exp = "[!--empirenews.listtemp--]" ; $list_r = explode ( $list_exp , $listtemp ); $listtext = $list_r [1]; $listtext2 = $list_r [1]; if ( count ( $list_r )==5) { $listtext = $list_r [2]; $listtext2 = $list_r [2]; } $no =1; $changerow =1; $sql = $empire ->query( "select classid,classname,islast,sonclass,tbname,intro,classimg,infos from {$dbtbpre}enewsclass where bclassid='$bclassid' and showclass=0 order by myorder,classid" ); while ( $r = $empire ->fetch( $sql )) { //显示栏目数据数 if ( $show ) { $num =ReturnClassInfoNum( $r ); } //替换列表变量 $repvar =ReplaceShowClassVars( $no , $listvar , $r , $num ,0, $subnews ); $listtext = str_replace ( "<!--list.var" . $changerow . "-->" , $repvar , $listtext ); $changerow +=1; //超过行数 if ( $changerow > $rownum ) { $changerow =1; $string .= $listtext ; $listtext = $listtext2 ; } $no ++; } //多余数据 if ( $changerow <= $rownum && $listtext <> $listtext2 ) { $string .= $listtext ; } if ( count ( $list_r )==5) { if ( $no ==1){ $string = $list_r [0]. $list_r [4]; // 20190606 由于不包含子栏目,所以这里不加 $string $string = str_replace ( "[!--class-menu--]" , "" , $string ); } else { $string = $list_r [0]. $list_r [1]. $string . $list_r [3]. $list_r [4]; $string = str_replace ( "[!--class-menu--]" , "menu" , $string ); } } else { $string = $list_r [0]. $string . $list_r [2]; } echo $string ; } |
注意:如果你想修改系统原来的模板,不是很熟悉的情况最好先做好备份;其实我觉得最好还是新建一个,把它的内容复制过来改,不然的一旦改的次数多了就找不回以前的了。
本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/EmpireCMS/2019-08-05/87.html