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

x5 New 'Short Description' Field in Categories - Solution and Question...
 
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 04-08-2015, 03:58 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 262
 

Default x5 New 'Short Description' Field in Categories - Solution and Question...

Using the example here as a guide: http://kb.x-cart.com/display/XDD/Adding+new+property+to+a+product

I've added a new field to the category admin screen to add short descriptions.

My code looks like this:

In XLite/Module/Client/ClientCatsShortDescriptions/Model/CategoryTranslation.php

Code:
namespace XLite\Module\Client\ClientCatsShortDescriptions\Model; class CategoryTranslation extends \XLite\Model\CategoryTranslation implements \XLite\Base\IDecorator { /** * @Column (type="string", length=255) */ protected $shortDescr; }

In XLite/Module/Client/ClientCatsShortDescriptions/View/Model/Category.php

Code:
namespace XLite\Module\Client\ClientCatsShortDescriptions\View\Model; class Category extends \XLite\View\Model\Category implements \XLite\Base\IDecorator { public function __construct(array $params = array(), array $sections = array()) { parent::__construct($params, $sections); $this->schemaDefault += array ( 'shortDescr' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Textarea\Advanced', self::SCHEMA_LABEL => 'Short Description', self::SCHEMA_REQUIRED => false, ), ); } }

in my template listing the categories (cut down for clarity)...
Code:
{foreach:getSubcategories(),subcategory} {subcategory.name}<br> {subcategory.shortdescr:h} {end:}

So this works very nicely except in admin the form field for entering the short descriptions is at the bottom of the page.

How can I move it to be above the normal description box?

I tried
Code:
ALTER TABLE `xc_category_translations` MODIFY `shortDescr` VARCHAR(255) AFTER `name`
in the database but it doesn't have any effect.

I guess it's something to do with the module being called last on the page?
__________________
Core version: 5.3.xx
PHP: 5.6
MySQL: 5.5.50-cll
Web server: Apache
Reply With Quote
  #2  
Old 04-08-2015, 01:27 PM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,430
 

Default Re: x5 New 'Short Description' Field in Categories - Solution and Question...

In your __construct() class you must reorganize the schemaDefault array and put your shortDescr field right above usual Description field instead of adding it to the bottom of the array.

Please, let me know if it makes sense to you.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 04-09-2015, 12:21 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 262
 

Default Re: x5 New 'Short Description' Field in Categories - Solution and Question...

Ah.. I did this...

In XLite/Module/Client/ClientCatsShortDescriptions/View/Model/Category.php now I have

Code:
namespace XLite\Module\Client\ClientCatsShortDescriptions\View\Model; class Category extends \XLite\View\Model\Category implements \XLite\Base\IDecorator { public function __construct(array $params = array(), array $sections = array()) { parent::__construct($params, $sections); $this->schemaDefault = array ( 'name' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', self::SCHEMA_LABEL => 'Category name', self::SCHEMA_REQUIRED => true, ), 'show_title' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Select\CategoryShowTitle', self::SCHEMA_LABEL => 'Show Category title', self::SCHEMA_REQUIRED => false, ), 'image' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\FileUploader\Image', self::SCHEMA_LABEL => 'Category icon', self::SCHEMA_REQUIRED => false, ), 'shortDescr' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Textarea\Advanced', self::SCHEMA_LABEL => 'Short Description', self::SCHEMA_REQUIRED => false, ), 'description' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Textarea\Advanced', self::SCHEMA_LABEL => 'Description', self::SCHEMA_REQUIRED => false, \XLite\View\FormField\Textarea\Advanced::PARAM_STYLE => 'category-description', ), 'cleanURL' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text\CleanURL', self::SCHEMA_LABEL => 'Clean URL', self::SCHEMA_REQUIRED => false, \XLite\View\FormField\Input\Text\CleanURL::PARAM_OBJECT_CLASS_NAME => '\XLite\Model\Category' ), 'meta_title' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', self::SCHEMA_LABEL => 'Custom HTML title', self::SCHEMA_HELP => 'Leave the field empty to autogenerate a value for the HTML title tag', self::SCHEMA_REQUIRED => false, ), 'meta_tags' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', self::SCHEMA_LABEL => 'Meta tags', self::SCHEMA_REQUIRED => false, ), 'meta_desc' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Textarea\Simple', self::SCHEMA_LABEL => 'Meta desc', self::SCHEMA_REQUIRED => false, ), 'memberships' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Select\Memberships', self::SCHEMA_LABEL => 'Memberships', self::SCHEMA_REQUIRED => false, ), 'enabled' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Checkbox\Enabled', self::SCHEMA_LABEL => 'Enabled', self::SCHEMA_REQUIRED => false, ), ); } }

Seems to work.

Cool!
__________________
Core version: 5.3.xx
PHP: 5.6
MySQL: 5.5.50-cll
Web server: Apache
Reply With Quote
  #4  
Old 08-07-2015, 01:40 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 262
 

Default Re: x5 New 'Short Description' Field in Categories - Solution and Question...

UPDATE

For 5.2.6 function method needs to look like this...

Code:
public function __construct(array $params = array(), array $sections = array()) { parent::__construct($params, $sections); $this->schemaDefault = array( 'name' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', self::SCHEMA_LABEL => 'Category name', self::SCHEMA_REQUIRED => true, ), 'parent' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Select\Category', self::SCHEMA_LABEL => 'Parent category', self::SCHEMA_REQUIRED => true, ), 'show_title' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Select\CategoryShowTitle', self::SCHEMA_LABEL => 'Show Category title', self::SCHEMA_REQUIRED => false, ), 'image' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\FileUploader\Image', self::SCHEMA_LABEL => 'Category icon', self::SCHEMA_REQUIRED => false, ), 'shortDescr' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Textarea\Advanced', self::SCHEMA_LABEL => 'Short Description', self::SCHEMA_REQUIRED => false, ), 'description' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Textarea\Advanced', self::SCHEMA_LABEL => 'Description', self::SCHEMA_REQUIRED => false, \XLite\View\FormField\Textarea\Advanced::PARAM_STYLE => 'category-description', ), 'cleanURL' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text\CleanURL', self::SCHEMA_LABEL => 'Clean URL', self::SCHEMA_REQUIRED => false, \XLite\View\FormField\AFormField::PARAM_LABEL_HELP => 'Human readable and SEO friendly web address for the page.', \XLite\View\FormField\Input\Text\CleanURL::PARAM_OBJECT_CLASS_NAME => 'XLite\Model\Category' ), 'meta_title' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', self::SCHEMA_LABEL => 'Category page title', self::SCHEMA_REQUIRED => false, self::SCHEMA_COMMENT => 'Leave blank to use category name as Page Title.', ), 'meta_tags' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', self::SCHEMA_LABEL => 'Meta keywords', self::SCHEMA_REQUIRED => false, ), 'meta_desc_type' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Select\MetaDescriptionType', self::SCHEMA_LABEL => 'Meta description', self::SCHEMA_REQUIRED => false, ), 'meta_desc' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Textarea\Simple', self::SCHEMA_LABEL => '', \XLite\View\FormField\AFormField::PARAM_USE_COLON => false, self::SCHEMA_REQUIRED => false, self::SCHEMA_DEPENDENCY => array( self::DEPENDENCY_SHOW => array ( 'meta_desc_type' => array('C'), ) ), ), 'memberships' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Select\Memberships', self::SCHEMA_LABEL => 'Memberships', self::SCHEMA_REQUIRED => false, ), 'enabled' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Checkbox\Enabled', self::SCHEMA_LABEL => 'Enabled', self::SCHEMA_REQUIRED => false, ), ); }
__________________
Core version: 5.3.xx
PHP: 5.6
MySQL: 5.5.50-cll
Web server: Apache
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may 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:48 AM.

   

 
X-Cart forums © 2001-2020