guolii在google sites

本网站的结构

本网站的结构(网站地图也就是sitemap)大致如下:
首页是sites.google.com/site/guolii2005;
各个网页左边总有“导航”区,“导航”就像网站的“导游”;
网站主要内容是日记(博客)、网址收藏、大杂烩;
日记分类了,有家庭、基督、工作、自由软件。。。
日记‎ > ‎自由软件‎ > ‎

关于用joomla扩展功能开发的基础

发布者:? ?,发布时间:‎‎2008-9-3 下午9:57‎

关于用joomla扩展功能开发的基础

关于用来扩展Joomla功能的三大件ComponentsModulesPlug-Ins的区别:


How to Extend Joomla!

There are three types of extensions Joomla! supports, each with a specific use.

Components
Of the extensions available, components are the most essential. Components are
essentially what you see in the "main" portion of the page显示在页面的”主要”部分. Joomla! is designed
to load and run exactly one component for each page generated. Consequently,
Joomla!'s core content management functionality is itself a component.
Components frequently have sophisticated back-end controls. The back end is
commonly used to create and update records in database tables; also it can do
typically anything, provided it is programmed in PHP. For instance, you may have
a batch job that typically runs from a UNIX command line, but you can use the back
end to provide a link where non-programmers can call it. You can also use it to allow
site administrators to upload pictures or videos.
Modules
In contrast to components, any number of modules can appear on a page与元件比较起来,一个页面上可以显示多个模組. Modules
typically make up the elements of a sidebar or content menus. Modules complement
the content contained in a component; they are not intended to be the main substance
of a page. Joomla! also supports content modules, which involve no programming
and can be displayed alongside coded components. The back-end controls for
modules are limited, typically consisting of basic formatting.
Plug-Ins
When a piece of code is needed throughout the site网站中到处运行的一段代码, it is best implemented as a
plug-in (formerly called a Mambot). Plug-ins are commonly used to format the
output of a component or module when a page is built. Some examples of plug-ins
include keyword highlighting, article comment boxes, and JavaScript-based HTML
editors. Plug-ins can also be used to extend the results found in the core search
component. The back-end controls are similar to those of modules.


Joomla!'s Component Structure Joomla! employs a specific naming scheme, which is used by all components. Each component in the system has a unique name with no spaces. The code is split into two folders, each bearing the component name prefixed by com_. The component in this book will be called reviews. Therefore, you will have to create two folders named com_reviews:

· Create one in the folder named components for the front end.

· Create one in the folder named components within the administrator

folder for the back end.

When the component is loaded from the front end, Joomla! will look for a file with the component's unique name ending in a .php extension. Within the components/com_reviews folder, create the reviews.php file. Similarly, running it in the back end assumes the presence of a file prefaced with admin. followed by the component name and ending in .php. Add the file admin.reviews.php in administrator/components/com_reviews. Leave both the files empty for the moment.




Executing the Component All front-end requests in Joomla! go through index.php in the root directory. Different components can be loaded by setting the option variable in the URL GET string. If you install Joomla! on a local web server in a directory titled joomla, the URL for accessing the site will be http://localhost/joomla/index.php or something similar. Assuming this is the case, you can load the component's front end by opening http://localhost/joomla/index.php?option=com_reviews in your browser. At this point, the screen should be essentially blank, apart from the common template elements and modules. To make this component slightly more useful, open reviews.php and add the following code, then refresh the browser:

<?php defined( '_JEXEC' ) or die( 'Restricted access' ); echo '<div class="componentheading">Restaurant Reviews</div>'; ?>

Your screen will look similar to the following:











以下是Joomla1.0.x版本,请在后面看joomla1.5.x的模板例子!

The Joomla! Template

First, let's look at the following figure to see how our basic template affects the Joomla! PHP output:



Figure 2.1 What your XHTML does to the template layout

You'll recall that the PHP code for the footer, sitename, pathway, and MainBody are not module position slots. These functions load in the required information that helps Joomla! to run, display standard footer information, and load the actual site content from the Joomla! MySQL databases

Top, left, and right are module position slots, which can be assigned site modules.




模板(template)决定module slots的位置 和 component(组件)的位置(同一时刻只显示一个component,就是前面Jommla1.0.x<?php mosMainBody();?>和后面Jommla1.5.x的模板中的<jdoc:include type="component" />)

Now that we have a deeper understanding of how the template, module position slots, and site modules work, let's take a look at how these three elements come together through the rhuk_solar_flare_ii template. The module position slot name is on the left, the content module name is on the right,





举例:CEF的首页模板joomla1.5.2/templates/gian_idv_tw/index.php内容:

<html>

<head>

<jdoc:include type="head" />


<link href="<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/CSS.css" rel="stylesheet" type="text/css">

<!--

<script language="JavaScript" src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/Scripts/menu.js"></script>

-->

<script language="JavaScript" src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/Scripts/swapimage.js"></script>


<script language="JavaScript" src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/mm_menu.js"></script>


<script src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<link href="<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/hotnews.css" rel="stylesheet" type="text/css">


<script type="text/JavaScript">

<!--

function MM_popupMsg(msg) { //v1.0

alert(msg);

}

//-->

</script>


<?php

include("templates/CEF/menu.php");

?>



</head>

<?php

if ( $my->id ) {

//initEditor();

}

?>


<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/button_search_2.gif','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_23_1.gif','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_24_1.gif','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_25_1.gif','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/button_re_2.gif','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/button_send_2.gif','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_10_1.jpg','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_11_1.jpg','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_12_1.jpg','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_13_1.jpg','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_14_1.jpg','<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_15_1.jpg')">


<script language="JavaScript1.2">mmLoadMenus();</script>


<div id="main">

<div class="header">

<div class="top_left">

<div class="logo">

<embed src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/logo.swf" quality="high" wmode="transparent" bgcolor="#ffffff" allowscriptaccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" align="middle" height="174" width="341"/>

</div>


</div>

<div class="top_right">

<?php

include("templates/CEF/web_links.php");

?>



<div id="searchbar">

<?php

include("templates/CEF/search_bar.php");

?>

</div>


<div id="menubar">

<?php

include("templates/CEF/menubar.php");

?>

</div>


</div>


</div>


<div class="main_content">

<div class="main_left">

<table border="0" align="left" cellpadding="0" cellspacing="0">

<tr>

<td rowspan="3" valign="top"><img src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_19.gif" width="17" height="194" alt=""></td>

<td><img src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_20.gif" width="225" height="12" alt=""></td>

</tr>

<tr>

<td class="bg_left_table"><div align="left"><img src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_30.gif" width="225" height="35" alt="">


<!--教育新闻台-->

<?php if($this->countModules('user1')) : ?>

<jdoc:include type="modules" name="user1" style="xhtml" />

<?php endif; ?>

<?php if($this->countModules('left')) : ?>

<jdoc:include type="modules" name="left" style="rounded" />

<?php endif; ?>

</div></td>

</tr>

<tr>


<td height="13" valign="bottom" class="bg_left_table"><img src="<?php echo $this->baseurl;?>/templates/gian_idv_tw/images/index_54.gif" width="225" height="13" alt=""></td>

</tr>

</table>

</div>

<div class="main_right">

<table width="684" border="0" cellspacing="0" cellpadding="0">

<tr>

<td bgcolor="#FFFFFF">


<!--标签页-->

<?php if($this->countModules('user2')) : ?>

<jdoc:include type="modules" name="user2" style="xhtml" />

<?php endif; ?>

</td>


<td>


<?php

include("templates/CEF/right_ad.php");

?>

<!--<iframe id="ad" name="ad" src="link_button.html" width="182" height="194" scrolling="no" frameborder="0"></iframe>-->

</td>

</tr>

</table>

<table width="684" border="0" cellspacing="0" cellpadding="0">

<tr>

<td>

<!--2x2方框-->

<jdoc:include type="component" />


</td>

</tr>


<!--picture banner-->

<?php if($this->countModules('user3')) : ?>

<jdoc:include type="modules" name="user3" style="xhtml" />

<?php endif; ?>


</table>

</div>

<div id="footer"><br><br>

Copyright (C)2005 Campus Evangelical Fellowship All Rights Reserved. .校園福音團契 版權所有. E-mail<a href="mailto:info@cef.org.tw">info@cef.org.tw</a> . 電 話:(02) 2368-2361 .傳 真:(02) 2367-2139</div><div id="space"></div>

</div>

</div>


<jdoc:include type="modules" name="debug" />



</body>


</html>