开发者

Passing a Smarty variable into Javascript link "src" attribute

I've assigned a Smarty variable:

{assign var="siteurl" value="http://website.com"}

I can successfully use it in my header.html file to call a CSS link:

<link rel="stylesheet" type="text/css" href="{$siteurl}/style.css" />

displays

<link rel="stylesheet" type="text/css" href="http://website.com/style.css" />

However, when I do the same for 开发者_开发问答a Javascript source, it literally prints out "{$siteurl}":

<script type="text/javascript" src="{$siteurl}/scripts.js"></script>

displays

<script type="text/javascript" src="{$siteurl}/scripts.js"></script>

Why isn't this Smarty variable displaying as expected?


Problem Solved! As mentioned in the comments above, I am working on an aMember system. I'm not sure if they leave smarty {literal} tags open at the end of their initial files, and then close them at the end, or what. But the fix was replacing

{$siteurl}

with

{/literal}{$siteurl}{literal}

I tried putting the reverse {literal} tags at the beginning and end of the document, but it threw an error. I have to manually put the code above for each javascript src instance.

THANK YOU SO MUCH EVERYONE FOR THE HELP!!


Are the script tags wrapped in a Smarty {literal}{/literal} block? That would prevent rendering of the {$siteurl} tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜