phpcms关键代码分享
文章目录
导航栏
导航栏增加选中样样式
1 | {if $r[catid]==$CATEGORYS[$parentid][catid]||$r[catid]==$catid} class="nav_bg" {/if} |
点击父栏目跳转到第一个子栏目
1 | {pc:content action="category" catid="0" num="7" siteid="$siteid" order="listorder ASC"} |
获取栏目图片
1 | {if $top_parentid} |
获取父栏目名称及链接地址
方法一:
1 | {$CATEGORYS[$CAT[parentid]][catname]} |
方法二:
1 | {$CATEGORYS[$top_parentid][catname]} |
获取子栏目
1 | {pc:content action="category" catid="$parentid" num="10" siteid="$siteid" order="listorder ASC"} |
获取当前位置及在列表页调用内容
1 | {catpos($catid)} |
列表页调用内容在PC标签加参数 moreinfo="1"
游客投稿到所有分类信息和栏目
modules/member/classes/foreground.class.php
第10行
1 | if(substr(ROUTE_A, 0, 7) != 'public_')) { |
改为:
1 | if(substr(ROUTE_A, 0, 7) != 'public_' && (ROUTE_A!= 'publish'|| ROUTE_A!= 'info_publish')) { |
即可让游客投稿,(后台要设置游客有投稿状态)
/phpcms/modules/member/content.php
270行左右,有关分类信息投稿:
1 | public function info_publish() { |
有关其它模型投稿在/phpcms/modules/member/content.php
行19左右也加入:
1 | if(!$memberinfo['groupid']) $memberinfo['groupid']=8; |
修改单页模型实现单页添加描述(description)和缩略图(thumb)功能
首先在page表新建字段thumb和description:
修改phpcms\modules\content\templates\content_page.tpl.php
在第48行下添加如下代码:
1 | <tr> |
修改单页父栏目无法添加内容问题
打开phpcms\modules\content\content.php
搜索$strs2
,定位到第二个。我们会看到这样的代码:
1 | $strs2 = "<span class='folder'>\$catname</span>"; |
然后将这段代码修改为:
1 | $strs2= "<span class='folder'>\$add_icon<a href='?m=content&c=content&a=\$type&menuid=".$_GET['menuid']."&catid=\$catid' target='right' onclick='open_list(this)'>\$catname</a></span>"; |
打开content.php
同文件夹下的create_html.php
,可以搜索$r['disabled']
,找到:
1 | $r['disabled'] = $r['child'] ? 'disabled' : ''; |
然后将这一段代码注释掉或者删除。
然后进后台更新缓存,可以编辑单页page父栏目了。
外部链接添加子栏目在管理内容中不能显示解决方法
将phpcms\modules\content\content.php
第481行
1 | if($r['siteid']!=$this->siteid || ($r['type']==2 && $r['child']==0)) continue; |
改为:
1 | if($r['siteid']!=$this->siteid) continue; |
修改后台登陆路径
在网站根目录创建一个文件夹,以后就要通过这个文件夹进入后台登录界面的,所以文件夹名就要取一个不易被人轻易猜到的名称。这里作为演示,我就取为myweb 好了。接着,在这个文件夹里新建一个文件index.php,内容为:
1 |
|
在 phpcms/modules/admin/
文件夹里新建一个文件 MY_index.php
,内容为:
1 |
|
以后就只能通过 my_web/
目录访问后台登录入口 了,如果直接使用 index.php?m=admin 访问的话,会直接跳转到网站首页,这样就阻止了对后台登录入口的直接访问了。
系统常量在phpcms\languages\
下面,分中英文
当前位置:
1 | {catpos($catid)} {$title} |
上一篇/下一篇
上一篇:
1 | <a href="{$previous_page[url]}">{str_cut($previous_page[title], 30)}</a> |
下一篇:
1 | <a href="{$next_page[url]}">{str_cut($next_page[title], 30)}</a> |