1.导航栏修改
(1)导航栏增加选中样式:
{if $r[catid]==$CATEGORYS[$parentid][catid]||$r[catid]==$catid} class="nav_bg" {/if}
(2)点击父栏目跳转到第一个子栏目:
{pc:content action="category" catid="0" num="7" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
{if count(subcat($r[catid])) > 0}
<!--获取第一个子类的 url 字段值-->
{php $zi_arr = explode(',',$r[arrchildid])}
{php $url = $CATEGORYS[$zi_arr[1]][url]}
<!--否则直接得到当前的url-->
{else}
{php $url = $r[url]}
{/if}
<li {if $r[catid]==$CATEGORYS[$CAT[parentid]][catid]||$r[catid]==$catid} class="nav_bg" {/if} ><a href="{$url}">{$r[catname]}</a></li>
{/loop}
{/pc}
2.获取栏目图片
{if $top_parentid}
{php $c_id=$top_parentid}
{else}
{php $c_id=$catid}
{/if}
{pc:content action="category" catid="$c_id" siteid="$siteid" order="listorder ASC" num="1"}
{loop $data $r}
{php echo $r[image]}
<img src="{thumb($r['image'],964,200)}" alt="{$r['catname']}" width="964" height="200" />
{/loop}
{/pc}
先判断是在当前栏目还是在父栏目子栏目,如果在子栏目则获取子栏目的父栏目图片,否则直接获取当前栏目图片
3.获取父栏目名称及链接地址
方法一:
{$CATEGORYS[$CAT[parentid]][catname]}
{$CATEGORYS[$CAT[parentid]][url]}
方法二:
{$CATEGORYS[$top_parentid][catname]}
{$CATEGORYS[$top_parentid][url]}
4.获取子栏目
{pc:content action="category" catid="$parentid" num="10" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<li {if $catid==$r[catid]}class="left_bg"{/if}><a href="{$r[url]}">{$r[catname]}</a></li>
{/loop}
{/pc}
5.获取当前位置及在列表页调用内容
{catpos($catid)}
列表页调用内容在PC标签加参数 moreinfo="1"
6.游客投稿到所有分类信息和栏目
1.modules/member/classes/foreground.class.php第10行
if(substr(ROUTE_A, 0, 7) != 'public_')) {
self::check_member();
}
改为:
if(substr(ROUTE_A, 0, 7) != 'public_' && (ROUTE_A!= 'publish'|| ROUTE_A!= 'info_publish')) {
self::check_member();
}
即可让游客投稿,(后台要设置游客有投稿状态)
2./phpcms/modules/member/content.php 行270左右
有关分类信息投稿:
public function info_publish() {
$memberinfo = $this->memberinfo;
$grouplist = getcache('grouplist');
$SEO['title'] = L('info_publish','','info');
//判断会员组是否允许投稿
在此下面加上:
if(!$memberinfo['groupid']) $memberinfo['groupid']=8;
有关其它模型投稿:
/phpcms/modules/member/content.php 行19左右也加入
if(!$memberinfo['groupid']) $memberinfo['groupid']=8;
7.修改单页模型实现单页添加描述(description)和缩略图(thumb)功能
首先在 _page新建字段 :
修改phpcms\modules\content\templates\content_page.tpl.php在第48行下添加如下代码:
<tr>
<th width="80"> <?php echo L('description');?> </th>
<td>
<textarea name="info[description]" id="description" style="width:98%;height:46px;" οnkeyup="strlen_verify(this, 'description_len', 255)"><?php echo $description;?></textarea>还可输入<b><span id="description_len">255</span></b>个字符</td>
</tr>
<tr>
<th width="80"> <?php echo L('thumb');?> </th>
<td><?php echo form::images('info[thumb]', 'thumb', $thumb, 'content');?></td>
</tr>
8.修改单页父栏目无法添加内容问题
打开phpcms\modules\content\content.php,搜索$strs2,定位到第二个。我们会看到这样的代码:
$strs2 = "<span class='folder'>\$catname</span>";
然后将这段代码修改为:
$strs2= "<span class='folder'>\$add_icon<a href='?m=content&c=content&a=\$type&menuid=".$_GET['menuid']."&catid=\$catid' target='right' οnclick='open_list(this)'>\$catname</a></span>";
打开content.php同文件夹下的create_html.php,可以搜索$r['disabled'],找到:
$r['disabled'] = $r['child'] ? 'disabled' : '';
然后将着一段代码注释掉或者删除。然后进后台更新缓存,可以编辑单页page父栏目了。
9.外部链接添加子栏目在管理内容中不能显示解决方法
将phpcms\modules\content\content.php 第481行
if($r['siteid']!=$this->siteid || ($r['type']==2 && $r['child']==0)) continue;
改为:
if($r['siteid']!=$this->siteid) continue;
10.修改后台登陆路径
在网站根目录创建一个文件夹,以后就要通过这个文件夹进入后台登录界面的,所以文件夹名就要取一个不易被人轻易猜到的名称。这里作为演示,我就取为my_web 好了。接着,在这个文件夹里新建一个文件index.php,内容为:
<?php
define('PHPCMS_PATH', realpath(dirname(__FILE__) . '/..') . '/');
include PHPCMS_PATH . '/phpcms/base.php';
// pc_base::creat_app();
$session_storage = 'session_' . pc_base :: load_config('system', 'session_storage');
pc_base :: load_sys_class($session_storage);
session_start();
$_SESSION['right_enter'] = 1;
unset($session_storage);
header('location:../index.php?m=admin');
第二步,,在 phpcms/modules/admin/ 文件夹里新建一个文件 MY_index.php,内容为:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class MY_index extends index {
public function __construct() {
if(empty($_SESSION['right_enter'])) {
header('location:./');exit;
}
parent::__construct();
}
public function public_logout() {
$_SESSION['right_enter'] = 0;
parent::public_logout();
}
}
以后就只能通过 my_web
/ 目录访问后台登录入口 了,如果直接使用 index.php?m=admin 访问的话,会直接跳转到网站首页,这样就阻止了对后台登录入口的直接访问了。
11.系统常量在phpcms\languages\ 下面,分中英文
12.当前位置:{catpos($catid)} {$title}
13.上一篇:<a href="{$previous_page[url]}">{str_cut($previous_page[title], 30)}</a>
下一篇:<a href="{$next_page[url]}">{str_cut($next_page[title], 30)}</a>