|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Ganderik Smarty n00b
Joined: 28 Jun 2012 Posts: 2
|
Posted: Thu Jun 28, 2012 10:40 am Post subject: insert variable inside an url |
|
|
Hi i am trying to do something that i thought was fairly simple, but aparently not.
I have assigned a variable:
Code: |
{if $smarty.server.SERVER_ADDR == "IP address to server"}
{assign var="linkLoc" value="Predefined IP adresse"}
{else}
{assign var="linkLoc" value="Another predefined IP adresse"}
{/if}
|
Then i later (supposed to) use that variable to change the location the link should take me to
Code: |
<img id="logoImage" alt="non pic" src="resources/images/pic.png" width="150" onclick="location.href='https://${linkLoc}/folder/index.php?m=welcome'" onmouseover="try {this.style.cursor='hand'} catch(e) {this.style.cursor='pointer'};"/>
|
But the output for the variable inside of the link, is only {$linkLoc}. What is wrong? |
|
Back to top |
|
ChrisFah Smarty Pro
Joined: 02 Nov 2009 Posts: 159 Location: Traun, Austria
|
Posted: Thu Jun 28, 2012 11:53 am Post subject: |
|
|
Hi,
at first look, i see following :
Code: |
<img id="logoImage" alt="non pic" src="resources/images/pic.png" width="150" onclick="location.href='https://[color=red]${linkLoc}[/color]/folder/index.php?m=welcome'" onmouseover="try [color=red]{this.style.cursor='hand'}[/color] catch(e) [color=red]{this.style.cursor='pointer'}[/color];"/>
|
Chang to: {$linkLoc} -> the $ not outside the braces
{ this.style.cursor='hand' } and { this.style.cursor='pointer' } -> a whitespace after and before the braces, else smarty will handle this js as a veriable.
Regards, Chris |
|
Back to top |
|
Ganderik Smarty n00b
Joined: 28 Jun 2012 Posts: 2
|
Posted: Thu Jun 28, 2012 2:10 pm Post subject: |
|
|
Thanks for the reply. I think i fixed it my self by accident . But i did the same as you are telling. I removed the whole try catch and replaced it with a plain old:
Code: |
onmouseover="this.style.cursor='pointer';"
|
have an excellent day. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|