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

How can I use language variable in Extra Fields?
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 11-07-2011, 08:59 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default How can I use language variable in Extra Fields?

Hello Folks,

How can I use language variables in Extra Fields? For examply I create an Extra Field for a warranty text. Some variable parts of the text I would like to change faster than doing a SQL using language variables over the database (because I am not sure how the result will be, sometimes I could affect the content).

For example in product add page, in the input text box for a specific extra field I will write the text using $lbl_ variable.

Cheers
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #2  
Old 11-17-2011, 12:08 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: How can I use language variable in Extra Fields?

Unfortunately it is not possible in the default X-Cart.
But this feature can be custom programmed.

You should alter the "modules/Extra_Fields/extra_fields.php" script and replace this code:
PHP Code:
$smarty->assign('extra_fields'$extra_fields); 
with this one:
PHP Code:
if (in_array(AREA_TYPE, array('C''B'))) {
    foreach (
$extra_fields as $ef_k=>$ef_v) {
        if (
preg_match("/\{[$]{1}lng\.([a-z_]+)+\}/i"$extra_fields[$ef_k]['field_value'], $match)) {
            
$extra_fields[$ef_k]['field_value'] = str_replace($match[0], func_get_langvar_by_name($match[1]), $extra_fields[$ef_k]['field_value']);
        }
    }
}
$smarty->assign('extra_fields'$extra_fields); 

Note: use FTP to edit the PHP scripts.

Alternatively you can apply the attached Patch.

After the patch is applied you should be able using e.g. "{$lng.lbl_login}" as extra field value.
Attached Files
File Type: txt DIFF.patch.txt (538 Bytes, 11 views)
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following 2 users thank qualiteam for this useful post:
am2003 (11-17-2011), gb2world (11-17-2011)
  #3  
Old 11-17-2011, 12:08 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: How can I use language variable in Extra Fields?

Moving to complete mods forum.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #4  
Old 05-03-2012, 07:00 AM
 
tomsell tomsell is offline
 

Member
  
Join Date: Feb 2009
Posts: 13
 

Default Re: How can I use language variable in Extra Fields?

Hi,

works nice, but if I add an extra field to products list - {$product.extra_fields[0].field_value} - I get only the language variable, not the language entry ie. {$lng.lbl_material_vinyl} not "Vinyl". Thank for advance!
__________________
4.1.11
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


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 01:01 PM.

   

 
X-Cart forums © 2001-2018