关于yourphp内容管理系统开启伪静态之后volist调用排序
2016-12-10 01:35
375 查看
写这篇博客主要的目的是让大家开发起来少浪费一些时间在小问题上。
今日用yourphp内容管理系统做二次开发的时候遇到一个问题,就是网站开启伪静态之后,后台设置的排序无效,于是百度了一下,发现有很多人回答了,修改某某文件222行为->(listorder desc)然而并没有什么卵用, 伪静态根本不执行这个文件,于是各种翻墙加交流群,请教大神都未果,是的,使用YP:list 可以设置排序,但是无法使用分页。
列表页模版提供的是:
<div class="list pic_list"><ul class="pic">
<volist name="list" id="vo" key="k" order="listorder desc">
<li><span><a href="{$vo.url}"><img src="{$vo.thumb}"></a></span><a href="{$vo.url}" target="_blank">{$vo.title}{$vo.listorder}</a></li>
</volist>
</ul></div>
<div id="pages" class="page">{$pages}</div>
因此我只要找到list这个数据的由来就解决问题了,这貌似是yourphp2.*版本遗留下来的bug,我花了一天的时间查资料,请教大神,都没有解决,突然灵光一现,我应该根据代码的执行过程来寻找数据源,于是我根据后台网站更新里面的更新列表页的button,找到了触发生成静态页的函数,接下来就是顺藤摸瓜,哈哈
找到Lib/Action/AdminbaseAction.class.php的create_list()函数,将$list = $dao->field($field)->where($where)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();修改为$list = $dao->field($field)->where($where)->order('listorder desc')->limit($page->firstRow
. ',' . $page->listRows)->select();就大功告成了,对了要记得更新列表页....
public function create_list($catid,$p=1,$count=0)
{
C('DEFAULT_THEME_NAME',$this->sysConfig['DEFAULT_THEME']);
C('HTML_FILE_SUFFIX',$this->sysConfig['HTML_FILE_SUFFIX']);
C('TMPL_FILE_NAME',str_replace('Admin/Default','Home/'.$this->sysConfig['DEFAULT_THEME'],C('TMPL_FILE_NAME')));
if(APP_LANG){
C('TMPL_CACHFILE_SUFFIX','_'.LANG_NAME.'.php');
$lang = C('URL_LANG')!=LANG_NAME ? $lang = LANG_NAME.'/' : '';
L(include LANG_PATH.LANG_NAME.'/common.php');
$T = F('config_'.LANG_NAME,'', './Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/');
}else{
L(include LANG_PATH.$this->sysConfig['DEFAULT_LANG'].'/common.php');
$T = F('config_'.$this->sysConfig['DEFAULT_LANG'],'', './Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/');
}
$this->assign('T',$T);
foreach((array)$this->module as $r){
if($r['issearch'])$search_module[$r['name']] = L($r['name']);
}
$this->assign('search_module',$search_module);
$this->assign ( 'form',new Form());
$this->assign($this->Config);
$this->assign('Categorys',$this->categorys);
$this->assign('Module',$this->module);
$this->assign('Type',$this->Type);
$catid =intval($catid);
if(empty($catid)) $this->success (L('do_empty'));
$cat = $this->categorys[$catid];
$this->assign('catid',$catid);
if($cat['type']) return;
if(empty($cat['ishtml'])) return;
unset($cat['id']);
$this->assign($cat);
$cat['id']=$catid;
$bcid = explode(",",$cat['arrparentid']);
$bcid = $bcid[1];
if($bcid == '') $bcid=intval($catid);
$this->assign('bcid',$bcid);
$urlrule = geturl($cat,'',$this->Urlrule);
$url= ($p > 1 ) ? $urlrule[1] : $urlrule[0];
$url = str_replace('{$page}', $p, $url);
if(strstr($url,C('HTML_FILE_SUFFIX'))){
$filename = basename($url,C('HTML_FILE_SUFFIX'));
$dir = dirname($url).'/';
}else{
$filename = 'index';
$dir= $url;
}
$dir = substr($dir,strlen(__ROOT__.'/'));
if(empty($module))$module=$cat['module'];
$this->assign('module_name',$module);
$this->assign ( 'fields', F($cat['moduleid'].'_Field') );
$this->assign ( 'form',new Form());
if($cat['moduleid']==1){
$cat['listtype']=2;
$module = $cat['module'];
$dao= M($module);
$data = $dao->find($catid);
$seo_title = $cat['title'] ? $cat['title'] : $data['title'];
$this->assign ('seo_title',$seo_title);
$this->assign ('seo_keywords',$data['keywords']);
$this->assign ('seo_description',$data['description']);
$template = $cat['template_list']? $cat['template_list'] : 'index';
//手动分页
$CONTENT_POS = strpos($data['content'], '[page]');
if($CONTENT_POS !== false){
$contents = array_filter(explode('[page]',$data['content']));
$pagenumber = count($contents);
for($i=1; $i<=$pagenumber; $i++) {
$pageurls[$i] = str_replace('{$page}',$i,$urlrule);
}
//生成分页
foreach ($pageurls as $p=>$urls) {
$pages = content_pages($pagenumber,$p, $pageurls);
$this->assign ('pages',$pages);
$data['content'] = $contents[$p-1];
$this->assign ($data);
if($p > 1)$filename = basename($pageurls[$p]['1'],C('HTML_FILE_SUFFIX'));
//$this->buildHtml($filename,$dir,'Home/'.$template);
$r=$this->buildHtml($filename,$dir,'./Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/Page_'.$template.C('TMPL_TEMPLATE_SUFFIX'));
}
}else{
$this->assign($data);
//$r=$this->buildHtml($filename,$dir,'Home/'.$template);
$r=$this->buildHtml($filename,$dir,'./Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/Page_'.$template.C('TMPL_TEMPLATE_SUFFIX'));
}
}else{
$seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
$this->assign ('seo_title',$seo_title);
$this->assign ('seo_keywords',$cat['keywords']);
$this->assign ('seo_description',$cat['description']);
if($cat['listtype']==1){
$template_r = 'index';
}else{
$where = " status=1 ";
if($cat['child']){
$where .= " and catid in(".$cat['arrchildid'].")";
}else{
$where .= " and catid=".$catid;
}
$module = $cat['module'];
$dao= M($module);
if(empty($count))$count = $dao->where($where)->count();
if($count){
import ( "@.ORG.Page" );
$listRows = !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');
$page = new Page ( $count, $listRows ,$p );
$page->urlrule = $urlrule;
$pages = $page->show();
$field = $this->module[$this->mod[$module]]['listfields'];
$field = $field ? $field : 'id,catid,userid,url,username,title,title_style,keywords,description,thumb,createtime,hits';
$list = $dao->field($field)->where($where)->order('listorder desc')->limit($page->firstRow . ',' . $page->listRows)->select();
$this->assign('pages',$pages);
$this->assign('list',$list);
}
$template_r = 'list';
}
$template = $cat['template_list']? $cat['template_list'] : $template_r;
$r=$this->buildHtml($filename,$dir,'./Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/'.$cat['module'].'_'.$template.C('TMPL_TEMPLATE_SUFFIX'));
}
if($r) return true;
}
博主第一次写博客,可能写得很啰嗦,主要是太紧张,担心写不好,大家看不懂,写这篇博客主要的目的是让大家开发起来少浪费一些时间在小问题上(长沙臭豆腐)
今日用yourphp内容管理系统做二次开发的时候遇到一个问题,就是网站开启伪静态之后,后台设置的排序无效,于是百度了一下,发现有很多人回答了,修改某某文件222行为->(listorder desc)然而并没有什么卵用, 伪静态根本不执行这个文件,于是各种翻墙加交流群,请教大神都未果,是的,使用YP:list 可以设置排序,但是无法使用分页。
列表页模版提供的是:
<div class="list pic_list"><ul class="pic">
<volist name="list" id="vo" key="k" order="listorder desc">
<li><span><a href="{$vo.url}"><img src="{$vo.thumb}"></a></span><a href="{$vo.url}" target="_blank">{$vo.title}{$vo.listorder}</a></li>
</volist>
</ul></div>
<div id="pages" class="page">{$pages}</div>
因此我只要找到list这个数据的由来就解决问题了,这貌似是yourphp2.*版本遗留下来的bug,我花了一天的时间查资料,请教大神,都没有解决,突然灵光一现,我应该根据代码的执行过程来寻找数据源,于是我根据后台网站更新里面的更新列表页的button,找到了触发生成静态页的函数,接下来就是顺藤摸瓜,哈哈
找到Lib/Action/AdminbaseAction.class.php的create_list()函数,将$list = $dao->field($field)->where($where)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();修改为$list = $dao->field($field)->where($where)->order('listorder desc')->limit($page->firstRow
. ',' . $page->listRows)->select();就大功告成了,对了要记得更新列表页....
public function create_list($catid,$p=1,$count=0)
{
C('DEFAULT_THEME_NAME',$this->sysConfig['DEFAULT_THEME']);
C('HTML_FILE_SUFFIX',$this->sysConfig['HTML_FILE_SUFFIX']);
C('TMPL_FILE_NAME',str_replace('Admin/Default','Home/'.$this->sysConfig['DEFAULT_THEME'],C('TMPL_FILE_NAME')));
if(APP_LANG){
C('TMPL_CACHFILE_SUFFIX','_'.LANG_NAME.'.php');
$lang = C('URL_LANG')!=LANG_NAME ? $lang = LANG_NAME.'/' : '';
L(include LANG_PATH.LANG_NAME.'/common.php');
$T = F('config_'.LANG_NAME,'', './Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/');
}else{
L(include LANG_PATH.$this->sysConfig['DEFAULT_LANG'].'/common.php');
$T = F('config_'.$this->sysConfig['DEFAULT_LANG'],'', './Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/');
}
$this->assign('T',$T);
foreach((array)$this->module as $r){
if($r['issearch'])$search_module[$r['name']] = L($r['name']);
}
$this->assign('search_module',$search_module);
$this->assign ( 'form',new Form());
$this->assign($this->Config);
$this->assign('Categorys',$this->categorys);
$this->assign('Module',$this->module);
$this->assign('Type',$this->Type);
$catid =intval($catid);
if(empty($catid)) $this->success (L('do_empty'));
$cat = $this->categorys[$catid];
$this->assign('catid',$catid);
if($cat['type']) return;
if(empty($cat['ishtml'])) return;
unset($cat['id']);
$this->assign($cat);
$cat['id']=$catid;
$bcid = explode(",",$cat['arrparentid']);
$bcid = $bcid[1];
if($bcid == '') $bcid=intval($catid);
$this->assign('bcid',$bcid);
$urlrule = geturl($cat,'',$this->Urlrule);
$url= ($p > 1 ) ? $urlrule[1] : $urlrule[0];
$url = str_replace('{$page}', $p, $url);
if(strstr($url,C('HTML_FILE_SUFFIX'))){
$filename = basename($url,C('HTML_FILE_SUFFIX'));
$dir = dirname($url).'/';
}else{
$filename = 'index';
$dir= $url;
}
$dir = substr($dir,strlen(__ROOT__.'/'));
if(empty($module))$module=$cat['module'];
$this->assign('module_name',$module);
$this->assign ( 'fields', F($cat['moduleid'].'_Field') );
$this->assign ( 'form',new Form());
if($cat['moduleid']==1){
$cat['listtype']=2;
$module = $cat['module'];
$dao= M($module);
$data = $dao->find($catid);
$seo_title = $cat['title'] ? $cat['title'] : $data['title'];
$this->assign ('seo_title',$seo_title);
$this->assign ('seo_keywords',$data['keywords']);
$this->assign ('seo_description',$data['description']);
$template = $cat['template_list']? $cat['template_list'] : 'index';
//手动分页
$CONTENT_POS = strpos($data['content'], '[page]');
if($CONTENT_POS !== false){
$contents = array_filter(explode('[page]',$data['content']));
$pagenumber = count($contents);
for($i=1; $i<=$pagenumber; $i++) {
$pageurls[$i] = str_replace('{$page}',$i,$urlrule);
}
//生成分页
foreach ($pageurls as $p=>$urls) {
$pages = content_pages($pagenumber,$p, $pageurls);
$this->assign ('pages',$pages);
$data['content'] = $contents[$p-1];
$this->assign ($data);
if($p > 1)$filename = basename($pageurls[$p]['1'],C('HTML_FILE_SUFFIX'));
//$this->buildHtml($filename,$dir,'Home/'.$template);
$r=$this->buildHtml($filename,$dir,'./Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/Page_'.$template.C('TMPL_TEMPLATE_SUFFIX'));
}
}else{
$this->assign($data);
//$r=$this->buildHtml($filename,$dir,'Home/'.$template);
$r=$this->buildHtml($filename,$dir,'./Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/Page_'.$template.C('TMPL_TEMPLATE_SUFFIX'));
}
}else{
$seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
$this->assign ('seo_title',$seo_title);
$this->assign ('seo_keywords',$cat['keywords']);
$this->assign ('seo_description',$cat['description']);
if($cat['listtype']==1){
$template_r = 'index';
}else{
$where = " status=1 ";
if($cat['child']){
$where .= " and catid in(".$cat['arrchildid'].")";
}else{
$where .= " and catid=".$catid;
}
$module = $cat['module'];
$dao= M($module);
if(empty($count))$count = $dao->where($where)->count();
if($count){
import ( "@.ORG.Page" );
$listRows = !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');
$page = new Page ( $count, $listRows ,$p );
$page->urlrule = $urlrule;
$pages = $page->show();
$field = $this->module[$this->mod[$module]]['listfields'];
$field = $field ? $field : 'id,catid,userid,url,username,title,title_style,keywords,description,thumb,createtime,hits';
$list = $dao->field($field)->where($where)->order('listorder desc')->limit($page->firstRow . ',' . $page->listRows)->select();
$this->assign('pages',$pages);
$this->assign('list',$list);
}
$template_r = 'list';
}
$template = $cat['template_list']? $cat['template_list'] : $template_r;
$r=$this->buildHtml($filename,$dir,'./Yourphp/Tpl/Home/'.$this->sysConfig['DEFAULT_THEME'].'/'.$cat['module'].'_'.$template.C('TMPL_TEMPLATE_SUFFIX'));
}
if($r) return true;
}
博主第一次写博客,可能写得很啰嗦,主要是太紧张,担心写不好,大家看不懂,写这篇博客主要的目的是让大家开发起来少浪费一些时间在小问题上(长沙臭豆腐)
相关文章推荐
- 关于内容管理系统IWMS的几个问题
- 关于三星手机调用系统相机之后activity被销毁导致数据丢失问题
- 关于LSCMS(链接工作室内容管理系统)开发的几点感想
- 关于企业内容管理系统(ECM)
- 关于CMS(内容管理系统)系统的一些构思
- 关于服务器centos系统开启伪静态也就是tp用的url重写
- 知识点总结_(做内容管理系统之后总结1)
- 关于调用系统照相机等,onActivityResult之后Activity被销毁问题解决
- 关于动态存储分配函数的调用,在已经过排序的数组中查找及删除内容的操作,余数的分析,删除字符数组中的空格,对链表的逆置,在源字符串中查找子字符串的个数,函数指针以及函数的调用,循环赋值带来的问题以及插入
- 解释hy(Xcms)内容管理系统中,后台manager文件夹中所有ftl页面中指令标签的调用,全部都用@ms.打头的原因
- django:ddtcms关于内容管理系统的想法
- [下载]好东西怎能不分享?推荐一个内容管理系统!
- (转载)[ZT]内容管理系统(CMS)的设计和选型
- 门户中的内容管理系统
- CMS: Content Manage System [内容管理系统] [quoted]
- 开启新的项目——基于电子邮件的知识管理系统
- 面向搜索引擎的内容管理系统(CMS)设计——利用Squid反相代理缓存实现网站内容静态发布
- 关于内容管理的几个问答(by AMT 知识管理研究小组)
- 内容管理系统(CMS)的设计和选型
- 几款PHP内容管理系统介绍(PHP CMS)