Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Adding new fields to category pages

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-03-2011, 05:56 PM
 
EvanAgee EvanAgee is offline
 

Newbie
  
Join Date: Jul 2011
Posts: 2
 

Default Adding new fields to category pages

I'm looking to add some additional fields to category pages. I'm wondering if anyone has experience with this and would be willing to do some consulting or offer some assistance?
__________________
X-Cart PRO 4.4
Reply With Quote
  #2  
Old 07-03-2011, 07:58 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Adding new fields to category pages

You can email me, I can help you. Email in signature
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 07-04-2011, 04:25 PM
 
dmpinder dmpinder is offline
 

Advanced Member
  
Join Date: Jun 2009
Posts: 86
 

Default Re: Adding new fields to category pages

Can you share how you achieved this? Thanks
__________________
Darren

X-Cart Gold 4.3.1
Reply With Quote
  #4  
Old 08-01-2011, 03:30 PM
 
Eyeglasses Expert Eyeglasses Expert is offline
 

eXpert
  
Join Date: May 2010
Posts: 307
 

Default Re: Adding new fields to category pages

would you pls share your method here?
Reply With Quote
  #5  
Old 08-01-2011, 03:50 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Adding new fields to category pages

You have to add the field(s) to categories table, modify the admin template to show the new field(s), modify the php script to read/write in the database for the new field(s)
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #6  
Old 08-01-2011, 03:55 PM
 
Eyeglasses Expert Eyeglasses Expert is offline
 

eXpert
  
Join Date: May 2010
Posts: 307
 

Default Re: Adding new fields to category pages

Quote:
Originally Posted by cflsystems
You have to add the field(s) to categories table, modify the admin template to show the new field(s), modify the php script to read/write in the database for the new field(s)

details, and sample code, pls!
Reply With Quote
  #7  
Old 08-02-2011, 12:26 AM
 
dmpinder dmpinder is offline
 

Advanced Member
  
Join Date: Jun 2009
Posts: 86
 

Wink Re: Adding new fields to category pages

Quote:
Originally Posted by Eyeglasses Expert
details, and sample code, pls!

Good news, I figured out how to do this myself, here is my method:



Version: X-Cart Gold 4.4.3

Steps for adding a new column to X-Cart category data

MySQL:
1. To create a new column in the `xcart_categories`, enter the following line into the SQL query box:
Code:
ALTER TABLE `xcart_categories` ADD `new_column` TEXT NOT NULL;

PHP:
2. Add the new column to the "// Prepare an array for further processing" array in \admin\category_modify.php using the following example:
PHP Code:
'new_column'              => $new_column

3. Create a new array for the new column in the $import_specification['CATEGORIES'] array in \include\import_categories.php using the following example:
PHP Code:
"new_column" => array(), 

If you need to set a default value, use the following example:
PHP Code:
"new_column" => array(
        
"default" => "0"), 

If you need to set a type, use the following example:
PHP Code:
"new_column" => array(
        
"type" => "B",
        
"default" => "0"), 

Smarty:
4. In the {$SkinDir}\main\product_details.tpl file add a new row for the new column so it is editable in the Admin area, for example:
HTML Code:
<tr> <td height="10" class="FormButton" nowrap="nowrap">New Column:</td> <td width="10" height="10"><font class="FormButtonOrange"></font></td> <td height="10"> <textarea cols="65" rows="4" name="new_column">{$current_category.new_column}</textarea> </td> </tr>

5. Place the Smarty tag to call the new data anywhere in a category page, using the following code:
HTML Code:
{$current_category.new_column}

NOTE: You may need to force a cache regeneration if you get an X-Cart SQL error (code 79). It will say there is a mis-match between sent data and database table structure, however this is usually a cache issue. Visit yoursite.com/cleanup.php and/or use "Force Cache Regeneration" in the Maintenance section of the admin area. This usually fixes the error. If not, double check your database structure.

NOTE: If the field you are creating will contain HTML tags, you need to include this new column into a "trusted post variables" array. You do this in \admin\category_modify.php
Inside: $trusted_post_variables = array('
Include: 'new_column',
__________________
Darren

X-Cart Gold 4.3.1
Reply With Quote

The following user thanks dmpinder for this useful post:
am2003 (08-18-2011)
  #8  
Old 08-17-2011, 03:18 PM
 
sinobest sinobest is offline
 

X-Adept
  
Join Date: Nov 2009
Posts: 462
 

Default Re: Adding new fields to category pages

Quote:
If you need to set a default value, use the following example:

i do not understand this, i have tried this, did not find any difference.
__________________
X-Cart Version: 4.7.12 GOLD
www.cheapglasses123.com prescription glasses online at discounted prices.
prescriptionglassesusa.com
www.loupesusa.com X-Cart Version: 4.7.11 GOLD PLUS
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:26 PM.

   

 
X-Cart forums © 2001-2020