maintenance.tpl.php,Prestashop快速手册

PrestaShop,像所有的PHP脚本语言一样会加载本地服务器上的 index.php 文件。如果你的 Prestashop 商店程序是放在mystore.com,当客户端输入URL : http://www.mystore.com, webserver会自动加载到index 这个页面。

为了了解咋们的Prestashop是如何运行的,我们需要去了解下index文件是如何去工作的。

Index.php

Prestashop index.php文件中包含着以下的代码 :<?php

include(dirname(__FILE__).'/config/config.inc.php');

include(dirname(__FILE__).'/header.php');

$smarty->assign('HOOK_HOME', Module::hookExec('home'));

$smarty->display(_PS_THEME_DIR_.'index.tpl');

include(dirname(__FILE__).'/footer.php');

?>

在 index.php 文件的开始包含着一个 config.inc.php 的文件,这个文件时主要处理我们的主要设置还有一些程序相关其它设置,config.inc.php 会检查是否所有的东西已经安装好了,并且确认了我们的默认模版和默认目录,还有路径、订单的状态还有其它的一些设置。或者现在你已经在抱怨着什么时候才能开始学习到相关的模版制作,现在我们只知道 index.php 中包含了什么而已。

然而,作为一个网页设计者,你可能需要及时地注意到了网页上的错误信息,因此现在就要用到刚才所提到的 config.inc.php 文件了,在这个文件最上面几行,你可以看到:@ini_set('display_errors', 'off');

你可以选择把它打开或关闭

@ini_set('display_errors', 'on');

现在你可以关闭错误信息报告了。不过要注意在下次正式安装前要吧它改回来。

Header.php

下一步,来看看 header.php 的代码:<?php

// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/ compact_policies)

header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

require_once(dirname(__FILE__).'/init.php');

/* CSS */

$css_files[_THEME_CSS_DIR_.'global.css'] = 'all';

/* Hooks are voluntary out the initialize array (need those variables already assigned) */

$smarty->assign(array(

'HOOK_HEADER' => Module::hookExec('header'),

'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'),

'HOOK_TOP' => Module::hookExec('top'),

'static_token' => Tools::getToken(false),

'token' => Tools::getToken(),

'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,

'content_only' => intval(Tools::getValue('content_only'))

));

if(isset($css_files) AND !empty($css_files)) $smarty->assign('css_files', $css_files);

if(isset($js_files) AND !empty($js_files)) $smarty->assign('js_files', $js_files);

/* Display a maintenance page if shop is closed */

if (isset($maintenance) AND (!isset($_SERVER['REMOTE_ADDR']) OR $_SERVER['REMOTE_ADDR'] != Configuration::get('PS_MAINTENANCE_IP')))

{

header('HTTP/1.1 503 temporarily overloaded');

$smarty->display(_PS_THEME_DIR_.'maintenance.tpl');

exit;

}

$smarty->display(_PS_THEME_DIR_.'header.tpl');

?>

接下来我们可以看到这句代码:$smarty->assign('HOOK_HOME', Module::hookExec('home'));

这里将会指定分配hook(我们通常都会第一时间把hook给指定分配了,你也可以指定哪些模块在你网站中出现)$smarty->display(_PS_THEME_DIR_.'index.tpl');

这一行代码是说明 index.tpl 相当于默认主题模版目录的位置(你可以定义或者添加你的主题,backoffice>> preferances>>appearance)

Footer.phpinclude(dirname(__FILE__).'/footer.php');

这一行代码include了我们的 footer.php文件,看下footer.php文件代码:<?php

if (isset($smarty))

{

$smarty->assign(array(

'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'),

'HOOK_FOOTER' => Module::hookExec('footer'),

'content_only' => intval(Tools::getValue('content_only'))));

$smarty->display(_PS_THEME_DIR_.'footer.tpl');

}

?>

尽管我们现在了解到了程序的配置设置,hooks还有不同的php文件包含,但是你会发现,目前为止,还没出现我们所熟悉的HTML代码。其实这个就是我们所有templates(tpl)的来源入口。tpl文件里面包含着HTML还有Smarty模版语言。这些tpl文件大多都在你的模版目录下,有些也在每个功能模块目录下。

现在来看看header.php文件,你会看到里面有这些代码:$css_files[_THEME_CSS_DIR_.'global.css'] = 'all';

if(isset($css_files) AND !empty($css_files)) $smarty->assign('css_files', $css_files);

if(isset($js_files) AND !empty($js_files)) $smarty->assign('js_files', $js_files);

$smarty->display(_PS_THEME_DIR_.'maintenance.tpl'); - Will display a maintenance page called maintenance.tpl if your shop is closed */

$smarty->display(_PS_THEME_DIR_.'header.tpl');

我们的global.css和css、 javascript文件都被包含在这里,html的显示来自于header.tpl文件。

以此类推,index.php 和footer.php也有这对应的index.tpl和footer.tpl(其它的文件也是这样的命名规则)

现在目前看起来好像有点混乱了,不用担心,坚持下去,接下来会变得简单些的。好了,从这里开始打段,总结下:index.php文件包含着header.php,index.tpl和footer.tpl,header.php和 footer.php的tpl文件也分别取自他们本身的文件名。

我们主要的HTML代码都来源于这三个tpl文件。

现在我们来打开header.tpl,index,tpl 还有footer.tpl,这里对于web设计师会相对熟悉点

Header.tpl

{$meta_title|escape:'htmlall':'UTF-8'}

{if isset($meta_description) AND $meta_description}

{/if}

{if isset($meta_keywords) AND $meta_keywords}

{/if}

{if isset($css_files)}

{foreach from=$css_files key=css_uri item=media}

{/foreach}

{/if}

var baseDir = '{$base_dir}';

var static_token = '{$static_token}';

var token = '{$token}';

var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals};

{if isset($js_files)}

{foreach from=$js_files item=js_uri}

{/foreach}

{/if}

{$HOOK_HEADER}

{if !$content_only}

{$HOOK_LEFT_COLUMN}

{/if}

Index.tpl{$HOOK_HOME}

Footer.tpl{if !$content_only}

{$HOOK_RIGHT_COLUMN}

{/if}

现在我们来看看homepage的源文件:

Index.tpl!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Prestashop demo

var baseDir = '/prestashop/';

var static_token = '8d6a4d79d983512d770333775a7d8d24';

var token = '521aacf70fb52a35b4f94e01366c4c64';

var priceDisplayPrecision = 2;

Prestashop demo

可能你会注意到了index.tpl 只有一行{$HOOK_HOME}。这里是因为index文件只在homepage上显示我们所指定的模块,我们的目录还有产品页将会显示其它的模块。

当然,你可能也会发现我们每个页面都有一个不同的body id,方便了我们用css去定义他们单独的每个页面,或许你以后还想在body上加上些class,那么这句是从哪句代码得来的呢?看看 header.tpl,这段代码就是用来实现它的:

id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> and

it is this code that gets the page name.

So category.tpl will have the

相关条目

参考来源

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值