- Joomla 基础教程
- Joomla - 首页
- Joomla - 概述
- Joomla - 安装
- Joomla - 架构
- Joomla - 控制面板
- Joomla - 工具栏
- Joomla - 菜单菜单
- Joomla - 内容菜单
- Joomla - 组件菜单
- Joomla - 扩展菜单
- Joomla - 帮助菜单
- Joomla 模块
- Joomla - 创建模块
- Joomla - 面包屑模块
- Joomla - 信息聚合显示模块
- Joomla - 页脚模块
- Joomla - 最新新闻模块
- Joomla - 搜索模块
- Joomla - 随机图片模块
- Joomla - 在线用户模块
- Joomla - 信息发布模块
- Joomla - 捐赠模块
- Joomla 全局设置
- Joomla - 系统设置
- Joomla - 媒体设置
- Joomla - 语言管理器
- Joomla - 私人消息
- Joomla - 群发邮件
- Joomla - 缓存管理
- Joomla - 用户设置
- Joomla - 调试
- Joomla 高级功能
- Joomla - 模板管理器
- Joomla - 自定义模板
- Joomla - 添加模板
- Joomla - 创建模板
- Joomla - 自定义Logo
- Joomla - 分类管理
- Joomla - 添加内容
- Joomla - 内容排版
- Joomla - 文章元数据
- Joomla - 添加横幅广告
- Joomla - 添加联系方式
- Joomla - 添加新闻订阅
- Joomla - 添加论坛
- Joomla - 添加网站链接
- Joomla - 插件管理器
- Joomla - 扩展管理器
- Joomla - 网站备份
- Joomla - 网站SEO
- Joomla 有用资源
- Joomla - 问答
- Joomla - 快速指南
- Joomla - 有用资源
- Joomla - 讨论
Joomla - 创建模板
在本章中,我们将学习如何在Joomla中创建模板。
创建模板
以下是Joomla中创建模板的简单步骤:
步骤1 - 在你的Joomla → Templates文件夹内创建一个名为MyFirstTemplate的文件夹。在MyFirstTemplate文件夹内,再创建两个名为images和CSS的文件夹,用于保存所有图片和CSS文件。
步骤2 - 在MyFirstTemplate文件夹内,创建一个名为templateDetails.xml的文件,没有此文件,模板将无法在Joomla中显示。
templateDetails.xml
<?xml version = "1.0" encoding = "utf-8"?>
<extension version = "3.0" type = "template">
<name>Tutorials Point</name>
<creationDate>2015-06-13</creationDate>
<author>Tutorials Point</author>
<authorEmail>tutorials@example.com</authorEmail>
<authorUrl>http://www.example.com </authorUrl>
<copyright>Jack 2015</copyright>
<license>GNU/GPL</license>
<version>1.0.2</version>
<description>My First Template</description>
<files>
<filename>index.php</filename>
<filename>templateDetails.xml</filename>
<folder>images</folder>
<folder>css</folder>
</files>
<positions>
<position>breadcrumb</position>
<position>left</position>
<position>right</position>
<position>top</position>
<position>user1</position>
<position>user2</position>
<position>user3</position>
<position>user4</position>
<position>footer</position>
</positions>
</extension>
代码详情
<files> - 它包含MyFirstTemplate文件夹中可用的文件和文件夹。
<folder> - 它包含MyFirstTemplate文件夹中所有可用的文件夹。
步骤3 - 创建一个名为index.php的文件。这有助于执行所有Joomla页面。
index.php
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
<!DOCTYPE html>
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "<?php echo $this->language; ?>" lang = "<?php echo $this->language; ?>" >
<head> //head section
<jdoc:include type = "head" />
<link rel = "stylesheet" href = "<?php echo $this->baseurl ?>/templates/system/css/system.css" type = "text/css" />
<link rel = "stylesheet" href = "<?php echo $this->baseurl ?>/templates/system/css/general.css" type = "text/css" />
<link rel = "stylesheet" href = "<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template.css" type="text/css" />
</head>
<body> //body section
<jdoc:include type = "modules" name = "top" />
<jdoc:include type = "component" />
<jdoc:include type = "modules" name = "bottom" />
</body>
</html>
?>
代码详情
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?> <!DOCTYPE html> <html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "<?php echo $this->language; ?>" lang = "<?php echo $this->language; ?>" >
此代码用于告诉浏览器正在使用哪种类型的html页面,并通过描述网站中使用的语言来开始HTML文档。
<head> //head section <jdoc:include type = "head" /> <link rel = "stylesheet" href = "<?php echo $this->baseurl ?>/templates/system/css/system.css" type = "text/css" /> <link rel = "stylesheet" href = "<?php echo $this->baseurl ?>/templates/system/css/general.css" type = "text/css" /> <link rel = "stylesheet" href = "<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template.css" type = "text/css" /> </head>
这些行用于链接Joomla模板的各种样式表。
<body> //body section <jdoc:include type = "modules" name = "top" /> <jdoc:include type = "component" /> <jdoc:include type = "modules" name = "bottom" /> </body>
此处在body部分,jdoc用于包含Joomla系统某些部分在Joomla中的输出。name = "top"用于将菜单设置在顶部。
步骤4 - 创建这两个文件后,登录Joomla并点击扩展→扩展管理器,将会显示如下页面。
步骤5 - 在上述页面中,点击发现链接,将会显示如下页面。
步骤6 - 接下来,点击发现按钮来发现新创建的模板,如下所示。
步骤7 - 点击复选框选择模板,然后点击安装按钮将模板安装到Joomla中。
步骤8 - 安装模板后,您可以通过点击扩展→模板管理器来查看您新创建的模板。您将看到您新创建的模板已列出,如下所示。
工具栏
以下是模板管理器中的工具栏选项:
默认 - 选择默认模板。
编辑 - 选择要编辑的模板。
复制 - 复制所选模板的副本。
删除 - 删除Joomla的模板。
