迅睿CMS框架是一款PHP8高性能·简单易用的CMS开源开发框架,基于MIT开源许可协议发布,免费且不限制商业使用,是免费开源的产品,以万端互联为设计理念,支持的微信公众号、小程序、APP客户端、移动端网站、PC网站等多终端式管理系统。
联系官方销售客服
1835022288
028-61286886
发现4.5.3开始Content类的_call_show在上一页下一页的上面了
之前我是通过模块中重写Content的_call_show 设置了上一页下一页的条件小于当前时间的显示
所以现在用不了
想问下是否会调整回来呢?
如果不调整回来 是否还有其他方法处理呢?
<?php namespace Phpcmf\Model\News; // 模块内容模型类 class Content extends \Phpcmf\Model\Content { // 格式化处理内容 public function _call_show($data) { // 上一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->mytable); $builder->where('catid', (int)$data['catid'])->where('status', 9); $is_fstatus && $builder->where('fstatus', 1); $builder->where('id<', (int)$data['id'])->where('inputtime<=', time())->orderBy('id desc'); $data['prev_page'] = $builder->limit(1)->get()->getRowArray(); // 下一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->mytable); $builder->where('catid', (int)$data['catid'])->where('status', 9); $is_fstatus && $builder->where('fstatus', 1); $builder->where('id>', (int)$data['id'])->where('inputtime<=', time())->orderBy('id asc'); var_dumo $data['next_page'] = $builder->limit(1)->get()->getRowArray(); return $data; } }
// 内容页面的字段格式化处理 protected function _Show_Data($data, $page) { // 处理关键字标签 $data['tag'] = $data['keywords'] = trim($data['keywords']); $data['kws'] = []; $data['tags'] = []; if ($data['keywords']) { $tag = explode(',', $data['keywords']); $obj = false; if (dr_is_app('tag')) { // 是否安装tag $obj = \Phpcmf\Service::M('tag', 'tag'); if (!method_exists($obj, 'get_tag_url')) { $obj = false; } } foreach ($tag as $t) { $t = trim($t); if ($t) { // 读缓存 if ($obj) { $url = $obj->get_tag_url($t); if ($url) { $data['tags'][$t] = $url; } } $data['kws'][$t] = \Phpcmf\Service::L('router')->search_url([], 'keyword', $t, MOD_DIR); } } } // 格式化输出自定义字段 $fields = $this->module['category_data_field'] ? array_merge($this->module['field'], $this->module['category_data_field']) : $this->module['field']; $fields['inputtime'] = ['fieldtype' => 'Date']; $fields['updatetime'] = ['fieldtype' => 'Date']; // 格式化字段 $data = \Phpcmf\Service::L('Field')->app($this->module['dirname'])->format_value($fields, $data, $page); // 挂钩点 内容读取之后 $rt2 = \Phpcmf\Hooks::trigger_callback('module_show_data', $data); if ($rt2 && isset($rt2['code']) && $rt2['code']) { $data = $rt2['data']; } // 模块的回调处理 $data = $this->content_model->_call_show($data); if ($this->is_prev_next_page) { // 关闭插件嵌入 $is_fstatus = dr_is_app('fstatus') && isset($this->module['field']['fstatus']) && $this->module['field']['fstatus']['ismain'] ? 1 : 0; // 上一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable); $builder->where('catid', (int)$data['catid']);//->where('status', 9) $is_fstatus && $builder->where('fstatus', 1); $builder->where('id<', (int)$data['id'])->orderBy('id desc'); $data['prev_page'] = $builder->limit(1)->get()->getRowArray(); if (isset($data['prev_page']['url']) && $data['prev_page']['url']) { $data['prev_page']['url'] = dr_url_prefix($data['prev_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile); } // 下一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable); $builder->where('catid', (int)$data['catid']);//->where('status', 9) $is_fstatus && $builder->where('fstatus', 1); $builder->where('id>', (int)$data['id'])->orderBy('id asc'); $data['next_page'] = $builder->limit(1)->get()->getRowArray(); if (isset($data['next_page']['url']) && $data['next_page']['url']) { $data['next_page']['url'] = dr_url_prefix($data['next_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile); } } return $data; }
// 内容页面的字段格式化处理 protected function _Show_Data($data, $page) { // 处理关键字标签 $data['tag'] = $data['keywords'] = trim($data['keywords']); $data['kws'] = []; $data['tags'] = []; if ($data['keywords']) { $tag = explode(',', $data['keywords']); $obj = false; if (dr_is_app('tag')) { // 是否安装tag $obj = \Phpcmf\Service::M('tag', 'tag'); if (!method_exists($obj, 'get_tag_url')) { $obj = false; } } foreach ($tag as $t) { $t = trim($t); if ($t) { // 读缓存 if ($obj) { $url = $obj->get_tag_url($t); if ($url) { $data['tags'][$t] = $url; } } $data['kws'][$t] = \Phpcmf\Service::L('router')->search_url([], 'keyword', $t, MOD_DIR); } } } // 关闭插件嵌入 $is_fstatus = dr_is_app('fstatus') && isset($this->module['field']['fstatus']) && $this->module['field']['fstatus']['ismain'] ? 1 : 0; // 上一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable); $builder->where('catid', (int)$data['catid'])->where('status', 9); $is_fstatus && $builder->where('fstatus', 1); $builder->where('id<', (int)$data['id'])->orderBy('id desc'); $data['prev_page'] = $builder->limit(1)->get()->getRowArray(); if (isset($data['prev_page']['url']) && $data['prev_page']['url']) { $data['prev_page']['url'] = dr_url_prefix($data['prev_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile); } // 下一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable); $builder->where('catid', (int)$data['catid'])->where('status', 9); $is_fstatus && $builder->where('fstatus', 1); $builder->where('id>', (int)$data['id'])->orderBy('id asc'); $data['next_page'] = $builder->limit(1)->get()->getRowArray(); if (isset($data['next_page']['url']) && $data['next_page']['url']) { $data['next_page']['url'] = dr_url_prefix($data['next_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile); } // 格式化输出自定义字段 $fields = $this->module['category_data_field'] ? array_merge($this->module['field'], $this->module['category_data_field']) : $this->module['field']; $fields['inputtime'] = ['fieldtype' => 'Date']; $fields['updatetime'] = ['fieldtype' => 'Date']; // 格式化字段 $data = \Phpcmf\Service::L('Field')->app($this->module['dirname'])->format_value($fields, $data, $page); // 模块的回调处理 $data = $this->content_model->_call_show($data); return $data; }
我的模块重写代码 上面帖子有个var_dumo请忽略他,不是这边问题 <?php namespace Phpcmf\Model\News; // 模块内容模型类 class Content extends \Phpcmf\Model\Content { // 格式化处理内容 public function _call_show($data) { // 上一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->mytable); $builder->where('catid', (int)$data['catid'])->where('status', 9); $is_fstatus && $builder->where('fstatus', 1); $builder->where('id<', (int)$data['id'])->where('inputtime<=', time())->orderBy('id desc'); $data['prev_page'] = $builder->limit(1)->get()->getRowArray(); // 下一篇文章 $builder = \Phpcmf\Service::M()->db->table($this->mytable); $builder->where('catid', (int)$data['catid'])->where('status', 9); $is_fstatus && $builder->where('fstatus', 1); $builder->where('id>', (int)$data['id'])->where('inputtime<=', time())->orderBy('id asc'); $data['next_page'] = $builder->limit(1)->get()->getRowArray(); return $data; } }
$data['prev_page']改成 $data['prev_page2'] 换一个名字
Content类的_call_show就把这个调到最下面 这个调整下位置好像也不影响其他,会不会更好?回调就可以控制所有的$data的了 // 模块的回调处理 $data = $this->content_model->_call_show($data); return $data;
4.5.3Content类的_call_show我是觉得4.5.3时候 模块回调得放在最后面比较合理的吧