Archive

Archive for the ‘joomla’ Category

override the output from the Joomla! core

November 26th, 2008

There may be occasions where you would like to change the way a Joomla! Extension (such as a Component or Module, whether from the Joomla! core or produced by a third party) is displayed on your site. Of course, you could recode the Extension from scratch, but that may be a bit ambitious for you! Thankfully, there is another way.

The standard output from any Joomla! Module or Component can be overridden by adding code to the html directory of your template. It is also possible to override two aspects of core functionality: Module chrome, and pagination.
Getting a head-start with overrides

If you are new to Joomla! development, then it is probably easiest to start with an existing view, and try modifying it to get what you want. To do this, you should make a copy of the existing view in the html directory of your template, and then modify the copy.

The directory structure you need is:

TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php

For example, if you want to change the way that the ‘Article’ view displays a com_content article, then you should copy the file at

PATH_TO_JOOMLA/components/com_content/views/article/tmpl/default.php
to
TEMPLATE_NAME/html/com_content/article/default.php

(note the slight difference in directory structure)

Similarly, if you want to change how the mod_login Module is displayed, then you should copy

PATH_TO_JOOMLA/modules/mod_login/tmpl/default.php
to
TEMPLATE_NAME/html/mod_login/default.php

Joomla! comes pre-packaged with a frontend template called Beez. Beez utilizes template overrides to produce a table-less layout for faster, smoother, and semantically correct markup. To see how it’s done, locate your Joomla! installation’s template directory, and you’ll notice the Beez template. Inside the Beez template directory, you’ll find a directory named html

the entire directory structure is as follows:

/your_joomla/templates/Beez/html/

If you want to try modifying the overrides used in Beez, you could simply copy and paste the Beez html directory into your own template’s main directory. However you choose to make your override files, you will need to ensure that they are correctly installed with your template. To do this, you should add the following code to your template’s templateDetails.xml file (in between the and tags):

html

The above code in essence lets the Joomla! package installer know that there are files to extract, and that they are part of the template as a whole.
Further tips

Template overrides are almost limitless. They allow you to add, edit, and remove the components of the Joomla! core output. Note: For the FireFox web browser, an extension is available called Firebug, which is useful for browsing a page’s HTML source and matching it up with the PHP code used in template overrides.

More information is available from the following resources:

joomla

joomla判断是否是首页

November 24th, 2008

在1.0当中判定首页一般使用如下的代码:

 <?php if (!((!$option)||($option!="com_frontpage"))){ ?>
 // 非首页
<? php } else {  ?>
//  首页
<?php }?>

在1.5当中此法已不可判断,需要采用如下方法判断:

<?php
    $menu = & JSite::getMenu();
     if($menu->getActive() == $menu->getDefault()){
?>
     //首页
<?php  } else{?>
     //非首页
<?php  } ?>

joomla

Joomla! 首页自由定制-为首页指定单独的模板

November 24th, 2008

大部分的Joomla! 1.5 模板给了我们足够的自由度,来在首页表达足够丰富的内容,然而有时候对于我们来说,三栏或者两栏的表达方式对于我们仍然不够,并且在建站的初期,可能最需要改变的就是首页的规划,从而达到最好的阅读效果。那么怎么才能让首页脱离模板的限制而任意布局和显示内容?

首先在/templates/目录下找到当前的模板目录,将index.php 拷贝为home.php和default.php ,然后我们来修改index.php,index.php的代码如下:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
function isFrontPage(){
 return (JRequest::getCmd('option')=='com_content' && !JRequest::getInt('id'));
}
if(isFrontPage()){
 include_once (dirname(__FILE__).DS.'/home.php');
} else {
 include_once (dirname(__FILE__).DS.'/default.php');
}
?>

其实就是判断是否在访问首页,如果访问首页,怎包含home.php,否则是默认default.php。

接下来就是按照你自己的意愿来修改home.php,而不受任何限制了。通常保留原来模板的页头部分,而内容部分可以你任意布局。

joomla ,

joomla模板单常见问题

November 24th, 2008

什么是模板(Template)?

模板决定了网站的整体外观和布局。模板提供了一个框架来整合通用元素(模块和组件),还包括了级联样式表(CSS)。站点的前端(网站)和后台(管理)都使用了模板。

Joomla! 安装版中包括了若干模板。你可以从其他网站上找到更多的模板,有些是免费的(基于各种许可证),也有些是收费的。此外,很多设计人员都能够制作模板。你也可以尝试制作你自己的模板。

模板通过模板管理器(Template Manager)管理,其入口在管理后台的扩展(Extensions)菜单下。

怎样安装模板(install a tempalte)?

在管理后台循扩展 » 安装和卸载(Extensions » Install & Uninstall)菜单进入,上传 .zip 格式的模板压缩文件即可。

也可以将整个模板文件夹直接复制到 /templates/ 目录下。

怎样修改模板(modify a template)?

模板是保存在 /templates/ 目录下的一系列 xml、php、html 和图片文件组成。你可以直接编辑这些文件,或者通过模板管理器(Template Manager)中提供的编辑接口进行修改(可修改模板中的 html 和 css 文件)。

怎样给特殊的页面单独指定模板?

Joomla! 中设定了默认模板,你也可以给特殊的“页面”单独指定模板,这里的页面特指某个(些)菜单项链接到的页面。因此,要给某个页面指定模板,首先要确保某个菜单项指向这一页面。参考 Joomla! 使用手册 – 菜单及菜单项(Menu & Menu Item)

(为页面指定模板,实际上是为模板分配页面。——译者注)
进入模板管理器,选择所要应用的模板,在 Menu Assignment (菜单分配)中,选择 Select From List (从列表中选择)单选框,然后从下面的下拉列表中,选择你希望应用这一模板渲染的页面,可多选。

注意:不能为系统默认模板分配页面。

深入理解:系统根据 ItemID 决定应用哪个模板。ItemID 在创建菜单项时生成,这就是为什么在为模板分配页面时,下拉列表中只有菜单项可供选择。

(当试图将同一个页面分配给多个模板时,会发生什么呢?——译者的疑问)

可以删除 Powered by Joomla! 信息吗?

可以,你可以从 footer.php 中删除此信息。但是你不能删除代码中的版权和许可证说明。

什么是模块开关(module switches)? (-1, -2, -3)

模块开关是指 mosLoadModules(string module_name, int module_switch) 函数的第二个参数,指显示模块的方式。-1 表示不作任何修饰,仅用一个 <div/> 容器封装模块的 HTML 代码;-2 表示将模块名称显示在一个 <h3/> 标签中,同时将整个模块封装在一个 <div/> 容器中;-3 表示除将模块名称显示在 <h3/> 标签中之外,用多个 <div/> 容器嵌套封装模块,以通过 CSS 技术显示圆角;当 module_switch 参数缺省时,将使用一个2行1列的表格封装模块,第1行单元格中显示模块标题,第2行单元格中载入模块代码。
(本答案省略了原文中的代码示例,仅供参考。)

原文:http://docs.joomla.org/Template_FAQs

joomla ,

joomla的插件和扩展下载中心比wordpress的可差多了

November 16th, 2008

这两天想用joomla架一个站。发现joomla的扩展和插件下载中心,比起wordpress的插件下载中心,可真是差多了。

一.速度慢。同样都是在美国,我感觉wordpress的插件下载中心页面打开很快。

二.分类繁杂。可能也是因为joomla扩展和插件太多的缘故吧。四千多个。wordpress我没去注意,不过估计甚至不会比joomla的少。

三.wordpress插件下载中心的简要说明,安装,功能截图,下载统计等,非常好。极大的提高了插件在我们未下载前对其的了解。仅截图那一项,就不错。还有下载统计,你可以看到下载的分日期统计。了解这个插件是否火爆。而joomla的就差的很多。下载也稍麻烦一点。

四.最讨厌的就是这一条了。joomla的插件下载不在joomla网站上。而是链到各个插件的开发者网站。很多网站都要注册才能下载,太烦人了。所以弄了个firefox插件Bugmenot。据说可以搜索数据库自动去添写注册用户

joomla ,

joomla 模板制作中的 jdoc说明

November 15th, 2008

jdoc:include
<jdoc:include type=”component” />
<jdoc:include type=”head” />
<jdoc:include type=”installation” />
<jdoc:include type=”message” />
<jdoc:include type=”module” name=”breadcrumbs” />
<jdoc:include type=”module” name=”menu” />
<jdoc:include type=”module” name=”submenu” style=”rounded” id=”submenu-box” />
<jdoc:include type=”modules” name=”debug” />
<jdoc:include type=”modules” name=”icon” />
<jdoc:include type=”modules” name=”left” style=”rounded” />
<jdoc:include type=”modules” name=”left” style=”xhtml” />
<jdoc:include type=”modules” name=”right” style=”xhtml” />
<jdoc:include type=”modules” name=”status”  />
<jdoc:include type=”modules” name=”syndicate” />
<jdoc:include type=”modules” name=”title” />
<jdoc:include type=”modules” name=”toolbar” />
<jdoc:include type=”modules” name=”top” />
<jdoc:include type=”modules” name=”top” style=”xhtml” />
<jdoc:include type=”modules” name=”user1″ style=”xhtml” />
<jdoc:include type=”modules” name=”user2″ style=”xhtml” />
<jdoc:include type=”modules” name=”user3″ />
<jdoc:include type=”modules” name=”user4″ />

type 属性

jdoc:include 元素中的type属性指定要渲染的内容类型,属性值可以是component,head,installation,message,module,modules
component
页面内容主输出部分,在模板页面<body>元素中应该只出现一次。

head
填充当前页的style, script,meta的相关元素,应该在模板的<head>元素中只出现一次。

installation
仅仅在安装模板中有用,在前台和后台的模板中没有用到,某种程度上与 component类型相似,渲染安装步骤中中的一个页面主内容。

message
在模板的<body>元素中只出现一次,填充系统或者报错信息。

module
渲染由name属性指定的单一模块,模块必须是发布的并且当前用户有权访问,还可以有layout以及controller属性。

modules
渲染模板中所有指定名称的模块,模块必须是发布的并且当前用户有权访问,还可以有layout以及controller属性。
style 属性

对于module 和modules 类型,style是一个可选属性,这一属性指定了模块被渲染风格,如果没指定style,默认是none

/templates/system/html/modules.php 声明了标准的style:table,horz,xhtml,rounded,outline
模板设计者可以在以下文件自定义style
/user-template/html/modules.php.

joomla ,