Page 1 of 1

[SOLVED] Can you call smarty code in the Pages content area?

Posted: Wed Oct 10, 2012 9:40 pm
by NicoCollu
Hello.

I'm wondering if it's possible to add smarty code into the page content WYSIWYG HTML editor.

To clarify, here is an example:
I want to call this code in the Pages content area. I have switched HTML view.

Code: Select all

<literal><div id="disquscomments">
{capture name=xxx assign=sid}news_{$entry->id}{/capture}{disqus comments=$sid}
</div></literal>
I also tried putting the literal code to surround just the smarty code. I also tried

Code: Select all

{literal}
code.

It doesn't work at all now and calls an error page when I reload the page.

At one point it worked, but then I went into change some things in the editor and it didn't work at all after that...

Also, when I press: "Apply", it removes the literal commands.

Thank you!

Re: Can you call smarty code in the Pages content area?

Posted: Wed Oct 10, 2012 9:46 pm
by calguy1000
short answer: yes

slightly longer answer: don't mix design code and content code, disable the wysiwyg for pages with design in them,

even longer answer: <literal> is not a valid tag. In HTML, or in smarty. {literal} is a smarty tag that turns off all smarty interpreting of the contents until {/literal} is encountered.

You need to read the documentation for the tags you are using, and the smarty documentation in general.

Re: Can you call smarty code in the Pages content area?

Posted: Wed Oct 10, 2012 10:12 pm
by NicoCollu
calguy1000 wrote:short answer: yes

slightly longer answer: don't mix design code and content code, disable the wysiwyg for pages with design in them,

even longer answer: <literal> is not a valid tag. In HTML, or in smarty. {literal} is a smarty tag that turns off all smarty interpreting of the contents until {/literal} is encountered.

You need to read the documentation for the tags you are using, and the smarty documentation in general.
Hey!

Yeah, I just read the {literal} smarty documentation and see that what I was trying to do was idiotic.

Is there a thread where the short answer is explained in detail?

Re: Can you call smarty code in the Pages content area?

Posted: Wed Oct 10, 2012 11:50 pm
by Dr.CSS
When you are trying to put code like that in a page it is sometimes better to put it in a GCB with editor turned off then use that in the "Content'...

Re: Can you call smarty code in the Pages content area?

Posted: Thu Oct 11, 2012 12:20 am
by NicoCollu
Dr.CSS wrote:When you are trying to put code like that in a page it is sometimes better to put it in a GCB with editor turned off then use that in the "Content'...
Thank you! This works perfectly for my purpose!