EXCMS 标签文件

来自站长百科
跳转至: 导航、​ 搜索

导航:返回上一页

EXCMS的标签页文件为:tag.php,用于显示按Tag 标签及tag 内容的列表。

代码[ ]

01	<?
02	 
03	/**
04	 * Project:     EXCMS: the PHP content management system.
05	 * File:        tag.php
06	 *
07	 * A product of SINOICAN Inc.
08	 *
09	 * EXCMS is a ten million data-level,high speed,human-based content management system.
10	 *
11	 * EX is Excellence & Express & Exceed & Expert.
12	 *
13	 * For questions, help, comments, discussion, please join the
14	 * EXCMS mailing list. Send a blank e-mail to
15	 * excms@sinoican.com
16	 * or join the EXCMS forum
17	 * www.excms.cn/forum
18	 *
19	 * @link http://www.excms.cn/
20	 * @copyright Copyright (c) 2007-2009 SINOICAN Inc.
21	 * @license http://www.excms.cn/licenses/LICENSE-1.0
22	 * @category EXCMS
23	 * @author hukuizhi
24	 * @version $Rev: 58 $
25	 */
26	  
27	 /* $Id: tag.php 58 2009-11-03 02:31:37Z hukuizhi $ */
28	  
29	 /**
30	  * TAG标签封面及列表程序
31	  */
32	 
33	//加载系统配置文件,移动本程序时,请修改配置文件路径
34	require_once ('configuration/inc/common.inc.php');
35	 
36	//获取页面参数
37	$name = trim($_GET['name']);
38	$type = trim($_GET['type']);
39	$_PAGE['pageon'] = (int)$_GET['page'];
40	 
41	//当前位置
42	$split_str = " {$EXCMS['list_symbol']} ";
43	$_PAGE['position'] = "<a href='{$EXCMS['domain']}'>{$EXCMS['home_link_txt']}</a>";
44	 
45	//定义页面模板
46	$tpl = 'tag.html';
47	 
48	if ($name != '') { //显示tag列表
49	    excms_import('EXCMS.content.Tag');
50	    $tag = new Tag();
51	     
52	    if($type == 'pinyin'){
53	        $name = iconv('UTF-8', 'GBK', $name);
54	    }
55	    $_PAGE['thisTag'] = $tag->getByName($name);
56	    if(!(is_array($_PAGE['thisTag']) && count($_PAGE['thisTag']))){
57	        echo "不存在的Tag:$name";exit();
58	    }
59	     
60	    //增加点击量
61	    $tag->clickUp($_PAGE['thisTag']['tagid']);
62	     
63	    $_PAGE['type'] = $type;
64	 
65	    if($type == 'pinyin'){
66	        $tagContentIds = $tag->getContentIdsByName($name);
67	        $tagIdArray = explode(',',$tagContentIds);
68	        if(count($tagIdArray)<6){
69	            rsort($tagIdArray);
70	            excms_import('EXCMS.content.Content');
71	            $content = new Content();
72	            excms_import('EXCMS.update.ContentFunction');
73	            $content_array = $content->getById($tagIdArray[0]);
74	            $url = ContentFunction::getContentUrl($content_array);
75	             
76	            header("HTTP/1.1 301 Moved Permanently");
77	            header("Location:".$url);
78	            exit();
79	        }
80	    }
81	    unset($tag);
82	    $_PAGE['name'] = $name;
83	     
84	    //当前位置
85	    $_PAGE['position'] .= $split_str . $name;
86	    $tpl = 'taglist.html';
87	}
88	 
89	//显示
90	excms_func_templateDisplay($tpl);
91	 
92	?>

代码说明[ ]

  • $name = iconv('UTF-8', 'GBK', $name); //将UTF-8编码转换成GBK编码。
  • $_PAGE['thisTag'] = $tag->getByName($name); //根据TAG名称获取当前TAG的相关信息。
  • $tag->clickUp($_PAGE['thisTag']['tagid']); //根据TAGID更新TAG点击数。
  • $tagContentIds = $tag->getContentIdsByName($name); //获取当前TAG名称下所有内容ID。
  • $content_array = $content->getById($tagIdArray[0]); //根据第一个内容ID获取内容的详细信息。
  • $url = ContentFunction::getContentUrl($content_array); //根据内容详细信息获取URL地址。

代码修改[ ]

$type为'pinyin',tag列表将按照拼音进行TAG分组。 如果您不需要按拼音进行TAG分组,下面的代码可以去掉。

01	if($type == 'pinyin'){
02	    $name = iconv('UTF-8', 'GBK', $name);
03	}
04	 
05	if($type == 'pinyin'){
06	    $tagContentIds = $tag->getContentIdsByName($name);
07	    $tagIdArray = explode(',',$tagContentIds);
08	    if(count($tagIdArray)<6){
09	        rsort($tagIdArray);
10	        excms_import('EXCMS.content.Content');
11	        $content = new Content();
12	        excms_import('EXCMS.update.ContentFunction');
13	        $content_array = $content->getById($tagIdArray[0]);
14	        $url = ContentFunction::getContentUrl($content_array);
15	         
16	        header("HTTP/1.1 301 Moved Permanently");
17	        header("Location:".$url);
18	        exit();
19	  }
20	}

页面参数$_PAGE可以自由修改,根据模板的需要来增加和修改页面参数。模板中可自由调用页面的参数,例如:{$_PAGE.title}显示页面标题。