Smarty error in template Andreas08 when adding a footer tag

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
schimanke
Regular
Posts: 161
Joined: Mon Jan 07, 2008 5:38 pm
Location: Hameln, Germany
Contact:

Smarty error in template Andreas08 when adding a footer tag

Post by schimanke » Wed Jan 29, 2014 11:02 am

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!

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Smarty error in template Andreas08 when adding a footer

Post by Timbalu » Wed Jan 29, 2014 11:28 am

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.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

schimanke
Regular
Posts: 161
Joined: Mon Jan 07, 2008 5:38 pm
Location: Hameln, Germany
Contact:

Re: Smarty error in template Andreas08 when adding a footer

Post by schimanke » Wed Jan 29, 2014 11:47 am

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!

User avatar
yellowled
Regular
Posts: 7005
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: Smarty error in template Andreas08 when adding a footer

Post by yellowled » Wed Jan 29, 2014 12:12 pm

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
amazon Wishlist - Serendipity-Podcast (German only, sorry)

schimanke
Regular
Posts: 161
Joined: Mon Jan 07, 2008 5:38 pm
Location: Hameln, Germany
Contact:

Re: Smarty error in template Andreas08 when adding a footer

Post by schimanke » Wed Jan 29, 2014 12:21 pm

Thanks a lot YL! That seemed indeed to do the trick. Now it works. :-)

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Smarty error in template Andreas08 when adding a footer

Post by Timbalu » Wed Jan 29, 2014 12:52 pm

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
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

Post Reply