PHPCMS V9跨站调用推荐位URL为空问题的解决办法
2013-06-09 10:09
411 查看
如题,如果你在使用PHPCMS V9的时候需要在不同的站点之间调用推荐位可能会出现链接的URL为空的情况,具体解决办法如下,该办法适合20130522 之前版本
一、在自定义函数中加入下面的函数:
第二:在content/classes/content_tag.class.php 的 public function position($data)函数中
即可,注意看两处红色区域,11-16行是为了获取siteID 可以根据情况不修改也可以
42行,即将原来 的go 改为 go_dusion其它不变即可。
一、在自定义函数中加入下面的函数:
/** * 获取内容地址 * @param $catid 栏目ID * @param $id 文章ID * @param $allurl 是否以绝对路径返回 */ function go_dusion($catid,$id, $allurl = 0) { static $category; if(empty($category)) { $siteids = getcache('category_content','commons'); $siteid = $siteids[$catid]; $category = getcache('category_content_'.$siteid,'commons'); } if($siteid == '' || empty($siteid)) { $siteids = getcache('category_content','commons'); $siteid = $siteids[$catid]; $category = getcache('category_content_'.$siteid,'commons'); } $id = intval($id); if(!$id || !isset($category[$catid])) return ''; $modelid = $category[$catid]['modelid']; if(!$modelid) return ''; $db = pc_base::load_model('content_model'); $db->set_model($modelid); $r = $db->get_one(array('id'=>$id), '`url`'); if (!empty($allurl)) { if (strpos($r['url'], '://')===false) { if (strpos($category[$catid]['url'], '://') === FALSE) { $site = siteinfo($category[$catid]['siteid']); $r['url'] = substr($site['domain'], 0, -1).$r['url']; } else { $r['url'] = $category[$catid]['url'].$r['url']; } } } return $r['url']; }
第二:在content/classes/content_tag.class.php 的 public function position($data)函数中
/** * 推荐位 * @param $data */ public function position($data) { $sql = ''; $array = array(); $posid = intval($data['posid']); $order = $data['order']; $thumb = (empty($data['thumb']) || intval($data['thumb']) == 0) ? 0 : 1; //Du修改 if(isset($data['siteid']) && is_numeric($data['siteid'])){ $siteid = $data['siteid']; }else{ $siteid = $GLOBALS['siteid'] ? $GLOBALS['siteid'] : 1; } $catid = (empty($data['catid']) || $data['catid'] == 0) ? '' : intval($data['catid']); if($catid) { $siteids = getcache('category_content','commons'); if(!$siteids[$catid]) return false; $siteid = $siteids[$catid]; $this->category = getcache('category_content_'.$siteid,'commons'); } if($catid && $this->category[$catid]['child']) { $catids_str = $this->category[$catid]['arrchildid']; $pos = strpos($catids_str,',')+1; $catids_str = substr($catids_str, $pos); $sql = "`catid` IN ($catids_str) AND "; } elseif($catid && !$this->category[$catid]['child']) { $sql = "`catid` = '$catid' AND "; } if($thumb) $sql .= "`thumb` = '1' AND "; if(isset($data['where'])) $sql .= $data['where'].' AND '; if(isset($data['expiration']) && $data['expiration']==1) $sql .= '(`expiration` >= \''.SYS_TIME.'\' OR `expiration` = \'0\' ) AND '; $sql .= "`posid` = '$posid' AND `siteid` = '".$siteid."'"; $pos_arr = $this->position->select($sql, '*', $data['limit'],$order); if(!empty($pos_arr)) { foreach ($pos_arr as $info) { $key = $info['catid'].'-'.$info['id']; $array[$key] = string2array($info['data']); $array[$key]['url'] = go_dusion($info['catid'],$info['id']); $array[$key]['id'] = $info['id']; $array[$key]['catid'] = $info['catid']; $array[$key]['listorder'] = $info['listorder']; } } return $array; }
即可,注意看两处红色区域,11-16行是为了获取siteID 可以根据情况不修改也可以
42行,即将原来 的go 改为 go_dusion其它不变即可。
相关文章推荐
- PHPCMS V9跨站调用推荐位出现URL连接为空问题的解决方法
- C# asp.net页面通过URL参数传值中文乱码问题解决办法
- Xcode8 ios 10 调用相机、相册、麦克风、位置等隐私问题崩溃解决办法
- url传中文乱码问题解决办法
- “DllRegisterServer的调用失败”问题解决办法
- ORACLE:SP2-1503: 无法初始化 Oracle 调用界面 SP2-1503: 无法初始化 Oracle 问题的解决办法
- 最近被问的最多的space上播放器url被自动清空的问题, 解决办法
- C# asp.net页面通过URL参数传值中文乱码问题解决办法
- 用Labview调用两个相机采集图像程序以及出现串图问题的解决办法
- mailto 调用邮件客户端乱码问题的解决办法
- 安装及调用Matlab程序可能存在的问题解决办法
- 继“破解某国外收费的RTMP Client并成功在Android和Java上调用”后续问题解决办法
- 工作线程中调用UI线程创建的窗口的UpdateData会导致Assert的问题及解决办法.
- 关于AJAX调用ASP.NET MVC 或者WEBAPI项目提示I跨域问题的解决办法
- Emgu中无法调用cxcore.dll等的问题解决办法
- Java 调用 FFMPEG 命令时用 url 作为输入源,Linux 下出现 “no such file or directory” 问题的解决
- 调用Dubbo服务报以下错误(com.alibaba.dubbo.remoting.RemotingException),问题原因和解决办法
- 关于DllRegisterServer的调用失败的问题解决办法
- 安卓EditText有时点击后无法自动弹出键盘的解决办法;TextWatcher多次调用问题
- 远古404 URL资源没有找到和服务器连接数已满问题解决办法