商务服务
php手机站生成,PHPCMS二次开发wap手机站创建tags列表页及调用教程
2024-12-23 21:05

这篇文章主要为大家详细介绍了PHPCMS二次开发wap手机站创建tags列表页及调用教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴。

本文是361源码今天早上起床后看到的一篇文章,感觉有参考价值,就转载过来了,如有版权,请联系本站处理。

用PHPCMS创建了PC站的tags汇总页和列表页,通过统计观察效果还不错,有不少人访问,因此想在移动端手机站上也创建tags汇总页和列表页,可是默认只能在 phpcms emplatesdefaultcontent 创建一个tag.html和tag_list.html页面,在PC端用了移动端就用不了了,361源码网站长思考了下,能不能在移动端 phpcms emplatesdefaultwap 目录下也创建一个tag.html和tag_list.html 页面来实现呢?下面就是361源码网站长的实现方法,希望对有需要的朋友有所帮助。

1、将 phpcmsmodulescontent ag.php 文件拷贝到 phpcmsmoduleswap 目录下

2、打 phpcmsmoduleswap ag.php 文件

2.1、将 pc_base::load_app_func('util','content'); 注释或删除,并在原位置添加 pc_base::load_app_func('global');

2.2、将 __construct() 函数中 $this->siteid = get_siteid(); 注释或删除,并在原位置下边添加$this->siteid = isset($_GET['siteid']) && (intval($_GET['siteid']) > 0) ? intval(trim($_GET['siteid'])) : (param::get_cookie('siteid') ? param::get_cookie('siteid') : 1);

param::set_cookie('siteid',$this->siteid);

$this->wap_site = getcache('wap_site','wap');

$this->types = getcache('wap_type','wap');

$this->wap = $this->wap_site[$this->siteid];

define('WAP_SITEURL', $this->wap['domain'] ? $this->wap['domain'].'index.php?' : APP_PATH.'index.php?m=wap&siteid='.$this->siteid);

if($this->wap['status']!=1) exit(L('wap_close_status'));

2.3、将 include template('content', 'tag'); 修改为 include template('wap', 'tag');

2.4、找到 $res = $this->db->get_one(array('id'=>$contentid), 'title, description, url, inputtime, style');

修改为$res = $this->db->get_one(array('id'=>$contentid), 'catid, title, description, inputtime, style');

此步骤添加 catid, 并删除 url,

2.5、找到 $res['description'] = str_replace($tag, ''.$tag.'', $res['description']); 并在此代码下边添加$catid = $res['catid'];

$types = getcache('wap_type','wap');

foreach ($types as $type) {

if($type['cat']==$catid) {

$typeid = $type['typeid'];

break;

}

}

$res['url'] = WAP_SITEURL."&a=show&catid=".$catid."&typeid=".$typeid."&id=".$contentid;

2.6、将 include template('content','tag_list'); 修改为 include template('wap','tag_list');

2.7、如想看完整文件请在文章最下边看

3、文章内容页调用示例:{loop $keywords $keyword}{$keyword}{/loop}

4、在 phpcms emplatesdefaultwap 目录下创建 tag.html 即为tags汇总页 tag_list.html 即为tags列表页

5、tag.html调用标签示例:{loop $infos $info}

{$info['keyword']}({$info['videonum']})

{/loop}

6、tag_list.html调用标签示例

{loop $datas $r}

{date('Y-m-d H:i:s',$r[inputtime])}· {$r[title]}

{/loop}

{$pages}

7、phpcmsmoduleswap ag.php 文件完整展示<?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'); 删除,并在原位置添加 pc_base::load_app_func('global');

pc_base::load_app_func('global');

class tag {

private $db;

function __construct() {

$this->db = pc_base::load_model('content_model');

$this->keyword_db = pc_base::load_model('keyword_model');

//此处将 $this->siteid = get_siteid(); 删除并添加如下代码,直到此函数最后

$this->siteid = isset($_GET['siteid']) && (intval($_GET['siteid']) > 0) ? intval(trim($_GET['siteid'])) : (param::get_cookie('siteid') ? param::get_cookie('siteid') : 1);

param::set_cookie('siteid',$this->siteid);

$this->wap_site = getcache('wap_site','wap');

$this->types = getcache('wap_type','wap');

$this->wap = $this->wap_site[$this->siteid];

define('WAP_SITEURL', $this->wap['domain'] ? $this->wap['domain'].'index.php?' : APP_PATH.'index.php?m=wap&siteid='.$this->siteid);

if($this->wap['status']!=1) exit(L('wap_close_status'));

}

public function init() {

$page = max($_GET['page'], 1);

$pagesize = 20;

$wher'`siteid`='.$this->siteid;

$infos = $this->keyword_db->listinfo($where, '`searchnums` DESC, `videonum` DESC', $page, $pagesize);

$pages = $this->keyword_db->pages;

//将原模板路径 content 修改为新手机模板路径 wap

include template('wap', 'tag');

}

public function lists() {

$tag = safe_replace(addslashes($_GET['tag']));

$keyword_data_db = pc_base::load_model('keyword_data_model');

//获取标签id

$r = $this->keyword_db->get_one(array('keyword'=>$tag, 'siteid'=>$this->siteid), 'id');

if (!$r['id']) showmessage('不存在此关键字');

$tagid = intval($r['id']);

$page = max($_GET['page'], 1);

$pagesize = 20;

$wher'`tagid`=''.$tagid.'' AND `siteid`='.$this->siteid;

$infos = $keyword_data_db->listinfo($where, '`id` DESC', $page, $pagesize);

$pages = $keyword_data_db->pages;

$total = $keyword_data_db->number;

if (is_array($infos)) {

$datas = array();

foreach ($infos as $info) {

list($contentid, $modelid) = explode('-', $info['contentid']);

$this->db->set_model($modelid);

//下行代码添加 catid, 并删除 url,

$res = $this->db->get_one(array('id'=>$contentid), 'catid, title, description, inputtime, style');

$res['title'] = str_replace($tag, ''.$tag.'', $res['title']);

$res['description'] = str_replace($tag, ''.$tag.'', $res['description']);

//此处为361源码网(www.ke361.com)添加代码开始

$catid = $res['catid'];

$types = getcache('wap_type','wap');

foreach ($types as $type) {

if($type['cat']==$catid) {

$typeid = $type['typeid'];

break;

}

}

$res['url'] = WAP_SITEURL."&a=show&catid=".$catid."&typeid=".$typeid."&id=".$contentid;

//此处为361源码网(www.ke361.com)添加代码结束

$datas[] = $res;

}

}

$SEO = seo($siteid, '', $tag);

//将原模板路径 content 修改为新手机模板路径 wap

include template('wap','tag_list');

}

}

?>

转载完毕,代码361源码没有亲测,有兴趣的朋友可以自行测试,如果有问题请向我们反映。

以上就是PHPCMS二次开发wap手机站创建tags列表页及调用教程的全部内容,希望对大家的学习和解决疑问有所帮助,也希望大家多多支持361模板网。

php手机站生成,PHPCMS二次开发wap手机站创建tags列表页及调用教程

    以上就是本篇文章【php手机站生成,PHPCMS二次开发wap手机站创建tags列表页及调用教程】的全部内容了,欢迎阅览 ! 文章地址:https://sicmodule.kub2b.com/news/9694.html
     栏目首页      相关文章      动态      同类文章      热门文章      网站地图      返回首页 企库往资讯移动站 https://sicmodule.kub2b.com/mobile/ , 查看更多   
最新文章
运营师抖音代运营
运营师抖音代运营:掌握流行短视频潮流的神奇职业短视频平台已经成为人们娱乐、学习和社交的重要方式。在众多的短视频平台中,抖
微短剧,2024年“最大赢家”? | 年终盘点
2024,短剧行业大变样。作者 | 张语格编辑 | 趣解商业文娱组“互联网大厂争相入局。”“98%的短剧制作方都在亏钱。”“用户被免
同类第一!20%弹性的人工智能 ETF 科创(588760)今日上市,一键布局科创板优质AI龙头
  最新公告内容显示,广发上证科创板交易型开放式指数投资基金(基金代码:588760;扩位简称: ETF 科创)已于 2025 年 1 月 1
如何使用关键词排名提升工具
随着互联网的飞速发展,自媒体行业逐渐成为热门领域,许多自媒体作者希望通过优质内容吸引更多粉丝,提高自己的知名度,在众多竞
2025快手广告跳转微信如何实现?配置详解
​​快手作为中国领先的短视频平台,拥有庞大的用户基础和高度的用户活跃度,为品牌提供了一个巨大的流量池。然而,如何将这些流
Tiktok专题
随着TikTok在全球范围内的爆发式增长,越来越多的品牌和企业开始关注这个平台,并寻找适合他们的产品来进行市场推广。想要在TikT
什么兼职最赚钱最快速?盘点适合负债者的10个副业
在当下经济环境下,许多人可能面临负债的压力,包括买房、买车等等,寻找一份能够快速赚钱的兼职成为了许多人的迫切需求。那么,
Google回击设计_今日google搜索Google设计教程
摘要:Google回击设计,今日google搜索Google设计教程,新片场素材小编舒子颖Google回击设计,今日google搜索Google设计教程相关内
关键词排名上不去怎么办(关键词排名靠前原因)
本文目录导读:关键词选择外链建设持续优化注意事项随着自媒体行业的不断发展,越来越多的创作者加入了这个大家庭,在激烈的竞争
A股市场昨有所回落 小红书概念股继续走强
每经记者:杨建    每经编辑:赵云1月14日,A股市场全天高开高走,三大指数放量大涨。1月15日,A股市场有所回落。截至收盘,