ludo.big.youth Posted November 15, 2011 Share Posted November 15, 2011 Hi all. Here is the thing : Under Tools -> CMS, i'm creating a Designers category, and inside this category, i've got a lot of Designer's pages. I would like to add an upload image field, so i can upload a logo for each designer. And i don't want to upload the logo into the rich text editor. Any idea on how to do this ? Have a good day. Ludo Link to comment Share on other sites More sharing options...
dawb Posted April 23, 2012 Share Posted April 23, 2012 Hi, did you have any luck in creating this? Thanks Link to comment Share on other sites More sharing options...
oldlastman Posted November 16, 2012 Share Posted November 16, 2012 I need add custom fields to the cms too it's posible? cms override? there is another free presashop 1.5.x module for news/cms/blog ? thanks Link to comment Share on other sites More sharing options...
CartExpert.net Posted November 16, 2012 Share Posted November 16, 2012 Hi. You can not override that controller, you need to overwrite it. You need to add a new field to $this->fields_form in the function renderForm() and set the $this->fieldImageSettings property in the constructor (also create the folder and table column for it). A good example is AdminCategoriesController.php This should do the trick. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
oldlastman Posted November 17, 2012 Share Posted November 17, 2012 I think it's posible override. because it's working in my locahost first override classes/CMS.php class CMS extends CMSCore { public $yourfield; // <-------------------------------------------------- /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'cms', 'primary' => 'id_cms', 'multilang' => true, 'fields' => array( 'id_cms_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'position' => array('type' => self::TYPE_INT), 'active' => array('type' => self::TYPE_BOOL), // Lang fields '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), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), 'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999), 'yourfield' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999), ),// <-- and your desired properties ); } next override controllers/admin/ <?php class AdminCmsController extends AdminCmsControllerCore { public function renderForm() { $this->display = 'edit'; $this->toolbar_btn['save-and-preview'] = array( 'href' => '#', 'desc' => $this->l('Save and preview') ); $this->initToolbar(); if (!$this->loadObject(true)) return; $categories = CMSCategory::getCategories($this->context->language->id, false); $html_categories = CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($this->object, 'id_cms_category'), 1); $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('CMS Page'), 'image' => '../img/admin/tab-categories.gif' ), 'input' => array( // custom template array( 'type' => 'select_category', 'label' => $this->l('CMS Category'), 'name' => 'id_cms_category', 'options' => array( 'html' => $html_categories, ), ), array( 'type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'id' => 'name', // for copy2friendlyUrl compatibility 'lang' => true, 'required' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'size' => 50 ), array( 'type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'size' => 70 ), array( 'type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'size' => 70, 'desc' => $this->l('To add "tags" click in the field, write something, then press "Enter"') ), array( 'type' => 'text', 'label' => $this->l('Friendly URL'), 'name' => 'link_rewrite', 'required' => true, 'lang' => true, 'hint' => $this->l('Only letters and the minus (-) character are allowed') ), array( 'type' => 'textarea', 'label' => $this->l('Page content'), 'name' => 'content', 'autoload_rte' => true, 'lang' => true, 'rows' => 5, 'cols' => 40, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array(//<------------------------------------------------------------------------- your field 'type' => 'text', 'label' => $this->l('your field'), 'name' => 'yourfield', //<--------------------------------------------------same name as CMS.php ofcourse 'required' => true, 'lang' => true, 'hint' => $this->l('Only letters and the minus (-) character are allowed') ),//<--------------------------------------------------------------------------- end your field array( 'type' => 'radio', 'label' => $this->l('Displayed:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), ), 'submit' => array( 'title' => $this->l(' Save '), 'class' => 'button' ) ); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso', ); } $this->tpl_form_vars = array( 'active' => $this->object->active ); return AdminControllerCore::renderForm();//<----------------------------- Use this... not use parent } } Then you must create the field needed in database in table ps_cms_lang your fieldname (used as variable in CMS.php and controlleradmin) is the name of the field in DB At this moment i don't know how to do this inside php sorry.. you must know how to create db fields and then it's only chage themes/yourtheme/cms.tpl with your new and shining custom fields investigatión cost: 2coffee+ 6 hours + 1/8 brain deceased XD i hope this is usefull for somebody 2 1 Link to comment Share on other sites More sharing options...
CartExpert.net Posted November 19, 2012 Share Posted November 19, 2012 Sorry, wasn't paying attention. Yes, it can be overridden. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now