View Single Post
Old 04-08-2015, 03:58 AM
xgarb xgarb is offline

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:

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

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

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)...
{foreach:getSubcategories(),subcategory} {}<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
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