JA文档中文翻译 - JA模板定制FAQ - 创建布局变体

thumb-ja-documentation在前面一篇文档教程中,我们学习了有关定制模板默认布局中的区块及模块位定义的知识,今天来看看怎样创建布局变体。有关Purity II模板自带的布局变体,可以参见“JA文档中文翻译 - JA模板框架指南 - Purity II模板的布局变体”回顾一下先。

我们将基于之前创建的默认布局文件shop.php来创建两个新的布局:

blog.php:通过复制shop.php文件中的代码并粘贴到新的空白文件中来创建以下区块将需要进行调整:

  • head-blog.php - 这是我们需要创建的新区块,其中会调用一些指定的样式表及JavaScript文件。
  • header.php
  • mainnav.php
  • main.php
  • right-xhtml.php
  • botsl.php
  • footer.php

news.php:通过复制shop.php文件中的代码并粘贴到新的空白文件中来创建;以下区块将需要进行调整:

  • head-news.php - 这是我们需要创建的新区块,其中会调用一些指定的样式表及JavaScript文件。
  • header.php
  • topsl.php
  • mainnav.php
  • main.php
  • left.php
  • botsl.php
  • footer.php

首先来看下blog.php的代码;将区块声明部分的代码调整为:

$positions = array (
'left1' =>'',
'left2' =>'',
'left-mass-top' =>'',
'left-mass-bottom' =>'',
'right1' =>'right',
'right2' =>'',
'right-mass-top' =>'',
'right-mass-bottom' =>'',
'content-mass-top' =>'',
'content-mass-bottom' =>'',
'content-top' =>'',
'content-bottom' =>'',
'inset1' =>'',
'inset2' =>''
);

接下来是<head>部分,将代码调整为:

<head>
<?php $this->loadBlock('head-blog') ?>
</head>

由于该布局不需要topsl区块位置,所以删除62行附近的:

<?php $this->loadBlock('topsl') ?>

同理,删除70行附近的:

<?php $this->loadBlock('left') ?>

并将调用右侧边栏区块的代码修改为:

<?php $this->loadBlock('right-xhtml') ?>

搞定;再来看news.php文件,将区块声明部分的代码调整为:

$positions = array (
'left1' =>'left',
'left2' =>'',
'left-mass-top' =>'',
'left-mass-bottom' =>'',
'right1' =>'',
'right2' =>'',
'right-mass-top' =>'',
'right-mass-bottom' =>'',
'content-mass-top' =>'',
'content-mass-bottom' =>'',
'content-top' =>'',
'content-bottom' =>'',
'inset1' =>'',
'inset2' =>''
);

接下来是<head>部分,将代码调整为:

<head>
<?php $this->loadBlock('head-news') ?>
</head>

将62行附近的:

<?php $this->loadBlock('topsl') ?>

与mainnav的调用代码对调,成为:

<?php $this->loadBlock('topsl') ?>
 
<!-- MAIN NAVIGATION -->
<?php $this->loadBlock('mainnav') ?>
<!-- //MAIN NAVIGATION -->

由于该布局不需要right区块位置,所以删除73行附近的:

<?php $this->loadBlock('right') ?>

搞定。现在我们可以打开layout/blocks文件夹,删除掉我们并不需要的“joomla”文件夹以及left-rounded.php、main-rounded.php、right.php这三个区块文件。

在同文件夹下,创建两个新的区块文件:head-blog.phphead-news.php,并将head.php中的代码复制粘贴到两个新文件中。

现在,定制模板的布局及区块结构应该是这样的:

purity-ii-new-layout-structure

定制模板的布局及区块结构就是这样了,接下来的几篇文档中,我们将重点学习一下模板样式方面的设定

译者:Viiiix7210

如需转载,请注明官方英文文档及本人译文的出处,谢谢。查看官方英文文档: JA Template Framework/FAQs


收藏与分享