5

Is it at all possible to have a text input or area field in which we could enter EE code to be processed by the template.

For example, if we could have a text area called "Advanced Functionality" and within this write things like

 {sn_contact-form}

Right in the channel entry, and then in our template call...

{advanced_functionality}

then that could be valuable in some instances.

Is this too far down the parse order to happen? Or does anybody know of a solution?

2
  • To clarify: You want a user to be able to submit EE tags and have the parse-engine parse that as if its a template?
    – fideloper
    Commented Nov 26, 2012 at 22:16
  • That's correct.
    – Mutual
    Commented Nov 26, 2012 at 22:16

4 Answers 4

5

You could do this combining Stash and the allow_eecode plugin. http://www.tyssendesign.com.au/articles/cms/more-stash-examples/ has a great example of the functionality you're trying to achieve (example 1 wp shortcode).

For stash see https://github.com/croxton/Stash, allow_eecode http://devot-ee.com/add-ons/allow-ee-code

5
  • Perfect. Alow EE Code is just what I had in mind. Thanks @erwinheiser
    – Mutual
    Commented Nov 26, 2012 at 22:24
  • no need for Allow EE Code plugin - you can get Stash to parse the snippet as in my example Commented Nov 26, 2012 at 22:27
  • I feel that Allow EE Code is very unsafe unless you know for a fact that only you will ever be entering content. If you are building a site for an end-client you should never use this, as it would allow whoever they give access to the control panel to do basically whatever they want to your site and database through the use of malicious template code. Commented Nov 26, 2012 at 22:27
  • Good points well made. Unaccepted this answer (sorry!) because of the points raised.
    – Mutual
    Commented Nov 26, 2012 at 22:29
  • I think this is a really cool option, it's just too dangerous to use on sites that are edited by end-users. Commented Nov 26, 2012 at 22:30
5

Stash, yet again(!), is the answer:

{exp:channel:entries}
    {exp:stash:parse process="end"}
        {advanced_functionality}
    {/exp:stash:parse}
{/exp:channel:entries}

... this does the trick for parsing snippets

Then if you want to get more creative with custom shortcodes instead of snippets, you'd use stash:set first like this:

{exp:stash:set name="shortcode_inside_field" type="snippet"}
    <p>Hi there! It's important to set type="snippet" so that {shortcode_inside_field} will get automatically replaced with this sentence by the stash:parse tag later on.</p>
    ... now run all kinds of complicated EE tags here to generate the content of the shortcode (be sure to add parse_tags="yes") ....
{/exp:stash:set}

{exp:channel:entries}
    {exp:stash:parse process="end"}
        {advanced_functionality}                
    {/exp:stash:parse}
{/exp:channel:entries}
3
  • We did this extensively in one of the sites that I worked on, it's a good method if you only have a handful of tags that need to be inserted and they do not need to take parameters. Otherwise, see my Shortcode answer. Commented Nov 26, 2012 at 22:27
  • Could you give me a quick overview about what this is doing? In the first portion you seem to be setting the stash partial, and 'getting' it further on. What is the reason for this? Shouldn't this just be part of {advanced_functionality}?
    – Mutual
    Commented Nov 26, 2012 at 22:31
  • Sorry my first response was a little premature... (I've spent over a year doing it this way using the old String plugin, which has an :output method that makes this easy)... However the latest (dev) branch of Stash includes the parse method which means (since it's a snippet) you can do it as shown. Commented Nov 26, 2012 at 23:21
4

I have a new module called Shortcode coming out soon which enables this type of thing. It is a bit more restrictive in that it only allows tags that have been setup for it to be parsed since it'd be very unsafe to allow for open ended template code to be entered as content. That said, it's trivial to add new Shortcodes to the module with just a few lines of code.

For instance, you could easily insert a ProForm form using this tag:

[form form_name="application_form"]

Let me know if you'd like a demo by posting in the Shortcode forum.

3
  • Sounds great. I marked @erwinheiser's as the accepted answer as it can be used today by anybody looking at this question but I'll definitely check out Shortcode when I get a few.
    – Mutual
    Commented Nov 26, 2012 at 22:28
  • Yep with the caveats I just posted on the other answers, they are both pretty good options that you can use now. Let me know if you want a demo of Shortcode, I'll send it over. Commented Nov 26, 2012 at 22:28
  • cool, was unaware of this add-on. Keeping an eye on it! Commented Nov 26, 2012 at 22:30
0

Hmm, good question. I dont think this would be possible with snippets, as they are always parsed too early.

By the sounds of things this is basically what the Shortcodes addon will offer - though that isn't publicly available yet - maybe @IsaacRaway can chip in and let us know?

2
  • Yep, posted an answer for Shortcode. If anyone wants a demo copy they can post in the forum for the module and I'll send it over. Commented Nov 26, 2012 at 22:34
  • Damn, you beat me to it :)
    – Tom Davies
    Commented Nov 26, 2012 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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