国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > PhpCMS > 正文

PHPCMS V9跨站調用推薦位URL為空問題的解決辦法

2024-09-10 07:15:42
字體:
來源:轉載
供稿:網友

如題,如果你在使用PHPCMS V9的時候需要在不同的站點之間調用推薦位可能會出現鏈接的URL為空的情況,具體解決辦法如下,該辦法適合20130522 之前版本.

一、在自定義函數中加入下面的函數:

  1. /**  
  2.  * 獲取內容地址  
  3.  * @param $catid   欄目ID  
  4.  * @param $id      文章ID  
  5.  * @param $allurl  是否以絕對路徑返回  
  6.  */   
  7. function go_dusion($catid,$id$allurl = 0) {   
  8.     static $category;   
  9.     if(emptyempty($category)) {   
  10.         $siteids = getcache('category_content','commons');   
  11.         $siteid = $siteids[$catid];   
  12.         $category = getcache('category_content_'.$siteid,'commons');   
  13.     }   
  14.    
  15.     if($siteid == '' || emptyempty($siteid)) {   
  16.         $siteids = getcache('category_content','commons');   
  17.         $siteid = $siteids[$catid];   
  18.         $category = getcache('category_content_'.$siteid,'commons');   
  19.     }   
  20.        
  21.     $id = intval($id);   
  22.     if(!$id || !isset($category[$catid])) return '';   
  23.        
  24.     $modelid = $category[$catid]['modelid'];   
  25.     if(!$modelidreturn '';       
  26.     $db = pc_base::load_model('content_model');   
  27.     $db->set_model($modelid);   
  28.     $r = $db->get_one(array('id'=>$id), '`url`');   
  29.     if (!emptyempty($allurl)) {   
  30.         if (strpos($r['url'], '://')===false) {   
  31.             if (strpos($category[$catid]['url'], '://') === FALSE) {   
  32.                 $site = siteinfo($category[$catid]['siteid']);   
  33.                 $r['url'] = substr($site['domain'], 0, -1).$r['url'];   
  34.             } else {   
  35.                 $r['url'] = $category[$catid]['url'].$r['url'];   
  36.             }   
  37.         }   
  38.     }   
  39.        
  40.        
  41.     return $r['url'];   

第二:在content/classes/content_tag.class.php 的 public function position($data)函數中,代碼如下:

  1. /**  
  2.      * 推薦位  
  3.      * @param $data  
  4.      */   
  5.     public function position($data) {   
  6.         $sql = '';   
  7.         $array = array();   
  8.         $posid = intval($data['posid']);   
  9.         $order = $data['order'];   
  10.         $thumb = (emptyempty($data['thumb']) || intval($data['thumb']) == 0) ? 0 : 1;   
  11.         //Du修改   
  12.         if(isset($data['siteid']) && is_numeric($data['siteid'])){   
  13.             $siteid = $data['siteid'];   
  14.         }else{   
  15.             $siteid = $GLOBALS['siteid'] ? $GLOBALS['siteid'] : 1;   
  16.         }   
  17.            
  18.         $catid = (emptyempty($data['catid']) || $data['catid'] == 0) ? '' : intval($data['catid']);   
  19.         if($catid) {   
  20.             $siteids = getcache('category_content','commons');   
  21.             if(!$siteids[$catid]) return false;   
  22.             $siteid = $siteids[$catid];   
  23.             $this->category = getcache('category_content_'.$siteid,'commons');   
  24.         }   
  25.         if($catid && $this->category[$catid]['child']) {   
  26.             $catids_str = $this->category[$catid]['arrchildid'];   
  27.             $pos = strpos($catids_str,',')+1;   
  28.             $catids_str = substr($catids_str$pos);   
  29.             $sql = "`catid` IN ($catids_str) AND ";   
  30.         }  elseif($catid && !$this->category[$catid]['child']) {   
  31.                 $sql = "`catid` = '$catid' AND ";   
  32.         }   
  33.         if($thumb$sql .= "`thumb` = '1' AND ";   
  34.         if(isset($data['where'])) $sql .= $data['where'].' AND ';   
  35.         if(isset($data['expiration']) && $data['expiration']==1) $sql .= '(`expiration` >= /''.SYS_TIME.'/' OR `expiration` = /'0/' ) AND ';   
  36.         $sql .= "`posid` = '$posid' AND `siteid` = '".$siteid."'";   
  37.         $pos_arr = $this->position->select($sql'*'$data['limit'],$order);   
  38.         if(!emptyempty($pos_arr)) {   
  39.             foreach ($pos_arr as $info) {   
  40.                 $key = $info['catid'].'-'.$info['id'];   
  41.                 $array[$key] = string2array($info['data']);   
  42.                 $array[$key]['url'] = go_dusion($info['catid'],$info['id']);                   
  43.                    
  44.                 $array[$key]['id'] = $info['id'];   
  45.                 $array[$key]['catid'] = $info['catid'];   
  46.                 $array[$key]['listorder'] = $info['listorder'];   
  47.             }   //Vevb.com 
  48.         }   
  49.         return $array;   
  50.     }   

即可,注意看兩處紅色區域,11-16行是為了獲取siteID 可以根據情況不修改也可以42行,即將原來 的go 改為 go_dusion其它不變即可.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南城县| 淮安市| 博罗县| 盈江县| 商洛市| 新余市| 阿克陶县| 开江县| 澄城县| 乐至县| 溆浦县| 辽中县| 和田县| 甘南县| 宝鸡市| 滨海县| 元阳县| 阿拉善右旗| 泌阳县| 都匀市| 疏勒县| 四子王旗| 安丘市| 迁安市| 马鞍山市| 东兴市| 湛江市| 漯河市| 乌拉特后旗| 新乡县| 东明县| 栖霞市| 赞皇县| 册亨县| 胶州市| 微山县| 河南省| 平湖市| 杨浦区| 洮南市| 穆棱市|