![]() |
Dynamic Image Directory Reference from within Langauge Variable
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> |
Re: Dynamic Image Directory Reference from within Langauge Variable
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? |
Re: Dynamic Image Directory Reference from within Langauge Variable
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. |
Re: Dynamic Image Directory Reference from within Langauge Variable
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. |
Re: Dynamic Image Directory Reference from within Langauge Variable
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.??
|
Re: Dynamic Image Directory Reference from within Langauge Variable
That was me, I wasn't sure my answer was correct O:)
|
Re: Dynamic Image Directory Reference from within Langauge Variable
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?) |
Re: Dynamic Image Directory Reference from within Langauge Variable
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:
<h1>{$lng.lbl_welcome_back|substitute:"name":$display_greet_visitor_name} </h1> Code:
Welcome back, {{name}} 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. |
Re: Dynamic Image Directory Reference from within Langauge Variable
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> |
Re: Dynamic Image Directory Reference from within Langauge Variable
So here's the result...
Sorry Steve your suggestion... Code:
<a href="home.php"><img src="{$AltImagesDir}/custom/mypicture.jpg" /></a> What does work is... Code:
<a href="home.php"><img src="{{AltImagesDir}}/custom/mypicture.jpg" /></a> if you call it like this from the tpl file... Code:
{$lng.languagevariablename|substitute:"AltImagesDir":$AltImagesDir} 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. |
All times are GMT -8. The time now is 02:45 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.