网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > ZenCart
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 49.87.187.58
Old 2016-04-11, 09:35 AM
Amanda Park Amanda Park is offline
初级会员
 
Join Date: 2012-05-11
Posts: 1
Amanda Park 现在声名狼藉
Default zen-cart开发教程 - 开发Sidebox插件

首先需要搞清楚什么是Sidebox,Sidebox是一个显示在左侧或者右侧的内容区域,当然你也可以将Sidebox的单栏状态打开,使其显示在网页的任何位置。你可以通过进入后台的Tools/Layout Boxes Controller来进行Sidebox的设置。注意的是如果开启了单栏Sidebox的话,你必须通过一句代码手动将其显示到模板中去,否则你是看不到任何效果的。zen-cart中自带了很多Sidebox, 例如显示产品分类的Sidebox, 显示最新产品的Sidebox, 选择语言的Sidebox等等。
1.Sidebox相关的文件和目录

输出左侧sidebox的文件:/includes/modules/column_left.php

输出右侧侧sidebox的文件:/includes/modules/column_right.php

输出单栏sidebox的文件:/includes/modules/column_single.php



存储sidebox的位置:/includes/modules/sideboxes

Sidebox模版位置:/includes/templates/template_default/sideboxes



默认左侧sidebox模版/includes/templates/template_default/common/tpl_box_default_left.php

默认右侧sidebox模版:/includes/templates/template_default/common/tpl_box_default_right.php

默认单栏sidebox模版:/includes/templates/template_default/common/ tpl_box_default_single.php


2.实例: hello_sidebox的开发
下面我们来开发一个简单的sidebox,以说明开发一个Sidebox的基本步骤,该sidebox只显示一段文字,并不实现任何功能, 我们将这个 sizebox命名为 hello_sidebox。
1). 设置语言和要在sidebox中显示的内容
在目录” /includes/languages/english/extra_definitions”新建一个PHP文件,命名为” hello_sidebox.php”, 并设置英语环境下sidebox的Title和要显示的内容。该文件中定义了两个常量BOX_HEADING_HELLOW_SIDEBOX(sidebox的标题), 'BOX_HEADING_HELLOW_SIDEBOX_CONTENT(显示的内容),代码如下


define(BOX_HEADING_HELLOW_SIDEBOX, "Hello sidebox");
define(BOX_HEADING_HELLOW_SIDEBOX_CONTENT, "This is a sidebox demo");


2). 新建sidebox文件
在目录”/includes/modules/sideboxes”下面新建一个 文件, 命名为” hello_sidebox.php”, 并输入以下代码, 其中第一行加载了hello_sidebox的模板文件, 第二行设置了sidebox的标题, 第三行代码加载了用来输出sidebox的模板文件.



require($template->get_template_dir('tpl_wp_cats.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_hello_sidebox.php');
$title = BOX_HEADING_HELLOW_SIDEBOX;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);



3). 新建sidebox模版文件
sidebox模板文件实际上并不会输出任何内容到网页上面, 这里只是构造了要在Sidebox内部显示的内容(变量$content). 这里, 我们的内容仅仅是将常量BOX_HEADING_HELLOW_SIDEBOX_CONTENT的值赋给$content,代码如下.


$content = "";
$content .= BOX_HEADING_HELLOW_SIDEBOX_CONTENT;


4). 安装sidebox


进入管理后台>>Tools>>Layout Boxes Controller, 就可以看到我们刚才开发的hello_sidebox插件了, 选中hello_sidebox, 点击编辑按钮, 将Left/Right Column Status设置为on, 再点击Update按钮, 这样安装过程就完成了. 现在再刷新一下首页, 是不是就能看到我们的hello_sidebox盒子了呢?


5). 发布sidebox

将刚才的文件按照原始的目录结构进行打包, 如下图所示, 就算发布成功了. 这样就可以把我们开发好的插件共享给别人使用了.


怎么样,很简单吧。该示例虽然很简单,却也涵盖了开发Sidebox的基本步骤,有了这些基础,你可以开发出更多复杂的应用。
Attached Images
File Type: jpg 2.jpg (730 KB, 1 views)

Last edited by Amanda Park : 2016-04-11 at 09:40 AM
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
开发Sidebox插件 topvip ZenCart 0 2012-12-21 07:30 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 03:04 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.