<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; editor</title>
	<atom:link href="http://nemops.com/tag/editor/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>Adding the visual editor to Category Description</title>
		<link>http://nemops.com/visual-editor-to-category-description/</link>
		<comments>http://nemops.com/visual-editor-to-category-description/#comments</comments>
		<pubDate>Wed, 17 Jul 2013 09:57:37 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[prestashop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1415</guid>
		<description><![CDATA[<p>In this video and written quick tip, we will see how to add a visual editor to the category description in Presashop. The proper way, of course, so that changes will not be killed with the next Prestashop Upgrade! Watch The Screencast (text below) &#160; &#160; Adding the visual editor to category description the proper [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/visual-editor-to-category-description/">Adding the visual editor to Category Description</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this video and written quick tip, we will see how to add a visual editor to the category description in Presashop. The proper way, of course, so that changes will not be killed with the next Prestashop Upgrade!</p>
<p><span id="more-1415"></span></p>
<a class="download-files button style1" href="http://nemops.com/wp-content/uploads/2013/07/AdminCategoriesController.zip" title="Download Project Files">Download Project Files</a>
<h2>Watch The Screencast (text below)</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/UZLHhr0DanM" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<div class="separator"></div>
<p>&nbsp;</p>
<h2>Adding the visual editor to category description the proper way</h2>
<p>Open up your Prestashop root folder, then navigate to <em>controllers/admin</em> and open <strong>AdminCategorisController.php</strong> in your favorite code editor.</p>
<p>Locate the <strong>renderForm</strong> method, at about line 321 (Prestashop 1.5.4.0). Inside it, locate the following snippet</p>
<pre class="brush: php; title: ; notranslate">
				array(
					'type' =&gt; 'textarea',
					'label' =&gt; $this-&gt;l('Description:'),
					'name' =&gt; 'description',
					'lang' =&gt; true,
					'rows' =&gt; 10,
					'cols' =&gt; 100,
					'hint' =&gt; $this-&gt;l('Invalid characters:').' &lt;&gt;;=#{}',
				),
</pre>
<p>Change so it looks like this:</p>
<pre class="brush: php; title: ; notranslate">
				array(
					'type' =&gt; 'textarea',
					'label' =&gt; $this-&gt;l('Description:'),
					'name' =&gt; 'description',
					'lang' =&gt; true,
					'rows' =&gt; 10,
					'cols' =&gt; 100,
					'hint' =&gt; $this-&gt;l('Invalid characters:').' &lt;&gt;;=#{}',
					'autoload_rte' =&gt; true
				),
</pre>
<p>As you can see <strong>we have added &#8216;autoload_rte&#8217; => true</strong>. This enables the visual editor. Save and access a category page in the back office to see the visual editor.</p>
<p>However, this way your changes will inevitably be overrridden at the next prestashop update you do. We need to use an <strong>override</strong>.</p>
<h3>Using an override for the controller</h3>
<p>Back to your prestashop root, go to <em>override/controllers/admin</em> and create a file called <strong>AdminCategorisController.php</strong>. Paste the following snippet inside</p>
<p>Change so it looks like this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

Class AdminCategoriesController extends AdminCategoriesControllerCore
{

?&gt;
</pre>
<p><strong>Note:</strong> We are extending a prestashop class (controller in this case). If you want to know more about this, head over <a href="http://doc.prestashop.com/display/PS15/Overriding+default+behaviors#Overridingdefaultbehaviors-OverridingPrestaShop'sclassesandcontrollers" title="Overriding Classes and Controllers in Prestashop">here</a>.</p>
<p>In the <strong>original</strong> AdminCategoriesController, copy the whole renderForm function we just modified, and paste it inside our new override.</p>
<p>Okay, at this point you might notice that the method is calling <strong>parent::renderForm();</strong> at the end, right before the closing bracket. Therefore, change the following line</p>
<pre class="brush: php; title: ; notranslate">
return parent::renderForm();
</pre>
<p>to</p>
<pre class="brush: php; title: ; notranslate">
return AdminController::renderForm();
</pre>
<p><strong>Tip:</strong> if we didn&#8217;t do this, the original one would have overridden this one no matter what, and no changes would have taken place</p>
<p>Lastly, head over to the root folder again then <em>cache/</em> and delete the <strong>class_index.php</strong> file, so that our changes take place. At this point, you can also restore the original adminCategoriesController to its defaults, since we are extending it in a maintainable way.</p>
<p>Here is the complete override (you can download it as a project file)</p>
<p>&#8230;And! if you would like more freedom with the visual editor, or simply <strong>the possibility to add html / javascript / css content everywhere in Prestashop/s front office</strong>, have a look at my module <a href="http://store.nemops.com/modules/28-html-block.html">HTML Block!</a></p>
<pre class="brush: php; title: ; notranslate">

&lt;?php

Class AdminCategoriesController extends AdminCategoriesControllerCore
{
	public function renderForm()
	{
		$this-&gt;initToolbar();
		$obj = $this-&gt;loadObject(true);
		$id_shop = Context::getContext()-&gt;shop-&gt;id;
		$selected_cat = array((isset($obj-&gt;id_parent) &amp;&amp; $obj-&gt;isParentCategoryAvailable($id_shop))? (int)$obj-&gt;id_parent : (int)Tools::getValue('id_parent', Category::getRootCategory()-&gt;id));
		$unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP'));
		$guest = new Group(Configuration::get('PS_GUEST_GROUP'));
		$default = new Group(Configuration::get('PS_CUSTOMER_GROUP'));

		$unidentified_group_information = sprintf($this-&gt;l('%s - All people without a valid customer account.'), '&lt;b&gt;'.$unidentified-&gt;name[$this-&gt;context-&gt;language-&gt;id].'&lt;/b&gt;');
		$guest_group_information = sprintf($this-&gt;l('%s - Customer who placed an order with the guest checkout.'), '&lt;b&gt;'.$guest-&gt;name[$this-&gt;context-&gt;language-&gt;id].'&lt;/b&gt;');
		$default_group_information = sprintf($this-&gt;l('%s - All people who have created an account on this site.'), '&lt;b&gt;'.$default-&gt;name[$this-&gt;context-&gt;language-&gt;id].'&lt;/b&gt;');
		$root_category = Category::getRootCategory();
		$root_category = array('id_category' =&gt; $root_category-&gt;id, 'name' =&gt; $root_category-&gt;name);
		$this-&gt;fields_form = array(
			'tinymce' =&gt; true,
			'legend' =&gt; array(
				'title' =&gt; $this-&gt;l('Category'),
				'image' =&gt; '../img/admin/tab-categories.gif'
			),
			'input' =&gt; array(
				array(
					'type' =&gt; 'text',
					'label' =&gt; $this-&gt;l('Name:'),
					'name' =&gt; 'name',
					'lang' =&gt; true,
					'size' =&gt; 48,
					'required' =&gt; true,
					'class' =&gt; 'copy2friendlyUrl',
					'hint' =&gt; $this-&gt;l('Invalid characters:').' &lt;&gt;;=#{}',
				),
				array(
					'type' =&gt; 'radio',
					'label' =&gt; $this-&gt;l('Displayed:'),
					'name' =&gt; 'active',
					'required' =&gt; false,
					'class' =&gt; 't',
					'is_bool' =&gt; true,
					'values' =&gt; array(
						array(
							'id' =&gt; 'active_on',
							'value' =&gt; 1,
							'label' =&gt; $this-&gt;l('Enabled')
						),
						array(
							'id' =&gt; 'active_off',
							'value' =&gt; 0,
							'label' =&gt; $this-&gt;l('Disabled')
						)
					)
				),
				array(
					'type' =&gt; 'categories',
					'label' =&gt; $this-&gt;l('Parent category:'),
					'name' =&gt; 'id_parent',
					'values' =&gt; array(
						'trads' =&gt; array(
							 'Root' =&gt; $root_category,
							 'selected' =&gt; $this-&gt;l('Selected'),
							 'Collapse All' =&gt; $this-&gt;l('Collapse All'),
							 'Expand All' =&gt; $this-&gt;l('Expand All')
						),
						'selected_cat' =&gt; $selected_cat,
						'input_name' =&gt; 'id_parent',
						'use_radio' =&gt; true,
						'use_search' =&gt; false,
						'disabled_categories' =&gt; array(4),
						'top_category' =&gt; Category::getTopCategory(),
						'use_context' =&gt; true,
					)
				),
				array(
					'type' =&gt; 'radio',
					'label' =&gt; $this-&gt;l('Root Category:'),
					'name' =&gt; 'is_root_category',
					'required' =&gt; false,
					'is_bool' =&gt; true,
					'class' =&gt; 't',
					'values' =&gt; array(
						array(
							'id' =&gt; 'is_root_on',
							'value' =&gt; 1,
							'label' =&gt; $this-&gt;l('Yes')
						),
						array(
							'id' =&gt; 'is_root_off',
							'value' =&gt; 0,
							'label' =&gt; $this-&gt;l('No')
						)
					)
				),
				array(
					'type' =&gt; 'textarea',
					'label' =&gt; $this-&gt;l('Description:'),
					'name' =&gt; 'description',
					'lang' =&gt; true,
					'rows' =&gt; 10,
					'cols' =&gt; 100,
					'hint' =&gt; $this-&gt;l('Invalid characters:').' &lt;&gt;;=#{}',
					'autoload_rte' =&gt; true
				),
				array(
					'type' =&gt; 'file',
					'label' =&gt; $this-&gt;l('Image:'),
					'name' =&gt; 'image',
					'display_image' =&gt; true,
					'desc' =&gt; $this-&gt;l('Upload a category logo from your computer.')
				),
				array(
					'type' =&gt; 'text',
					'label' =&gt; $this-&gt;l('Meta title:'),
					'name' =&gt; 'meta_title',
					'lang' =&gt; true,
					'hint' =&gt; $this-&gt;l('Forbidden characters:').' &lt;&gt;;=#{}'
				),
				array(
					'type' =&gt; 'text',
					'label' =&gt; $this-&gt;l('Meta description:'),
					'name' =&gt; 'meta_description',
					'lang' =&gt; true,
					'hint' =&gt; $this-&gt;l('Forbidden characters:').' &lt;&gt;;=#{}'
				),
				array(
					'type' =&gt; 'tags',
					'label' =&gt; $this-&gt;l('Meta keywords:'),
					'name' =&gt; 'meta_keywords',
					'lang' =&gt; true,
					'hint' =&gt; $this-&gt;l('Forbidden characters:').' &lt;&gt;;=#{}',
					'desc' =&gt; $this-&gt;l('To add &quot;tags,&quot; click in the field, write something, and then press &quot;Enter.&quot;')
				),
				array(
					'type' =&gt; 'text',
					'label' =&gt; $this-&gt;l('Friendly URL:'),
					'name' =&gt; 'link_rewrite',
					'lang' =&gt; true,
					'required' =&gt; true,
					'hint' =&gt; $this-&gt;l('Only letters and the minus (-) character are allowed.')
				),
				array(
					'type' =&gt; 'group',
					'label' =&gt; $this-&gt;l('Group access:'),
					'name' =&gt; 'groupBox',
					'values' =&gt; Group::getGroups(Context::getContext()-&gt;language-&gt;id),
					'info_introduction' =&gt; $this-&gt;l('You now have three default customer groups.'),
					'unidentified' =&gt; $unidentified_group_information,
					'guest' =&gt; $guest_group_information,
					'customer' =&gt; $default_group_information,
					'desc' =&gt; $this-&gt;l('Mark all of the customer groups you;d like to have access to this category.')
				)
			),
			'submit' =&gt; array(
				'title' =&gt; $this-&gt;l('Save'),
				'class' =&gt; 'button'
			)
		);
		
		$this-&gt;tpl_form_vars['shared_category'] = Validate::isLoadedObject($obj) &amp;&amp; $obj-&gt;hasMultishopEntries(); 
		$this-&gt;tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
		if (Shop::isFeatureActive())
			$this-&gt;fields_form['input'][] = array(
				'type' =&gt; 'shop',
				'label' =&gt; $this-&gt;l('Shop association:'),
				'name' =&gt; 'checkBoxShopAsso',
			);
		// remove category tree and radio button &quot;is_root_category&quot; if this category has the root category as parent category to avoid any conflict
		if ($this-&gt;_category-&gt;id_parent == Category::getTopCategory()-&gt;id &amp;&amp; Tools::isSubmit('updatecategory'))
			foreach ($this-&gt;fields_form['input'] as $k =&gt; $input)
				if (in_array($input['name'], array('id_parent', 'is_root_category')))
					unset($this-&gt;fields_form['input'][$k]);

		if (Tools::isSubmit('add'.$this-&gt;table.'root'))
			unset($this-&gt;fields_form['input'][2],$this-&gt;fields_form['input'][3]);

		if (!($obj = $this-&gt;loadObject(true)))
			return;

		$image = ImageManager::thumbnail(_PS_CAT_IMG_DIR_.'/'.$obj-&gt;id.'.jpg', $this-&gt;table.'_'.(int)$obj-&gt;id.'.'.$this-&gt;imageType, 350, $this-&gt;imageType, true);

		$this-&gt;fields_value = array(
			'image' =&gt; $image ? $image : false,
			'size' =&gt; $image ? filesize(_PS_CAT_IMG_DIR_.'/'.$obj-&gt;id.'.jpg') / 1000 : false
		);

		// Added values of object Group
		$category_groups_ids = $obj-&gt;getGroups();

		$groups = Group::getGroups($this-&gt;context-&gt;language-&gt;id);
		// if empty $carrier_groups_ids : object creation : we set the default groups
		if (empty($category_groups_ids))
		{
			$preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
			$category_groups_ids = array_merge($category_groups_ids, $preselected);
		}
		foreach ($groups as $group)
			$this-&gt;fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], (in_array($group['id_group'], $category_groups_ids)));

		return AdminController::renderForm();
	}	
}
</pre>
<p>The post <a rel="nofollow" href="http://nemops.com/visual-editor-to-category-description/">Adding the visual editor to Category Description</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/visual-editor-to-category-description/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
