Page 1 of 1

How to insert Smarty with WYSIWYG?

Posted: Mon Feb 15, 2010 11:55 am
by Charles Butcher
Does anyone have advice on how WYSIWYG users can insert uesr-defined tags, global content blocks and other "{}" stuff?

My logic is like this:
  • My users need a WYSIWYG editor such as TinyMCE...
  • ...but they also want to insert the occasional Smarty tag -- for example {startExpandCollapse}...{stopExpandCollapse}, or a bit of Javascript to hide email addresses from robots.
  • It's convenient to put these tags in TinyMCE's "Custom Dropdown" menu, and that works fine for tags that don't mind being embedded in ... or other HTML block-level elements...
  • ...but it can wreck more complex tags that don't like being enclosed.
To put it another way: I use the Custom Dropdown menu as a quick way to insert Smarty tags, but then I turn off WYSIWYG and remove any ... enclosing them. Is there any way to set up a WYSWIG editor so that this is not necessary?

And for people who are comfortable with HTML, is there a quick way to insert snippets directly?

Calguy has written:
Users will screw something up if there is the slightest possibility, so don't give it to them.  If your customer will be editing a page that has smarty tags in them, move the smarty tags into the page template.
Makes a lot of sense, but there are times when I'd like to offer them more.

Re: How to insert Smarty with WYSIWYG?

Posted: Wed Feb 17, 2010 5:04 pm
by Dr.CSS
Train your clients to remove them, they may find after inserting one it has a p path, found at the bottom of tiny in the left side, they may be able to hilite it and choose none as formatting...

Re: How to insert Smarty with WYSIWYG?

Posted: Wed Feb 17, 2010 7:03 pm
by Wishbone
Dr.CSS wrote:...they may be able to hilite it and choose none as formatting...
I have tried that. There is no "none" on my install, just "format". When you click on it, it reverts back to "paragraph". However, you can select "div" instead to wrap a generic DIV around the item instead. Where this won't work is if your tag is supposed to fill 100% of the width of the enclosing container.

I was thinking about creating a function inside one of my existing modules, or as a separate module that strips the paragraph tags from a smarty tag that was on it's own line, using a smarty pre-trigger to call a function to process the data with a regular expression search and replace. Now that I think about it, there might be some tags that you might want enclosed in a paragraph tag, even on it's own line, so the admin panel would have to have a list of smarty tags to process... If I ever do this, I'll publish it. I haven't looked around, but I thought that this would be a common enough problem that would have an easy fix.

Re: How to insert Smarty with WYSIWYG?

Posted: Mon Jun 14, 2010 3:46 pm
by Charles Butcher
wishbone wrote: I was thinking about creating a function ... that strips the paragraph tags from a smarty tag that was on it's own line
Glad I'm not alone with this. Let us know when you get round to it. The other solutions are all perfectly valid, but just require users to remember even more stuff.

And if I'm not mistaken, the last couple of versions of TinyMCE have got very picky about styling. Now, it seems you have to select a whole para if you are not to end up with a bunch of span tags.