solved Processing a smarty variable inside {literal}

iamtimbo
@iamtimbo
7 years ago
301 posts
I would like (some very privileged) users to be able to add a snippet to a form (e.g. from http://www.gettyimages.co.uk/resources/embed), and then display it.

However, as the snippet has JavaScript in it, it needs to be wrapped with {literal} tags in the output template, but of course when you do that, it doesn't process the variable from the array:

{literal}
{$item.remoteimage_snippet}
{/literal}

Is it even possible to extract the snippet within literal tags, or does smarty start to eat itself? For reference, the snippet looks like this:

<a id='8U7eAtVYRcZZvolcN-XWTw' class='gie-single' href='http://www.gettyimages.co.uk/detail/HA8271-001' target='_blank' style='color:#a7a7a7;text-decoration:none;font-weight:normal !important;border:none;display:inline-block;'>Embed from Getty Images</a><script>window.gie=window.gie||function(c){(gie.q=gie.q||[]).push(c)};gie(function(){gie.widgets.load({id:'8U7eAtVYRcZZvolcN-XWTw',sig:'xsRNMqHbH3vZI8R3Nky7Cky6BNNwUBPGMjQdiuT1cuE=',w:'511px',h:'335px',items:'HA8271-001',caption: true ,tld:'co.uk',is360: false })});</script><script src='//embed-cdn.gettyimages.com/widgets.js' charset='utf-8' async></script>

updated by @iamtimbo: 11/13/17 12:27:18AM
michael
@michael
7 years ago
7,746 posts
It only needs to be wrapped in {literal} tags if it is in a .tpl file. If its saved by the users to the database, then output back into the HTML page that was formed by the structure of the smarty code, then it doesn't need to be in literals because smarty has finished processing.

--edit--
So if you trust them 100% you can put them in a quota that has
ACP -> MODULES -> CORE -> SYSTEM CORE -> QUOTA -> Allow Alll Formatting

enabled.
updated by @michael: 08/14/17 07:02:12AM
iamtimbo
@iamtimbo
7 years ago
301 posts
Gotcha. Sorted. Thank you. Overthinking as usual! :)