| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Dynamic Image Directory Reference from within Langauge Variable | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() Hi all, (XC 4.5.4)
Can anyone explain to me why the following does not work in a language variable: <a href="home.php"><img src="{{AltImagesDir}}/custom/mypicture.jpg" /></a> It seems it cannot use the {{AltImagesDir}} to determine the path to the picture. I also tried inserting a "$", {{$AltImagesDir}} which did not work either. I saw something similar in another default language variable, but since I don't know whether the lng variable I found with similar value is being used anywhere I don't know if it actually works either. I can get the following to work, but want to understand why the former doesn't: <a href="home.php"><img src="../images/custom/mypicture.jpg" /></a>
__________________
David Coggan Carolyn Nussbaum Music Company X-Cart v4.5.4 Gold + LiteCommerce v2.2.41 (previous 6 years) |
|||||||
#2
|
|||||||
|
|||||||
![]() Well that still doesn't work for me. The example I was working from is the following default language variable:
lbl_buy_now_img = <img src="{{AltImagesDir}}/custom/add_to_cart.gif" alt="Buy Now"/> like I said this may not work either, but since I don't know where it is called from I can't say. Does what you recommended work for you?
__________________
David Coggan Carolyn Nussbaum Music Company X-Cart v4.5.4 Gold + LiteCommerce v2.2.41 (previous 6 years) |
|||||||
#3
|
|||||||||
|
|||||||||
![]() Its a great question, and the answer is simple as always.
Look at /common_files/modules/One_Page_Checkout/opc_summary.tpl Note this line: {$lng.txt_terms_and_conditions_note|substitute:"te rms_url":"`$xcart_web_dir`/pages.php?alias=conditions":"privacy_url":"`$xcart _web_dir`/pages.php?alias=business"} Important part here is "|substitute" take note of this syntax and let me know if you need more help.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#4
|
|||||||
|
|||||||
![]() Hi mike,
Did you maybe accidentally post a response here to a different question? Or maybe I am just so tired from another late night trying to launch my new site and therefore don't see the connection between your response and my question. Either way thanks for the attention, but I don't get it.
__________________
David Coggan Carolyn Nussbaum Music Company X-Cart v4.5.4 Gold + LiteCommerce v2.2.41 (previous 6 years) |
|||||||
#5
|
|||||||
|
|||||||
![]() Hmmm, really strange. I had got a response to this post ( between #1 and #2) from someone( sorry I can't remember who) and the I responded as seen in two.. But now that post is gone??? Is the forum maybe having a problem.??
__________________
David Coggan Carolyn Nussbaum Music Company X-Cart v4.5.4 Gold + LiteCommerce v2.2.41 (previous 6 years) |
|||||||
#6
|
|||||||
|
|||||||
![]() That was me, I wasn't sure my answer was correct
![]()
__________________
xcartmods.co.uk |
|||||||
#7
|
|||||||
|
|||||||
![]() Oh no prob PhilJ, I new it was one of you gurus that had responded, but didn't want to thank the wrong person.
Is it me? Do you undstand Mike's post here? (I mean I understand it, as he wonderfully sheds light on some terrible hardcoding related to the terms & privacy links on the OPC, but I don't know what it has to do with my question?)
__________________
David Coggan Carolyn Nussbaum Music Company X-Cart v4.5.4 Gold + LiteCommerce v2.2.41 (previous 6 years) |
|||||||
#8
|
|||||||||
|
|||||||||
![]() David, I was three sheets to the wind when I posted. No wonder it didn't make sense. The missing post threw me off too.
Here is a snippet from a 4.4.5 cart /common_files/customer/main/welcome.tpl Code:
Code:
Make sense now? As I understand it, you want to use a smarty variable in a language variable. You have done the right thing encapsulating your variable in the language entry with {{this}} now you need to use "|substitute" when you call the language variable in the template.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#9
|
|||||||||
|
|||||||||
![]() Quote:
Why do you have the smarty variable in double {{}}? It has to be single {}. <a href="home.php"><img src="{$AltImagesDir}/custom/mypicture.jpg" /></a>
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#10
|
|||||||
|
|||||||
![]() So here's the result...
Sorry Steve your suggestion... Code:
What does work is... Code:
if you call it like this from the tpl file... Code:
I believe this is because the language variable itself can't pass through the real value of the smarty variable. Therefore they use the {{ }} to identify a value that can be called out by the substitute function and in the substitute function they replace the AltImagesDir with the smarty variable {$AltImagesDir} which of course the tpl file know. There ya go, it works now. All that to avoid hardcoding the path in the language variable, not sure it was worth it but a good learning exercise. Feel free to give a more proper explanation of why it works if you want. I am not a developer.
__________________
David Coggan Carolyn Nussbaum Music Company X-Cart v4.5.4 Gold + LiteCommerce v2.2.41 (previous 6 years) |
|||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|