使用Textmate开发Joomla模板
用到的Bundles有Zen Coding,960gs,joomla1.5,Zen CSS和Zen Html,使用这些可以使你的开发速度提高n个档次,基本上是成倍的效率往上翻。 首先,textmate只有Mac的版本且安装以上的Bundles,本文的快捷键只在Mac下有效,特此声明(主要是针对index.php)。
按住command+option+h,选择编辑模式为zen html,输入jhead,然后按tab键,就会出现以下code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="templates/<?php echo $this->template ?>/css/template.css" type="text/css" />
</head>
<body>
</body>
</html>
该模板我们采用960gs开发,且此处我们使用的是12cols进行开发,在之后,输入c12,然后tab,就会出现相应的code,
<div class="container_12" id="name">
</div>
<div class="container_12" id="name">
<div class="grid_4">
one
</div>
<div class="grid_4">
two
</div>
<div class="grid_4">
three
</div>
</div>
接下来我们继续讲插入module的方法,很简单,选择你要插入module的地方,module,然后tab,出现两个选项,1为判断位置是否存在的code,2为位置的code,此处我们插入的是module的位置,所以选择2,对应的code应该是:
<?php if($this->countModules('left')) : ?>
<jdoc:include type="modules" name="left" style="XHTML" />
<?php endif; ?>
Joomla模板里面的content的插入方法是,content,然后tab,这样就可以了
<jdoc:include type="component" />
其他的还有jText之类的其他的,以后继续解释,下面贴了一个模板的code,仅供参考,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<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" />
<?php
if($this->countModules('left and right') == 0) $content = "12";
if($this->countModules('left or right') == 1) $content = "8";
if($this->countModules('left and right') == 1) $content = "4";
?>
</head>
<body>
<div id="corner"></div>
<div id="wrapper">
<div class="container_12" id="header">
<div class="grid_4 logo">
<?php if($this->countModules('logo')) : ?>
<jdoc:include type="modules" name="logo" style="raw" />
<?php endif; ?>
</div>
<div class="grid_8">
<?php if($this->countModules('search')) : ?>
<div class="topsearch">
<jdoc:include type="modules" name="search" style="raw" />
</div>
<?php endif; ?>
</div>
</div>
<div class="container_12" id="mainmenu">
<?php if($this->countModules('mainmenu')) : ?>
<jdoc:include type="modules" name="mainmenu" style="raw" />
<?php endif; ?>
</div>
<div class="container_12" id="content">
<?php if($this->countModules('left')) : ?>
<div class="grid_4 left">
<jdoc:include type="modules" name="left" style="raw" />
</div>
<?php endif; ?>
<div class="grid_<?php echo $content ?> content">
<jdoc:include type="component" />
</div>
<?php if($this->countModules('right')) : ?>
<div class="grid_4">
<jdoc:include type="modules" name="right" style="raw" />
</div>
<?php endif; ?>
</div>
<div class="container_12" id="advert">
<div class="grid_4 advert1">
<?php if($this->countModules('advert1')) : ?>
<jdoc:include type="modules" name="advert1" style="raw" />
<?php endif; ?>
</div>
<div class="grid_4 advert2">
<?php if($this->countModules('advert2')) : ?>
<jdoc:include type="modules" name="advert2" style="raw" />
<?php endif; ?>
</div>
<div class="grid_4 advert3">
<?php if($this->countModules('advert3')) : ?>
<jdoc:include type="modules" name="advert3" style="raw" />
<?php endif; ?>
</div>
</div>
<div class="container_12" id="user">
<div class="grid_3">
<?php if($this->countModules('user1')) : ?>
<jdoc:include type="modules" name="user1" style="raw" />
<?php endif; ?>
</div>
<div class="grid_3">
<?php if($this->countModules('user2')) : ?>
<jdoc:include type="modules" name="user2" style="raw" />
<?php endif; ?>
</div>
<div class="grid_3">
<?php if($this->countModules('user3')) : ?>
<jdoc:include type="modules" name="user3" style="raw" />
<?php endif; ?>
</div>
<div class="grid_3">
<?php if($this->countModules('user4')) : ?>
<jdoc:include type="modules" name="user4" style="raw" />
<?php endif; ?>
</div>
</div>
</div>
<div class="container_12" id="footer">
<?php if($this->countModules('footer')) : ?>
<jdoc:include type="modules" name="footer" style="raw" />
<?php endif; ?>
</div>
<div class="container_12" id="copyright">
<?php if($this->countModules('copyright')) : ?>
<jdoc:include type="modules" name="copyright" style="raw" />
<?php endif; ?>
</div>
</body>
</html>
<?php
if($this->countModules('left and right') == 0) $content = "12";
if($this->countModules('left or right') == 1) $content = "8";
if($this->countModules('left and right') == 1) $content = "4";
?>
templateDetails.xml这个文件也可以通过textmate去生成,编辑模式调成xml,然后templatexml,然后tab就可以了,按照你的需求,进行编辑,就可以了。
阅读其他美文