X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Adding new fields to category pages (https://forum.x-cart.com/showthread.php?t=60050)

EvanAgee 07-03-2011 05:56 PM

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?

cflsystems 07-03-2011 07:58 PM

Re: Adding new fields to category pages
 
You can email me, I can help you. Email in signature

dmpinder 07-04-2011 04:25 PM

Re: Adding new fields to category pages
 
Can you share how you achieved this? Thanks

Eyeglasses Expert 08-01-2011 03:30 PM

Re: Adding new fields to category pages
 
would you pls share your method here?

cflsystems 08-01-2011 03:50 PM

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)

Eyeglasses Expert 08-01-2011 03:55 PM

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!

dmpinder 08-02-2011 12:26 AM

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',

sinobest 08-17-2011 03:18 PM

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.


All times are GMT -8. The time now is 09:33 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.