Page 1 of 1

Smarty error in template Andreas08 when adding a footer tag

Posted: Wed Jan 29, 2014 10:02 am
by schimanke
Hi,

I just tried to add a script to my blog which is running the Andreas08 template. According to the instructions I need to put the script in the footer tag. In Andreas08 there is no such tag so I tried to add it manually in the index.tpl. However, this resulted in the following error:

Code: Select all

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template
Any ideas how I can add that script in the footer tag?

Thanks a lot!

Re: Smarty error in template Andreas08 when adding a footer

Posted: Wed Jan 29, 2014 10:28 am
by Timbalu
Who says to put what in the footer section?

What kind of script do you try to place to the end of index.tpl?
Normally javascript is meant to be placed before the closing </body> tag, if it isn't needed in the pages head.

Did you use the smarty parser exclude escape {literal}your script{/literal} or added a following whitespace "{ " to each opening bracket (Smarty3)?

Where does it say the syntax error is? It should show the erroneous line in detail.

Re: Smarty error in template Andreas08 when adding a footer

Posted: Wed Jan 29, 2014 10:47 am
by schimanke
Thanks for your reply and sorry that I seemed to be a little unspecific.

The instructions I was referring to can be found here: http://www.apple.com/itunes/affiliates/ ... maker.html

I am not really experienced where to put such scripts. Is it correct to put it in the index.tpl?

I didn't use any smarty parser exclude escapes or anything like that. I just added the script-code to the index.tpl. The error occurs when I make my code look like this:

Code: Select all

....

<div class="clearingdiv">&nbsp;</div>
</div>
<div id="footer"><div class="footerbg">
	</font><p><font color="#d8e3e9"><a href="http://www.schimanke.com/index.php?/pages/impressum.html">Impressum</a> | <a href="http://www.schimanke.com/index.php?/pages/about.html">Über mich</a><br>&copy; by <a href="http://www.schimanke.com">Florian Schimanke</a> | Template based on <a href="http://spartacus.s9y.org/index.php?mode=template_all" target="_blank">Andreas08</a></p></div>
</div>

{$raw_data}
{serendipity_hookPlugin hook="frontend_footer"}
{if $is_embedded != true}

<script type='text/javascript'>var _merchantSettings=_merchantSettings || [];_merchantSettings.push(['tdde', 'XXXX']);(function(){var autolink=document.createElement('script');autolink.type='text/javascript';autolink.async=true; autolink.src='http://autolinkmaker.itunes.apple.com/js/itunes_autolinkmaker.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(autolink, s);})();</script>

</body>

</html>
{/if}
Obviously this is not the right way to do it. Can you help me with that?

The error occurs in line 132.

Thanks again!

Re: Smarty error in template Andreas08 when adding a footer

Posted: Wed Jan 29, 2014 11:12 am
by yellowled
Most likely you'll need to mask the curly braces in the JS code since they're interpreted as Smarty code. That means to replace any occurence of { by {ldelim} and any occurence of } by {redlim}, but only within the JS code. So

Code: Select all

<script type='text/javascript'>var _merchantSettings=_merchantSettings || [];_merchantSettings.push(['tdde', 'XXXX']);(function(){var autolink=document.createElement('script');autolink.type='text/javascript';autolink.async=true; autolink.src='http://autolinkmaker.itunes.apple.com/js/itunes_autolinkmaker.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(autolink, s);})();</script>
becomes

Code: Select all

<script type='text/javascript'>var _merchantSettings=_merchantSettings || [];_merchantSettings.push(['tdde', 'XXXX']);(function(){ldelim}var autolink=document.createElement('script');autolink.type='text/javascript';autolink.async=true; autolink.src='http://autolinkmaker.itunes.apple.com/js/itunes_autolinkmaker.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(autolink, s);{rdelim})();</script>
and that should be it.

YL

Re: Smarty error in template Andreas08 when adding a footer

Posted: Wed Jan 29, 2014 11:21 am
by schimanke
Thanks a lot YL! That seemed indeed to do the trick. Now it works. :-)

Re: Smarty error in template Andreas08 when adding a footer

Posted: Wed Jan 29, 2014 11:52 am
by Timbalu
Erm, thats what I said... It would also help masking the whole script with literal or simply just change

Code: Select all

(function(){var
to

Code: Select all

(function() { var
with Smarty3. With this Smarty3 would know by itself that it isn't a Smarty delimiter.

And the place at the end of index.tpl for this kind of script should be ok, (minor) but better here

Code: Select all

</div>
{* place template js here *}
{$raw_data}
{serendipity_hookPlugin hook="frontend_footer"}
{* or here *}
{if $is_embedded != true}
</body>
</html>
{/if}
Please read http://www.smarty.net/forums/viewtopic.php?t=4501