Add a column thumbnail

Source: Internet
Author: User

Ecshop template has a lot of imperfections, such as the addition of product classification can not be added to the classification of the chart, can not achieve the effect we want, then the solution?

In fact, we only need to add a small amount of code to implement this function.

1, modify the/admin/template/category_info.html

<tr><td>{$lang. Cat_img}:</td><td><input name= "cat_img" size= "35″type=" file "/>{if $ Cat_info.category_img}{/if}</td></tr>

2. Modify/languages/zh_cn/admin/category.php

Add a language configuration item

$_lang[' cat_img '] = ' category stands for picture 80*134′;

3. Modify the/admin/category.php server to add the code to upload pictures

In Require (DirName (__file__). '/includes/init.php '); next line


Introduction of cls_image.php Image upload class

Include_once (Root_path. ' includes/cls_image.php ');

-----------------------------------------------------------------------------------


Add code under if ($_request[' act ' = = ' Insert ') {

/* Two Development additional category Representative pictures */
$image = new Cls_image ();
$cat [' category_img '] = $image->upload_image ($_files[' cat_img ');

-----------------------------------------------------------------------------------


In if ($_request[' act '] = = ' Update ') {Add code below

/* Two Development additional category Representative pictures */
$image = new Cls_image ();
$image = $image->upload_image ($_files[' cat_img ');
if (!empty ($image)) {
$cat [' category_img '] = $image;
}

4. Next, when we upload the post-editing, we also want to display the newly uploaded image, then we need to modify


function Cat_list (functions in the/includes/lib_common.php)


Append a category_img field when constructing a $sql variable near line 250

$sql = "Select c.cat_id, C.cat_name, C.measure_unit, c.parent_id, C.is_show, C.show_in_nav, C.grade, C.sort_order, COUNT ( s.cat_id) as Has_children,c.category_img ".

5. Don't forget to add a varchar-type category_img field to the Xxx_category table to store the uploaded picture path string

Here's how the front desk shows, find the category.php file under the root. Find Code

function Get_cat_info ($cat _id) {return $GLOBALS [' DB ']->getrow (' SELECT cat_name,category_img, keywords, cat_desc, Style, grade, filter_attr, parent_id from '. $GLOBALS [' ECS ']->table (' category '). " WHERE cat_id = ' $cat _id ' ");}

Plus category_img.

Find the code again

if (!empty ($cat)) {$smarty->assign (' keywords ', htmlspecialchars ($cat [' keywords '])); $smarty->assign (' Description ', Htmlspecialchars ($cat [' Cat_desc ')); $smarty->assign (' Cat_style ', Htmlspecialchars ($cat [' style '] ); $smarty->assign (' CatName ', Htmlspecialchars ($cat [' cat_name ']);//Add $smarty->assign (' categoryimg '), Htmlspecialchars ($cat [' category_img ']);//Add it yourself}

This can be called with {$categoryimg} in the category.dwt template file.

Add a column thumbnail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.