Zencart根据分类加背景图片

Zencart根据分类加背景图片

在我前一个处理的项目中,有个客户要求有变动的头部背景图,在zencart里要怎么去实现这一操作呢? 在我处理的问题中有两种方法,如下:

1. 给body里加一个DIV中CLASS的值,这个CLASS值跟后加添加的分类ID值是一样的,然后用CSS样式去控制头部的背景图。如下图:(not_ID)

2. 在后台的分类编辑里开发出一个上传图片的地方(作为背景图),之后我们根据分类来调用。如下图:

(1)进入数据库,在categories表中加入categories_image_header字符型字段。

(2)在806行的样子加入以下代码:

$contents[] = array(‘text’ => ‘
‘ . TEXT_CATEGORIES_IMAGE_MANUAL . ‘(分类头部图片)’ . zen_draw_input_field(‘categories_image_header’));

$contents[] = array(‘text’ => ‘
‘ . zen_info_image($cInfo->categories_image_header, $cInfo->categories_name));

$contents[] = array(‘text’ => ‘
‘ . $cInfo->categories_image_header);

(3)进入admin/categories.php

在230行左右加上以下代码:

if ($_POST[‘categories_image_header’] != ”) {

// add image manually

$categories_image_header = $_POST[‘img_dir’] . $_POST[‘categories_image_header’];

$db->Execute(“update ” . TABLE_CATEGORIES . ”

set categories_image_header = ‘” . $categories_image_header . “‘

where categories_id = ‘” . (int)$categories_id . “‘”);

}

这是判断是不是有更新的内容,如果没有,不做理会;如果有,则更新。

(4)在admin/includes/modules/category_product_listing.php中的数据查询中加入c.categories_image_header

如下:

if (isset($_GET[‘search’])) {

$search = zen_db_prepare_input($_GET[‘search’]);

$categories = $db->Execute(“select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image,

c.parent_id, c.sort_order, c.date_added, c.last_modified,

c.categories_status, c.categories_image2,c.categories_image3,c.categories_image_header

from ” . TABLE_CATEGORIES . ” c, ” . TABLE_CATEGORIES_DESCRIPTION . ” cd

where c.categories_id = cd.categories_id

and cd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘

and cd.categories_name like ‘%” . zen_db_input($search) . “%'” .

$order_by);

} else {

$categories = $db->Execute(“select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image,

c.parent_id, c.sort_order, c.date_added, c.last_modified,

c.categories_status, c.categories_image2,c.categories_image3,c.categories_image_header

from ” . TABLE_CATEGORIES . ” c, ” . TABLE_CATEGORIES_DESCRIPTION . ” cd

where c.parent_id = ‘” . (int)$current_category_id . “‘

and c.categories_id = cd.categories_id

and cd.language_id = ‘” . (int)$_SESSION[‘languages_id’] . “‘” .

$order_by);

}

即可。 如果您还有什么好的方法,请共享给我,谢谢。

Need a translation service?

Please enter your personal details and we will contact you shortly

Words translated by CCJK

146,096,379

Our Client Satisfaction

Rating for previous quarterr

4.00

Over 95% of our clients recommend our language services to others

Copyright © CCJK Technologies Co., Ltd. 2000-2019. All rights reserved.
TOP