<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>trylife &#187; 帝国CMS分页</title>
	<atom:link href="http://www.trylife.cn/tag/%e5%b8%9d%e5%9b%bdcms%e5%88%86%e9%a1%b5/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trylife.cn</link>
	<description>life&#039;s short , try more...</description>
	<lastBuildDate>Sun, 05 Feb 2012 23:33:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>帝国CMS模板不为人知的技巧2 – 对系统设置的重新赋值</title>
		<link>http://www.trylife.cn/ecms-unkonwn-template-skill-2/</link>
		<comments>http://www.trylife.cn/ecms-unkonwn-template-skill-2/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 14:59:39 +0000</pubDate>
		<dc:creator>TryLife</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[帝国CMS]]></category>
		<category><![CDATA[帝国CMS二次开发]]></category>
		<category><![CDATA[帝国CMS模板]]></category>
		<category><![CDATA[帝国CMS内容不同分页]]></category>
		<category><![CDATA[帝国CMS分页]]></category>
		<category><![CDATA[帝国CMS模板不为人知的技巧]]></category>

		<guid isPermaLink="false">http://www.trylife.cn/?p=835</guid>
		<description><![CDATA[帝国CMS模板不为人知的技巧2 – 对函数参数重新赋值应用]]></description>
			<content:encoded><![CDATA[<p><strong>引言：</strong>继续上一篇：<a title="Permanent Link to 帝国CMS模板不为人知的技巧 – 对语言包重新赋值应用" rel="bookmark" href="http://www.trylife.cn/ecms-template-language-evaluation/">帝国 CMS模板不为人知的技巧 – 对语言包重新赋值应用</a>trylife和大家一起看看 帝国CMS不为人知的技巧2 – 对系统设置的重新赋值；上篇文章有童鞋看了之后觉得一无所获；或者觉得看了之后没什么价值；trylife写这些文章只是指引月亮的方向，<strong><span style="color: #ff0000;">各位童鞋不要在意trylife手指本身</span></strong>；我们做帝国CMS二次开发尽量不修改系统文件的情况下实现功能，这样可以达到不影响升级这样的效果；废话不多说我们来看正文。</p>
<h3>一 查看模板中的全局变量</h3>
<p>我们在模板任意位置放入代码&lt;?=$GLOBALS?&gt;,比如列表模板，重新生成列表页面；查看页面源代码，我们可以看到变量和数组的整齐格式；我们可以看到 $public_r(系统设置数组),$class_r(栏目设置数组),$emod_r(模型设置数组),$fun_r(函数语言数组)，$level_r(会员组数组)等等；还记得上一篇(<a title="Permanent Link to 帝国CMS模板不为人知的技巧 – 对语言包重新赋值应用" rel="bookmark" href="http://www.trylife.cn/ecms-template-language-evaluation/">帝国 CMS模板不为人知的技巧 – 对语言包重新赋值应用</a>)中的例子就是通过对$fun_r中的一个成员重新赋值实现了英文列表分页；<br />
<strong> </strong></p>
<p><span style="color: #888888;"><strong>什么是数组</strong>：你可以回想下 周星驰的《唐伯虎点秋香》唐伯虎混入画府当低等下人，当时武状元说“小子，从今天开始，你就是华府的低等下人，9527就是你的终身代号。开始做事！”这里的低等下人就是一个数组，其中9527就是数组一个成员KEY值，唐伯虎这个人就是就是9527这个KEY的VALUE值；我们把低等下人这个数组变成PHP数组：</span></p>
<p style="text-align: center;"><img class="size-full wp-image-864 aligncenter" title="tangbohudianqiuxiang_didengxiaren_array" src="http://www.trylife.cn/wp-content/uploads/2010/07/tangbohudianqiuxiang_didengxiaren_array.jpg" alt="" width="720" height="257" /></p>
<p>回到帝国CMS，打开e/class/config.php 搜$public_r 这里的$pulic_r就是一个数组(暂时不讨论多元数组)，看到上下图是部分$public_r的截图，sitename,newsurl都是key;对应的帝国网站管理系统,http://www.trylife.cn 这些是VALUE值；你可以在任意模板中加入&lt;?=$public_r[KEY值]?&gt;重新生成页面可以得到相对应的VALUE值，比如&lt;?=$public_r[sitename]?&gt;得到你系统设置的网站名称；</p>
<p style="text-align: center;"><img class="size-full wp-image-862 aligncenter" title="ecms_public_r" src="http://www.trylife.cn/wp-content/uploads/2010/07/ecms_public_r.jpg" alt="" width="555" height="250" /></p>
<h3>二 对系统设置的重新赋值能干点啥</h3>
<p>实例：我们知道帝国CMS所有分页函数遵循统一遵循系统设置中的分页函数，那么我想某个列表使用不同分页函数呢，trylife的答案是可以的；<br />
下面trylife就做了一个比较无聊的例子实现某个列表使用不同的分页函数（为了区分这个列表的数字做成了中文数字冏）；<br />
1.这个特殊的列表用的分页变量是[!--show.listpage--]<br />
2.对应的这个分页变量在$public_r数组中KEY值为listpagelistfun<br />
3.在e/class/userfun.php加了一个新的分页函数 trylife_listpage() <a href="http://www.trylife.cn/wp-content/uploads/2010/07/userfun_function_listpage.php_.tar.gz">点击下载测试函数userfun_function_listpage.php.tar</a><br />
4.在这个列表模板的顶部加入了一段代码&lt;?php $public_r[listpagelistfun]=”trylife_listpage”;?&gt;<span style="color: #888888;">(备注：这里一定要使用双引号，要不会提示函数未定义，感谢报告<strong>☆冰★手☆  276402823</strong> reportdate:2011-05-11)</span></p>
<p><span style="color: #888888;">(备注：帝国CMS后台-&gt;系统参数设置-&gt;信息设置-&gt;列表分页函数(列表) 模式设置是 sys_ShowListMorePage,我们现在针对某个特定的列表要使用不同的分页函数，所以我们在userfun.php写了一个新的函数，并且将函数名赋值给了$public_r[listpagelistfun]；这样使用我们修改的模板的栏目，将会使用我们给他设置的特定的分页函数，也就是trylife_listpage这个函数；）</span></p>
<p style="text-align: center;"><strong><img class="aligncenter" title="ecms_newlistpage_trylife" src="../wp-content/uploads/2010/07/ecms_newlistpage_trylife.jpg" alt="" width="623" height="108" /></strong></p>
<p style="text-align: center;">（上图）帝国CMS特定列表不同分页样式 效果</p>
<h3>三 小结</h3>
<p>1.列表分页函数(下拉) ，内容分页函数都可以用例子中的方法来做不同模板的不同分页<br />
2.几个分页</p>
<table style="font-size: 12px;">
<tbody>
<tr>
<th>分页函数名</th>
<th>数组变量[KEY]</th>
<th>默认函数名</th>
<th>变量</th>
</tr>
</tbody>
<tbody>
<tr>
<td>列表分页函数(下拉)</td>
<td>$public_r[listpagefun]</td>
<td>sys_ShowListPage</td>
<td>[!--show.page--]</td>
</tr>
<tr>
<td>列表分页函数(列表)</td>
<td>$public_r[listpagelistfun]</td>
<td>sys_ShowListMorePage</td>
<td>[!--show.listpage--]</td>
</tr>
<tr>
<td>内容分页函数</td>
<td>$public_r[textpagefun]</td>
<td>sys_ShowTextPage<br />
sys_ShowTextPageSelect</td>
<td>[!--page.url--]<br />
[!--title.select--]</td>
</tr>
</tbody>
</table>
<h3>四 其他</h3>
<p><strong><span style="color: #008000;">除了分页这块，还有很多其他的方面可以赋值，你想到了什么呢？欢迎评论讨论</span></strong></p>
<p>转载写明出处 原文地址：<a href="http://www.trylife.cn/ecms-unkonwn-template-skill-2/">http://www.trylife.cn/ecms-unkonwn-template-skill-2/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.trylife.cn/ecms-unkonwn-template-skill-2/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

