{"id":920,"date":"2009-04-10T13:46:55","date_gmt":"2009-04-10T05:46:55","guid":{"rendered":"http:\/\/www.nan.im\/blog\/?p=920"},"modified":"2009-04-10T13:46:55","modified_gmt":"2009-04-10T05:46:55","slug":"joomla-%e6%a8%a1%e6%9d%bf%e5%b8%b8%e7%94%a8%e6%8a%80%e5%b7%a7%e5%87%bd%e6%95%b0%e6%94%b6%e9%9b%86","status":"publish","type":"post","link":"http:\/\/nan.im\/blog\/920","title":{"rendered":"Joomla \u6a21\u677f\u5e38\u7528\u6280\u5de7\u51fd\u6570\u6536\u96c6\uff08\u4e0d\u65ad\u66f4\u65b0\uff09"},"content":{"rendered":"<p>\u5728\u5e73\u65f6\u5f00\u53d1 Joomla \u6a21\u677f\u7684\u65f6\u5019\u6536\u96c6\u4e86\u4e00\u4e9b\u6781\u4e3a\u5e38\u89c1\u4e5f\u975e\u5e38\u6709\u7528\u7684\u51fd\u6570\uff0c\u73b0\u5217\u51fa\u6765\u65b9\u4fbf\u5236\u4f5c Joomla \u6a21\u677f\u65f6\u67e5\u9605\uff0c\u5177\u4f53\u5185\u5bb9\u5c06\u4e0d\u65ad\u66f4\u65b0\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u8be5\u9875\u4ee3\u7801\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u65f6\u5747\u9700\u5d4c\u5957\u5728 &lt;?php\u00a0 ?&gt; \u6807\u7b7e\u91cc\u9762\uff08\u5730\u7403\u4eba\u90fd\u77e5\u9053\u4e86\uff09\u66f4\u591a\u5b8c\u6574\u51fd\u6570\u53ef\u67e5\u9605 Joomla \u7684\u5b98\u65b9 API \u7f51\u7ad9 <a href=\"http:\/\/api.joomla.org\/\" target=\"_blank\">http:\/\/api.joomla.org\/<\/a> \u8fd9\u91cc\u5217\u51fa\u6765\u7684\u4ec5\u662f\u5236\u4f5c\u6a21\u677f\u4e3b\u9898\u65f6\u7ecf\u5e38\u4f7f\u7528\u5230\u7684\uff1a<\/p>\n<p><!--more--><\/p>\n<p>0\u3001\u5173\u4e8e jdoc \u7684\u4f7f\u7528\uff1a<\/p>\n<pre lang='html4strict' line='1'>\n<jdoc:include type=\"head\" \/>\n<jdoc:include type=\"message\" \/>\n<jdoc:include type=\"component\" \/>\n<jdoc:include type=\"installation\" \/>\n<jdoc:include type=\"module\" name=\"logo\" \/>\n<jdoc:include type=\"module\" name=\"menu\" \/>\n<jdoc:include type=\"modules\" name=\"side\" style=\"xhtml\" \/>\n<jdoc:include type=\"modules\" name=\"main\" style=\"xhtml\" \/>\n<\/pre>\n<p>\u5176\u4e2d type \u5c5e\u6027\u4e3a jdoc \u5143\u7d20\u4e2d\u8981\u6e32\u67d3\u7684\u5185\u5bb9\u7c7b\u578b\uff0c\u5c5e\u6027\u503c\u53ef\u4ee5\u662f\u4e0b\u5217\u7684\u503c\uff1a<\/p>\n<blockquote><p>\nhead \u2014\u2014 \u586b\u5145\u5f53\u524d\u9875&lt;head&gt;\u6807\u7b7e\u91cc\u7684 style script meta \u7b49\u5143\u7d20\uff1b<\/p>\n<p>message \u2014\u2014 \u7528\u4e8e\u5728\u6a21\u677f\u663e\u793a\u7cfb\u7edf\u4fe1\u606f\u6216\u62a5\u9519\u4fe1\u606f\uff0c\u53d1\u5e03\u6a21\u677f\u65f6\u53ef\u4ee5\u5220\u6389\uff1b<\/p>\n<p>component \u2014\u2014 \u7528\u4e8e\u9875\u9762\u4e3b\u4f53\u5185\u5bb9\u8f93\u51fa\uff1b<\/p>\n<p>installation \u2014\u2014 \u4ec5\u7528\u4e8e\u6a21\u677f\u5b89\u88c5\uff0c\u6e32\u67d3\u5b89\u88c5\u6b65\u9aa4\u4e2d\u7684\u4e00\u4e2a\u9875\u9762\u4e3b\u5185\u5bb9\uff0c\u901a\u5e38\u4e0d\u9700\u8981\uff1b<\/p>\n<p>\u4ee5\u4e0a\u5185\u5bb9\u7c7b\u578b\u901a\u5e38\u5728\u4e00\u4e2a\u9875\u9762\u5e94\u5f53\u4ec5\u51fa\u73b0\u4e00\u6b21\uff0c\u5e76\u4e14\u901a\u5e38\u6ca1\u6709\u5176\u4ed6\u5c5e\u6027\uff0c\u5982 name style \u7b49\u5c5e\u6027\uff1b<\/p>\n<p>module \u2014\u2014 \u6e32\u67d3\u7531 name \u5c5e\u6027\u6307\u5b9a\u7684\u5355\u4e00\u6a21\u5757\uff0c\u6a21\u5757\u5fc5\u987b\u662f\u53d1\u5e03\u7684\u5e76\u4e14\u5f53\u524d\u7528\u6237\u6709\u6743\u8bbf\u95ee\uff0c\u53e6\u5916\u8fd8\u53ef\u4ee5\u6709 layout \u53ca controller \u5c5e\u6027\uff1b<\/p>\n<p>modules \u2014\u2014 \u6e32\u67d3\u7531\u6a21\u677f xml \u6587\u4ef6\u4e2d\u6307\u5b9a\u7684\u4f4d\u7f6e\uff0c\u9700\u8981\u7559\u610f\u7684\u662f\u4e00\u4e2a\u4f4d\u7f6e\u53ef\u4ee5\u653e\u7f6e\u591a\u4e2a\u6a21\u5757\uff0c\u8fd9\u70b9\u975e\u5e38\u91cd\u8981\uff0c\u80fd\u4e3a\u4f60\u8282\u7ea6\u5f88\u591a\u65f6\u95f4\u548c\u6210\u672c\uff1b<\/p>\n<p>style \u2014\u2014 \u662f\u5bf9\u4e8e module \u53ca modules \u7c7b\u578b\u7684\u4e00\u4e2a\u53ef\u9009\u5c5e\u6027\uff0c\u8fd9\u4e00\u5c5e\u6027\u6307\u5b9a\u4e86\u6a21\u5757\u88ab\u6e32\u67d3\u98ce\u683c\uff0c\u5982\u679c\u6ca1\u6307\u5b9a\u5c06\u9ed8\u8ba4\u4e3a none \u5c5e\u6027\uff0c\u6240\u6709\u5c5e\u6027\u5728 \/templates\/system\/html\/modules.php \u4e2d\u6709\u58f0\u660e\uff0c\u5305\u62ec\u6709 table horz xhtml rounded outline \u5f53\u7136\u6a21\u677f\u8bbe\u8ba1\u8005\u53ef\u4ee5\u5728\u4f60\u81ea\u5df1\u7684\u6a21\u677f\u540c\u6837\u4f4d\u7f6e\u5bf9\u5176\u8fdb\u884c\u81ea\u5b9a\u4e49\uff0c\u5426\u5219\u5efa\u8bae\u4f7f\u7528 xhtml \u7c7b\u578b\u3002\n<\/p><\/blockquote>\n<p>1\u3001\u5224\u65ad\u5f53\u524d\u9875\u9762\u662f\u5426\u4e3a\u9996\u9875\uff1agetActive(); getDefault();<\/p>\n<pre lang='php' line='1'>\n$menu = & JSite::getMenu();\nif( $menu->getActive() == $menu->getDefault() ){ \/* \u8fd9\u91cc\u663e\u793a\u9996\u9875\u4ee3\u7801 *\/ }else{ \/* \u8fd9\u91cc\u662f\u975e\u9996\u9875\u4ee3\u7801 *\/ }\n<\/pre>\n<p>\u89e3\u91ca\u4e00\u4e0b\uff1a\u8fd9\u91cc\u4f7f\u7528 getActive \u51fd\u6570\u83b7\u53d6\u5f53\u524d\u9875\u9762\u5e76\u4e0e\u9ed8\u8ba4\u9875\u9762\u5bf9\u6bd4\uff1b<\/p>\n<p>2\u3001\u6839\u636e\u4f4d\u7f6e\u662f\u5426\u5b58\u5728\u5185\u5bb9\u8bbe\u7f6e\u4e00\u4e9b\u5bbd\u5ea6\uff1acountModules();<\/p>\n<pre lang='php' line='1'>\nif ($this->countModules('west and east') == 0) { $coreWidth = \"100%\"; }\nif ($this->countModules('west or east') == 1) { $coreWidth = \"75%\"; }\nif ($this->countModules('west and east') == 1) { $coreWidth = \"50%\"; }\n<\/pre>\n<p>\u89e3\u91ca\u4e00\u4e0b\uff1a\u901a\u5e38\u591a\u680f\u9875\u9762\u5728\u6ca1\u6709\u5176\u4e2d\u4e00\u680f\u6216\u591a\u680f\u5185\u5bb9\u7684\u60c5\u51b5\u4e0b\u9700\u8981\u5c06\u5176\u4ed6\u680f\u76ee\u505a\u5bbd\u5ea6\u8c03\u6574\uff0c\u8fd9\u91cc\u4f7f\u7528 countModules() \u51fd\u6570\u5224\u65ad\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u6216\u591a\u4e2a\u4f4d\u7f6e\u3002<\/p>\n<p>\u793a\u4f8b\u4e2d\u5c55\u793a\u7684\u662f\u4e09\u680f\u60c5\u51b5\u4e0b\uff0c\u5047\u4f7f\u4e09\u680f\u5206\u522b\u4e3a\u4e09\u4e2a west core east \u4f4d\u7f6e\uff0c\u5176\u4e2d west \u548c east \u4e3a\u5de6\u53f3\u4e24\u4e2a\u4f4d\u7f6e\u5185\u5bb9\u4e3a\u53ef\u9009\uff0c\u800c core \u4f4d\u7f6e\u4e3a\u4e3b\u4f53\u4f4d\u7f6e\u5185\u5bb9\u4e3a\u5fc5\u987b\uff0c\u901a\u8fc7\u5224\u65ad\u5f97\u51fa\u56db\u79cd\u60c5\u51b5\u5373\uff1a\u65e0 west \u680f\u3001\u65e0 east \u680f\u3001\u4ec5 core \u680f\u53ca\u540c\u65f6\u5177\u6709\u4e09\u680f\u3002\u793a\u4f8b\u4ee3\u7801\u7b2c\u4e00\u884c\u4e3a\u4ec5\u6709 core \u680f\u5373 west \u548c east \u90fd\u4e0d\u5b58\u5728\u7684\u60c5\u51b5\u65f6\u8d4b coreWidth \u4e3a 100% \u5bbd\u5ea6\uff1b\u7b2c\u4e8c\u884c\u4e3a\u4ec5\u6709 west \u6216 east \u680f\u5176\u4e2d\u4e4b\u4e00\u65f6\u8d4b coreWidth \u4e3a 75% \u5bbd\u5ea6\uff1b\u7b2c\u4e09\u884c\u4e3a\u540c\u65f6\u5b58\u5728\u4e09\u680f\u65f6\u9644 coreWidth \u4e3a 50% \u5bbd\u5ea6\u3002\u53d6\u5f97\u4e86 coreWidth \u503c\u4e4b\u540e\u5c31\u53ef\u4ee5\u5728 html \u4ee3\u7801\u4e2d\u5f15\u7528\u4e86\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre lang='html4strict' line='1'>\n<div style=\"width:<?php echo $coreWidth; ?>;\">\n    <jdoc:include type=\"modules\" name=\"core\" \/>\n<\/div>\n<\/pre>\n<p>\u5f53\u7136\uff0c\u8fd9\u91cc\u7701\u7565\u4e86 CSS \u6837\u5f0f\uff0c\u4f60\u9700\u8981\u5728 CSS \u91cc\u9762\u5b9a\u4e49 west \u548c east \u7684\u5bbd\u5ea6\u7b49\u53c2\u6570\u3002<\/p>\n<p>3\u3001\u6839\u636e\u4f4d\u7f6e\u662f\u5426\u6709\u5185\u5bb9\u63a7\u5236\u8f93\u51fa\uff1acountModules();<\/p>\n<pre lang='html4strict' line='1'>\n<?php if ( $this->countModules('west or core or east') == 1 ) : ?>\n<div class=\"body\">\n    <div id=\"west\"><jdoc:include type=\"modules\" name=\"west\" style=\"xhtml\" \/><\/div>\n    <div id=\"core\"><jdoc:include type=\"modules\" name=\"core\" style=\"xhtml\" \/><\/div>\n    <div id=\"east\"><jdoc:include type=\"modules\" name=\"east\" style=\"xhtml\" \/><\/div>\n<\/div>\n<?php endif; ?>\n<\/pre>\n<p>\u89e3\u91ca\u4e00\u4e0b\uff1a\u8fd9\u79cd\u4f7f\u7528\u5176\u5b9e\u662f\u5bf9\u4e0a\u9762\u7b2c 2 \u70b9\u7684\u4e00\u4e2a\u8865\u5145\uff0c\u901a\u5e38\u5728\u8f93\u51fa\u4f4d\u7f6e\u7684\u65f6\u5019\u6211\u4eec\u559c\u6b22\u4f7f\u7528\u4e00\u4e2a div \u5305\u88f9\u8f93\u51fa\u7684\u4f4d\u7f6e\u5185\u5bb9\u7528\u6765\u505a\u4e00\u4e9b\u6548\u679c\uff0c\u4f46\u5982\u679c\u8be5\u4f4d\u7f6e\u6ca1\u6709\u8f93\u51fa\uff0c\u6216\u662f\u4e00\u4e2a\u5927\u901a\u680f\u91cc\u9762\u5305\u62ec\u7684\u4e09\u4e2a\u4f4d\u7f6e\u90fd\u6ca1\u6709\u8f93\u51fa\uff0c\u90a3\u4e48\u8fd9\u4e2a\u901a\u680f\u5c31\u6ca1\u6709\u5fc5\u8981\u8f93\u51fa\u4e86\uff0c\u4f7f\u7528 countModules \u540c\u65f6\u5224\u65ad west core east \u4f4d\u7f6e\u662f\u5426\u6709\u4efb\u610f\u4e00\u4e2a\u4f4d\u7f6e\u6709\u5185\u5bb9\u8f93\u51fa\uff0c\u5982\u679c\u6709\u4efb\u4e00\u4f4d\u7f6e\u6709\u8f93\u51fa\u4fbf\u8f93\u51fa &lt;div class=&#8221;body&#8221;&gt; &lt;\/div&gt; \u4e2d\u95f4\u7684\u5185\u5bb9\u3002<\/p>\n<p>4\u3001\u65b9\u4fbf\u7684\u67e5\u770b\u5f53\u524d\u6a21\u677f\u4f4d\u7f6e\u60c5\u51b5\uff1aindex.php?tp=1<\/p>\n<blockquote><p>\u793a\u4f8b\u4ee3\u7801\uff1a\u7f51\u7ad9 URL \u8def\u5f84 + index.php?tp=1 \uff08\u5982 http:\/\/127.0.0.1\/index.php?tp=1 \u7b49\uff09<\/p>\n<p>\u89e3\u91ca\u4e00\u4e0b\uff1a\u8fd9\u4e2a\u5730\u5740\u53c2\u6570\u7528\u6765\u65b9\u4fbf\u7684\u67e5\u770b\u5f53\u524d\u9875\u9762\u7684\u6a21\u677f\u4e0a\u7684\u4f4d\u7f6e\u60c5\u51b5\uff0c\u53ca\u76f8\u5e94\u7684\u8f93\u51fa\u6a21\u5f0f\uff0c\u5176\u4e2d\u7684 127.0.0.1 \u9700\u8981\u6839\u636e\u5177\u4f53\u5730\u5740\u4fee\u6539\u3002<\/p><\/blockquote>\n<p>5\u3001\u76f4\u63a5\u5728\u6a21\u677f\u8c03\u7528\u6a21\u5757\uff1a<\/p>\n<pre lang='php' line='1'>\nrequire_once (JPATH_BASE .DS. 'modules' .DS. 'mod_latestnews' .DS. 'helper.php');\n$params = new JParameter(\u201d);\n$params -> set('catid',5);\n$params -> set('count',3);\n$list = modLatestNewsHelper::getList($params);\nrequire(JModuleHelper::getLayoutPath('mod_latestnews'));\n<\/pre>\n<p>\u89e3\u91ca\u4e00\u4e0b\uff1a\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u5728\u6a21\u677f\u4e2d\u76f4\u63a5\u8c03\u7528 LatestNews \u6a21\u5757\uff0c\u5e76\u8bbe\u7f6e\u5206\u7c7b ID 28 \u663e\u793a 3 \u7bc7\u6587\u7ae0\u3002<\/p>\n<p>6\u3001\u2026\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5e73\u65f6\u5f00\u53d1 Joomla \u6a21\u677f\u7684\u65f6\u5019\u6536\u96c6\u4e86\u4e00\u4e9b\u6781\u4e3a\u5e38\u89c1\u4e5f\u975e\u5e38\u6709\u7528\u7684\u51fd\u6570\uff0c\u73b0\u5217\u51fa\u6765\u65b9\u4fbf\u5236\u4f5c Joomla \u6a21\u677f\u65f6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[109,20,24,49],"class_list":["post-920","post","type-post","status-publish","format-standard","hentry","category-tech","tag-cms","tag-code","tag-develop","tag-joomla"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts\/920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/comments?post=920"}],"version-history":[{"count":0,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts\/920\/revisions"}],"wp:attachment":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/media?parent=920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/categories?post=920"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/tags?post=920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}