首页 > Zencart > zencart复制网站模板的方法

zencart复制网站模板的方法

首先说明的是,这里只是说明复制网站模板的理论,用于学习用途,复制并使用未经授权的模板是非法的。
第一次写这类说明,没有经验,欢迎大家指正、补充。

这里以zen cart或者osc的模板为例,其他的模板也是同样的方法。

1. 首先在你的模板目录下,建立一个新的模板,例如:\includes\templates\mytemplate\
复制\includes\templates\template_default下的所有目录和文件到新的目录中

2. 用文本编辑器修改\includes\templates\mytemplate\template_info.php,修改其中的名称、版本、作者等内容。

3. 在后台打开新的模板,然后再工具-外观控制中,点击重置

4. 获取网站模板的图片
用整站下载软件实现,例如Teleport Pro,下载全站的所有图形文件,要保留原站的文件结构。
图片通常都在/images目录下,将下载到的/images下的图形文件都复制到zen cart的/images目录下。

5. 获取网站模板的按钮
也可以用Teleport Pro下载所有按钮,通常是英文的,osc的按钮图片在/includes/languages/english/images/buttons目录下。
将下载的按钮保存到zen cart的按钮目录/includes/templates/mytemplate/buttons/english/ 和 /includes/templates/mytemplate/buttons/schinese/ 中,在schinese目录中的按钮,可以自己用图像处理软件转换成中文。

osc模板中,可供下载的按钮有:

http://www.domainname.com/osc/includes/languages/english/images/buttons/button_address_book.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_add_address.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_back.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_buy_now.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_change_address.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_checkout.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_confirm_order.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_continue.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_continue_shopping.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_delete.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_edit_account.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_in_cart.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_login.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_notifications.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_quick_find.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_remove_notifications.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_reviews.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_search.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_shipping_options.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_tell_a_friend.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_update.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_update_cart.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/button_write_review.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/small_delete.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/small_edit.gif
http://www.domainname.com/osc/includes/languages/english/images/buttons/small_view.gif

类似的,zen cart模板的按钮有

http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_add_address.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_back.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_buy_now.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_change_address.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_checkout.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_confirm_order.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_continue.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_continue_shopping.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_delete.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_download.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_in_cart.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_login.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_next.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_ppcheckout.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_prev.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_redeem.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_return_to_product_list.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_reviews.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_search.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_send.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_shipping_estimator.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_sold_out.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_sold_out_sm.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_submit.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_TellAFriend.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_tell_a_friend.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_unsubscribe.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_update.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_update_cart.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/button_write_review.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/small_delete.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/small_edit.gif
http://www.domainname.com/zencart/includes/languages/english/images/buttons/small_view.gif

上面的列表中,自己替换www.domainname.com/osc 或者 http://www.domainname.com/zencart 为你需要复制的网站地址。

6. 获取网站模板的CSS文件。osc的stylesheet.css文件在根目录下。stylesheet.css文件的具体路径在查看页面源代码时能看到。
打开获得的stylesheet.css文件,剪贴到/includes/templates/mytemplate/css/stylesheet.css文件中,追加在原来的css文件后,不要覆盖原有的内容。

7. 打开需要复制的zen cart或者osc网站,查看源代码。(有些网站不允许你查看源代码,要一些技巧,这里就不详细讨论这个问题了)

8. 在源代码中复制
<!– header //–> 到 <!– header_eof //–> 之间的内容作为\includes\templates\mytemplate\common\tpl_header.php,删除该文件内原来的内容。

<!– footer //–> 到 <!– footer_eof //–> 之间的内容作为\includes\templates\mytemplate\common\tpl_footer.php,删除该文件内原来的内容。

(有些模板把边框部分的显示也放到header.php中,那么你需要找出属于边框的部分并删除)

9. 现在,整个网站的外观已经基本出来了。需要替换上面的这两个文件内的链接,这里是模板转换的关键。根据下面的模式替换,第一行是需要替换的类似链接,第二行是正确的代码:
http://www.domainname.com/osc/index.php
<?php echo zen_href_link(FILENAME_DEFAULT); ?>

http://www.domainname.com/osc/account.php
<?php echo zen_href_link(FILENAME_ACCOUNT, ”, ‘SSL’); ?>

http://www.domainname.com/osc/shopping_cart.php
<?php echo zen_href_link(FILENAME_SHOPPING_CART, ”, ‘NONSSL’); ?>

http://www.domainname.com/osc/checkout_shipping.php
<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, ”, ‘SSL’); ?>

http://www.domainname.com/osc/shipping.php
<?php echo zen_href_link(FILENAME_SHIPPING); ?>

http://www.domainname.com/osc/advanced_search.php
<?php echo zen_href_link(FILENAME_ADVANCED_SEARCH); ?>

http://www.domainname.com/osc/products_new.php
<?php echo zen_href_link(FILENAME_PRODUCTS_NEW); ?>

http://www.domainname.com/osc/specials.php
<?php echo zen_href_link(FILENAME_SPECIALS); ?>

http://www.domainname.com/osc/featured_products.php
<?php echo zen_href_link(FILENAME_FEATURED_PRODUCTS); ?>

http://www.domainname.com/osc/products_all.php
<?php echo zen_href_link(FILENAME_PRODUCTS_ALL); ?>

http://www.domainname.com/osc/upcoming_products.php
<?php echo zen_href_link(FILENAME_UPCOMING_PRODUCTS); ?>

http://www.domainname.com/osc/contact_us.php
<?php echo zen_href_link(FILENAME_CONTACT_US); ?>

还有一些必须的代码包括,

用户登录、登出的代码:
<?php if ($_SESSION[‘customer_id’]) { ?>
<a href=”<?php echo zen_href_link(FILENAME_LOGOFF, ”, ‘SSL’); ?>”><?php echo HEADER_TITLE_LOGOFF; ?></a>&amp;nbsp;|&amp;nbsp;
<a href=”<?php echo zen_href_link(FILENAME_ACCOUNT, ”, ‘SSL’); ?>”><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a>
<?php
} else {
if (STORE_STATUS == ‘0’) {
?>
<a href=”<?php echo zen_href_link(FILENAME_LOGIN, ”, ‘SSL’); ?>”><?php echo HEADER_TITLE_LOGIN; ?></a>
<?php } } ?>

货币选择方框的代码:
<?php

if (isset($currencies) && is_object($currencies)) {

reset($currencies->currencies);
$currencies_array = array();
while (list($key, $value) = each($currencies->currencies)) {
$currencies_array[] = array(‘id’ => $key, ‘text’ => $value[‘title’]);
}

$hidden_get_variables = ”;
reset($_GET);
while (list($key, $value) = each($_GET)) {
if ( ($key != ‘currency’) && ($key != zen_session_name()) && ($key != ‘x’) && ($key != ‘y’) ) {
$hidden_get_variables .= zen_draw_hidden_field($key, $value);
}
}
}
$content = zen_draw_form(‘currencies’, zen_href_link(basename(ereg_replace(‘.php’,”, $PHP_SELF)), ”, $request_type, false), ‘get’);
$content .= zen_draw_pull_down_menu(‘currency’, $currencies_array, $_SESSION[‘currency’], ‘onchange=”this.form.submit();” style=”width: 100%”‘) . $hidden_get_variables . zen_hide_session_id();
$content .= ‘</form>’;

echo $content;
?>

语言选择的代码:
<?php
if (!isset($lng) || (isset($lng) && !is_object($lng))) {
$lng = new language;
}
$lng_cnt = 0;
while (list($key, $value) = each($lng->catalog_languages)) {
$content .= ‘<a href=”‘ . zen_href_link($_GET[‘main_page’], zen_get_all_get_params(array(‘language’, ‘currency’)) . ‘language=’ . $key, $request_type) . ‘”>’ . zen_image(DIR_WS_LANGUAGES . $value[‘directory’] . ‘/images/’ . $value[‘image’], $value[‘name’]) . ‘</a>&amp;nbsp;&amp;nbsp;’;
$lng_cnt ++;
if ($lng_cnt >= MAX_LANGUAGE_FLAGS_COLUMNS) {
$lng_cnt = 0;
$content .= ‘<br />’;
}
}
echo $content;
?>

经过以上的替换,tpl_header.php和tpl_footer.php中所有的外部链接都应该替换为你自己的链接了。
如果还有类似 http://www.domainname.com/osc/index.php?cPath=37_28 的链接,这是单个商品的链接,可以删除,或改成你自己的商品链接。

10. 下一步,将tpl_header.php和tpl_footer.php这两个文件中的文字,替换为PHP代码,以支持多语言。如果你只用单一语言,直接修改为你需要的文字即可。例如,
类似 “创建帐号” 改为 <?php echo HEADER_TITLE_CREATE_ACCOUNT; ?>
类似 “商品分类” 改为 <?php echo HEADER_TITLE_CATALOG; ?>
类似 “登出” 改为 <?php echo HEADER_TITLE_LOGOFF; ?>
类似 “我的帐号” 改为 <?php echo HEADER_TITLE_MY_ACCOUNT; ?>
类似 “登录” 改为 <?php echo HEADER_TITLE_LOGIN; ?>

类似 “购物车中的货品” 改为 <?php echo HEADER_TITLE_CART_CONTENTS; ?>
类似 “结帐” 改为 <?php echo HEADER_TITLE_CHECKOUT; ?>

类似”搜索”改为 <?php echo BOX_HEADING_SEARCH; ?>
类似”高级搜索”改为 <?php echo BOX_SEARCH_ADVANCED_SEARCH; ?>

类似 “特价商品” 改为 <?php echo CATEGORIES_BOX_HEADING_SPECIALS; ?>
类似 “新进商品” 改为 <?php echo CATEGORIES_BOX_HEADING_WHATS_NEW; ?>
类似 “推荐商品” 改为 <?php echo CATEGORIES_BOX_HEADING_FEATURED_PRODUCTS; ?>
类似 “所有商品” 改为 <?php echo CATEGORIES_BOX_HEADING_PRODUCTS_ALL; ?>

类似 “联系我们” 改为 <?php echo BOX_INFORMATION_CONTACT; ?>
类似 “货币” 改为 <?php echo BOX_HEADING_CURRENCIES; ?>
类似 “语言” 改为 <?php echo BOX_HEADING_LANGUAGES; ?>

还有一些可能用到的代码:
引文:

<?php echo TEXT_YOUR_IP_ADDRESS . ‘ ‘ . $_SERVER[‘REMOTE_ADDR’]; ?>
<?php echo FOOTER_TEXT_BODY; ?>
<div>Parse Time: <?php echo $parse_time; ?> – Number of Queries: <?php echo $db->queryCount(); ?> – Query Time: <?php echo $db->queryTime(); ?></div>

经过以上的十步操作,基本形成了网站的外观,下面要调整边框的模板了。待续。

——————————————————————————-

补充:sideboxes里的模块随意插入到网页任意位置方法
参考search_header.php的做法:

require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,’common’) . ‘/’ . $column_box_default);

改为
require($template->get_template_dir (‘tpl_box_你自定义的文件名.php’,DIR_WS_TEMPLATE, $current_page_base,’common’). ‘/tpl_box_你自定义的文件名.php’);

在common目录下建立此文件名:tpl_box_你自定义的文件名.php
内容:<?php echo $content; ?>
插入模块时参考写法:<?php require(DIR_WS_MODULES . ‘sideboxes/’ . ‘search_header.php’); ?>

分类:Zencart 标签:,
  1. 还没有评论。
  1. No trackbacks yet.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: