Jump to content

how to add extra textbox to category and subcategory page?


q-skins.dk

Recommended Posts

 

Hi all. 

 

I am trying to improve my online shop. What i want to do is to add an extra textfield like the one you have at the top on category and subcategory pages. I would like to add some at the bottom of the category and subcategory page. Does anybody know how to do that or which html file to place the code for the text box?

 

 

Thanks in advance. 

Link to comment
Share on other sites

in this case you have to extend category object.

 

 

1) create new field in ps_category_lang table, use name "second_desc"

c4Kd9nN.png

 

2) edit Category.php class (classes/Category.php)

in object definition add 'second_desc' field:

 

public static $definition = array(
'table' => 'category',
'primary' => 'id_category',
'multilang' => true,
'multilang_shop' => true,
'fields' => array(
'nleft' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'nright' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'level_depth' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'is_root_category' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'position' => array('type' => self::TYPE_INT),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
 
// Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
'second_desc' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
),
);
 
and add new field in __construct function:
...
/** @var boolean Status for display */
public $active = 1;
/** @var  integer category position */
public $position;
/** @var string Description */
public $description;
public $second_desc;
/** @var integer Parent category ID */
public $id_parent;
/** @var integer default Category id */
public $id_category_default;

...

 

3) add field to field list definition in AdminCategoriesController (controllers/admin/AdminCategoriesController)

array(
'type' => 'textarea',
'label' => $this->l('Description:'),
'name' => 'description',
'autoload_rte' => true,
'lang' => true,
'rows' => 10,
'cols' => 100,
'hint' => $this->l('Invalid characters:').' <>;=#{}'
),
array(
'type' => 'textarea',
'label' => $this->l('Second Description:'),
'name' => 'second_desc',
'autoload_rte' => true,
'lang' => true,
'rows' => 10,
'cols' => 100,
'hint' => $this->l('Invalid characters:').' <>;=#{}'
),
array(
'type' => 'file',
'label' => $this->l('Image:'),
'name' => 'image',
'display_image' => true,
'desc' => $this->l('Upload a category logo from your computer.')
),
 
 
effect: category edit page with new field:
xpjsgWY.png
 
 
 
then just use {$second_desc} variable in category.tpl file
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...