Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2007-05-02 10:35:46

thetazzbot
New member
Registered: 2007-04-06
Posts: 4

How to protect Smarty Tags in Xinha

I have a content management system which uses Smarty.  I wanted to use Xinha as the WYSIWIG editor but it kept foobarring my smarty tags. 

Here's how you can protect your Smarty tags inside the editor:

First of all, you need to change XinhaCore.js line 319:

this.getHtmlMethod = 'TransformInnerHTML';

Next, you need to add two lines to this file:  modules/GetHtml/TransformInnerHTML.js:

go to line 59, it currently looks like this:

/*23*/  new RegExp().compile(/(^|<\/script>)[\s\S]*?(<script[^>]*>|$)/g) //find content NOT inside script tags

You need to add a comma after the ending ")" so the line looks like:

/*23*/  new RegExp().compile(/(^|<\/script>)[\s\S]*?(<script[^>]*>|$)/g), //find content NOT inside script tags

Now, add these two lines after the above line:

/*24*/  new RegExp().compile(/(^|\{[\s\S]*?\})([\s\S]*?)(?=\{[\s\S]*?\}|$)/g),//find content NOT inside smarty tags
/*25*/  new RegExp().compile(/(^|\{\/[\s\S]*?\})[\s\S]*?(\{[^}]*}|$)/g) //find content NOT inside smarty tags

Save the files.  In your browser you *must* dump the cache.  In Firefox, its Tools, Clear Private Data. 

Good luck!

Xinha Rocks!

The Tazz

Offline

#2 2007-05-02 10:53:17

thetazzbot
New member
Registered: 2007-04-06
Posts: 4

Re: How to protect Smarty Tags in Xinha

Well, this works partially, I cant figure out why this type of code still messes up things like this:

{if count($courselist)>0}.....{/if}

it changes the > to >

Offline

#3 2007-05-03 00:17:54

thetazzbot
New member
Registered: 2007-04-06
Posts: 4

Re: How to protect Smarty Tags in Xinha

well crap, theres more to it then this.  I'm still trying to figure this out, if anyone has ideas please chime in.

Basically, we need to protect Smarty code just like script and comment code from being cleaned by Xinha.

Offline

#4 2007-05-03 08:52:47

wymsy
Xinha Community Member
From: Massachusetts, USA
Registered: 2005-04-01
Posts: 44
Website

Re: How to protect Smarty Tags in Xinha

The changes in your first post just define a couple of new regexps, without actually using them. You need to expand the statement that starts on line 154 (in the original source) to invoke them.

Offline

Board footer

Powered by FluxBB