Forums / General Questions / Adding a richtext editor to edit product descriptions

Adding a richtext editor to edit product descriptions

Locked

Views: 1,495

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
8 Jun 2009, 12:19 PM
#1
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Adding a richtext editor to edit product descriptions

Hi all
I added a WYSIWYG editor in a custom page to amend the product descriptions (products_description.products_description) more easily. It also lets me add color and change text size. Hope it's of some use

Download the WYSIWYG editor from openwebware.com
and make a donation to say thanks to the guy that wrote this (not me, honest)

Upload the files to your includes/js/ directory into a new folder. eg openwysiwyg_v147 as below

Add these lines to your custom page tpl_mypage_DEFAULT.php after the require ($define_page);

<!--INCLUDES FOR WYSIWYG EDITOR-->

<script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg-popup.js"></script> <script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg-color.js"></script> <script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg.js"></script> <script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg-settings.js"></script>

Immediately after you create the form eg

echo zen_draw_form('productsEditForm', zen_href_link(FILENAME_PRODUCTS_EDIT, '','SSL'),'POST'); ?>

add

<script language="javascript1.2">
// attach the editor to the textarea with a matching identifier'.
WYSIWYG.attach('products_description');
</script>

Now create a textarea. Note that the id of the textarea must match the above WYSIWYG.attach call

<textarea rows="15" name="products_description" id="products_description">db_text</textarea>
Click when finished  <input type="submit" name='submit' value="Done">

and close the form... :smile:

</form>

The form handler takes the contents, in my example, from $_POST['products_description].

Hope that's all clear and correct. If you want to pre-populate the textarea with your products_description insert the query result where I've written db_text.

The editor has a few non-funky features such as opening new windows to handle text color and it flags a couple of deprecated command errors in firebug. If anyone wants to provide feedback on how these can be tidied up I'd be grateful as the openwebware page doesn't seem to have a forum to discuss this. Similarly with any security issues the code might raise. Credit should go to the openwebware guy for the editor code, I've only shoehorned it into zencart.
Steve

8 Jun 2009, 12:38 PM
#2
sjk1000 avatar

sjk1000

New Zenner

Join Date:
Sep 2008
Posts:
100
Plugin Contributions:
0

Re: Adding a richtext editor to edit product descriptions

ps sorry, just realised I've probably dropped this into an inappropriate forum

14 Jul 2009, 3:04 AM
#3
sirdragon avatar

sirdragon

New Zenner

Join Date:
Jul 2009
Posts:
1
Plugin Contributions:
0

Re: Adding a richtext editor to edit product descriptions

**looks good but were is Add these lines to your custom page tpl_mypage_DEFAULT.php after the require ($define_page);and were do i put all this > <!--INCLUDES FOR WYSIWYG EDITOR-->
<script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg-popup.js"></script>
<script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg-color.js"></script>
<script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg.js"></script>
<script language="JavaScript" type="text/javascript" src="includes/js/openwysiwyg_v147/scripts/wysiwyg-settings.js"></script>

Immediately after you create the form eg

echo zen_draw_form('productsEditForm', zen_href_link(FILENAME_PRODUCTS_EDIT, '','SSL'),'POST'); ?>

add

<script language="javascript1.2">
// attach the editor to the textarea with a matching identifier'.
WYSIWYG.attach('products_description');
</script>

Now create a textarea. Note that the id of the textarea must match the above WYSIWYG.attach call

<textarea rows="15" name="products_description" id="products_description">db_text</textarea>
Click when finished  <input type="submit" name='submit' value="Done">

and close the form...

</form>**