在内容模型里创建文件(即phpcms\modules\content目录下)
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
//模型缓存路径
define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
pc_base::load_app_func('util','content');
class printr {
private $db;
function __construct() {
$this->db = pc_base::load_model('content_model');
$this->_userid = param::get_cookie('_userid');
$this->_username = param::get_cookie('_username');
$this->_groupid = param::get_cookie('_groupid');
}
//内容页
public function show() {
$catid = intval($_GET['catid']);
$id = intval($_GET['id']);
$siteids = getcache('category_content','commons');
$siteid = $siteids[$catid];
$CATEGORYS = getcache('category_content_'.$siteid,'commons');
$this->category = $CAT = $CATEGORYS[$catid];
$this->category_setting = $CAT['setting'] = string2array($this->category['setting']);
$siteid = $GLOBALS['siteid'] = $CAT['siteid'];
$MODEL = getcache('model','commons');
$modelid = $CAT['modelid'];
$tablename = $this->db->table_name = $this->db->db_tablepre.$MODEL[$modelid]['tablename'];
$r = $this->db->get_one(array('id'=>$id));
if(!$r || $r['status'] != 99) showmessage(L('info_does_not_exists'),'blank');
$this->db->table_name = $tablename.'_data';
$r2 = $this->db->get_one(array('id'=>$id));
$rs = $r2 ? array_merge($r,$r2) : $r;
//再次重新赋值,以数据库为准
$catid = $CATEGORYS[$r['catid']]['catid'];
$modelid = $CATEGORYS[$catid]['modelid'];
require_once CACHE_MODEL_PATH.'content_output.class.php';
$content_output = new content_output($modelid,$catid,$CATEGORYS);
$data = $content_output->get($rs);
extract($data);
include template('content','print_r');
}
}
?>
内容模型的模板文件按照模型指定的名字来建,如上面指定的是print_r.html文件,然后在这个文件就可以输出你想要的内容页的指定字段内容进行打印预览了,
需要打印功能的页面加上:<a href="{APP_PATH}index.php?m=content&c=printr&a=show&catid={$catid}&id={$id}">打印</a>
打印页的样式可以完全按照内容页的代码去调用内容!
V9增加打印模板和打印预览功能
admin
2015-06-27 20:45:26
¥ 打赏
×
如果您觉得文章帮助了您就打赏一下吧
非常感谢你的打赏,我们将继续分享更多优质内容,让我们一起创建更加美好的网络世界!
支付宝扫一扫打赏
微信扫一扫打赏
本文《V9增加打印模板和打印预览功能》发布于石头博客文章,作者:admin,如若转载,请注明出处:https://www.pweb123.com/cms/phpcms/439.html,否则禁止转载,谢谢配合!
阅读排行
小程序插件
站长推荐
-
百度小程序审核被拒原因--汇总各种奇葩原因
- 486
-
重新对百度支付进行编写封装(百度智能小程序支付)
- 370
-
phpcms小程序插件api接口升级到4.3
- 814
-
phpcms封装的微信h5支付源码DEMO参考
- 755
添加微信好友
文章点评