网络营销电子商务研究中心  
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

Reply
 
Thread Tools Display Modes
  #1   IP: 153.99.80.189
Old 2016-08-17, 04:57 PM
Marianna Marianna is offline
初级会员
 
Join Date: 2010-05-10
Posts: 1
Marianna 现在声名狼藉
Default zen-cart开发教程 - 开发Sidebox

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


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



实例: 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 hello_sidebox_img.jpg (61 KB, 1 views)
File Type: jpg hello_sidebox_architecture.jpg (177 KB, 2 views)
Reply With Quote
Reply


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

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


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