1

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?

2
  • Strange. It shouldn't do that all by itself. What version of Smarty is this? Are you using {literal}{/literal} somewhere? Commented Mar 26, 2010 at 18:01
  • You know what, I am themeing an aMember system. So, I didn't build the system from scratch. I bet they've put {literal} tags wrapping the content somewhere in the file structure. Now that I know that the above code should work, I'll start going through the file structure for debug. Thanks. Is there a possible php function that they could've called (that I should look out for) to enable this {literal} functionality? Commented Mar 26, 2010 at 18:12

2 Answers 2

1

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!!

Sign up to request clarification or add additional context in comments.

1 Comment

I've a similar situation here but little complex,look @ my code. {literal}<iframe src="http://www.facebook.com/plugins/registration.php?client_id=2343434234&fb_on‌ ​ ly=true&redirect_uri=http://localhots/POC/manage_users.php?reg_type={/literal}{$regtype}{literal}&act_action=save_profiledata&fields=[{'name':'name'}, {'name':'email'}, {'name':'gender'}, {'name':'location'}, {'name':'birthday'}]" scrolling="auto" frameborder="no" style="border:none" allowTransparency="true" width="100%" height="360"></iframe>{/literal} In this case it doesn't return full url but the value is retrieved.Any help?
0

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

3 Comments

No. I actually, tried wrapping them with {literal} while troubleshooting, but realized that it does the opposite of what I want to do.
You know what, I am themeing an aMember system. So, I didn't build the system from scratch. I bet they've put {literal} tags wrapping the content somewhere in the file structure. Now that I know that the above code should work, I'll start going through the file structure for debug. Thanks. Is there a possible php function that they could've called (that I should look out for) to enable this {literal} functionality?
I tried putting {/literal} at the beginning of the script, and then {literal} at the end of the script. In case the aMember system left the {literal} tag open in one of the initial files, and closed it in one of the final files (for whatever reason). It drew an error though, so dice there either. Hmm...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.