How would you rate this article?
Rating:
1 user(s) have rated this article
Posted by:
retro
Date:
02/05/2009
Category:
Web Development
Views:
this article has been read 1299 times
Recent Articles

(26/06/2010)
Nochex merchant accounts provide you with everything you need to accept payments on your web site. With no monthly fees and support for a number of ecommerce solutions, including nopCommerce, it has never been easier to start selling online!
|
(25/05/2010)
Check out our latest project for community interest company S.C.A.
|
(25/05/2010)
We are pleased to announce support for version 4.0 of the .NET Framework on all of our hosting plans.
|
(11/02/2010)
We have just completed development of a new web site for UK based Aerial Spares.
|
(11/02/2010)
Today sees the release of the official nopCommerce user guide. It explains every part of the application in detail and includes a getting started guide so you can get up and running quickly.
|
read more
We have used FCKeditor (text editor) frequently in the past. We came up with a neat solution recently whilst working on the nopCommerce project to insert pre-defined message tokens into the message templates.
FCKeditor is used in many different areas of the nopCommerce administration portal. One of these is the creation/modification of message templates. Message templates are used to control the formatting of emails sent to both storekeepers and customers.
The store administrator can insert "tokens" into the body of the message that will then be replaced with the necessary text at runtime e.g:
Hello %Order.CustomerFullName%!,
This will then be replaced with the customer's full name.
Now with nopCommerce becoming more and more feature packed with every release, we needed an easy way of remembering what tokens could be used. What we did was to create a custom FCKeditor control "nopcombo" that would read tokens from an xml file, display the token names, and upon selection, insert the token values into the body of the message.
Below is an extract of the xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Tokens>
<Token name="Store.Name" value="%Store.Name%" />
<Token name="Store.URL" value="%Store.URL%" />
<Token name="Store.Email" value="%Store.Email%" />
and a screen shot of the control in action:

To install download the nopcombo plugin from the article resources at the top of this page. Extract the nopcombo folder into the plugins directory (/fckeditor/editor/plugins).
Create a valid XML file inside the fckeditor directory. The code expects the XML to have the "Token" nodes as per the above structure, so you may need to modify the code if you want name your XML elements differently. However, in most cases you can leave it as it is.
Open up fckconfig.js and make the following changes:
Underneath "FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;" add:
FCKConfig.Plugins.Add( 'nopcombo' ) ;
Underneath "FCKConfig.StylesXmlPath = FCKConfig.EditorPath + 'fckstyles.xml';" add:
FCKConfig.NopTokensXmlPath = FCKConfig.EditorPath + 'yourxmlfile.xml';
Finally, you just need to add the nopcombo control to your toolbar set:
['FitWindow', 'ShowBlocks', '-', 'About'], ['nopcombo']
That's it!
Comments
Comment this article