2

Is it possible to use the Allow EE Code plugin and textarea formatting option and also have formatting as XHTML?

I have an existing field (textarea with XHTML formatting) with lots of content in many existing entries. I would like to change that field to Allow EE Code, but still have it auto format as XHTML. As far as I can tell, when you change a field to format as "Allow EE Code" it doesn't use XHTML or Auto BR formatting. No auto formatting at all.

Is there any way to marry the two and have the best of both worlds?

1

Yes. You can leave the custom field formatting set to xhtml, and then in your template just wrap the custom field in the Allow EE Code plugin.

{exp:allow_eecode}{your_custom_field}{/exp:allow_eecode}

You could also do the reverse, setting the field formatting to Allow EE Code and then use the xhtml typography plugin in the template.

{exp:xhtml:full}{your_custom_field}{/exp:xhtml:full}

That said, these approaches may not be super-useful because of the way xhtml formatting wraps line breaks in p tags. Hard to say without knowing more about your use case. In my experience the times I need the Allow EE Code plugin I'm applying any html myself along with the EE tags rather than relying on auto xhtml. So you could consider setting the field formatting to none.

Again, this might be off target for you but if you provide a bit more information and some of your template code you might get a better answer.

4
  • So it's not a requirement to use the Allow EE Code formatting option? What's the purpose of it then? Feb 28 '13 at 8:41
  • You'd use Allow EE Code if you are going to store ExpressionEngine template tags in a custom field in your entries. Its purpose is to parse the tags. Without it any tags in your custom field data are just treated as text. ...I am going to update my answer, though, because setting the field formatting to xhtml and then mixing in EE code is probably going to have the undesired effect of wrapping your output in p tags. If you update your question with more detail and a little of your template code I (or someone else) might be able to offer a better answer.
    – Alex Kendrick
    Feb 28 '13 at 15:11
  • So just the clarify, if you wrap your field output in {exp:allow_eecode} you do not need to also use the 'Allow EE Code' field formatting option on that field? For some reason I was under the impression that you needed both. So it's one or the other? Do they have the same effect? In my case, paragraph tags around the EE tags are probably not a problem but I can see how in most cases that would be undesirable. I'm just trying to find a way to write EE tags in my field content and have them parse, but also preserve XHTML auto formatting in the field text. Feb 28 '13 at 19:17
  • Correct. If you wrap a field with exp:allow_eecode in the template then you do not need to also set the formatting of the custom field to "Allow EE Code". -- As to whether you'll get the desired results when combining it with auto xhtml formatting you'll just have to experiment as it depends on your content, the EE tags, and how you want your output. Try the suggestions in my answer. The second method is less likely to cause issues with the interpretation of EE tags.
    – Alex Kendrick
    Feb 28 '13 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.