Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Dynamic Image Directory Reference from within Langauge Variable

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 12-19-2012, 08:17 PM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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>
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #2  
Old 12-19-2012, 08:36 PM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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?
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #3  
Old 12-20-2012, 01:49 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
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.
Reply With Quote
  #4  
Old 12-20-2012, 04:47 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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.
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #5  
Old 12-20-2012, 04:56 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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.??
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #6  
Old 12-20-2012, 06:01 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Dynamic Image Directory Reference from within Langauge Variable

That was me, I wasn't sure my answer was correct
__________________
xcartmods.co.uk
Reply With Quote
  #7  
Old 12-20-2012, 07:59 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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?)
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #8  
Old 12-20-2012, 09:28 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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>
Then looking at the language variable lbl_welcome_back we see this:
Code:
Welcome back, {{name}}
The important part is "|substitute:"name":$display_greet_visitor_nam e" when you call the language variable in the template.

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.
Reply With Quote
  #9  
Old 12-20-2012, 10:30 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Dynamic Image Directory Reference from within Langauge Variable

Quote:
Originally Posted by tartaglia
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>

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
Reply With Quote
  #10  
Old 12-20-2012, 11:17 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default 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>
doesn't work, but thanks.

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.
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:28 PM.

   

 
X-Cart forums © 2001-2020