X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   How can I use language variable in Extra Fields? (https://forum.x-cart.com/showthread.php?t=61508)

ADDISON 11-07-2011 08:59 AM

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

qualiteam 11-17-2011 12:08 AM

Re: How can I use language variable in Extra Fields?
 
1 Attachment(s)
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.

qualiteam 11-17-2011 12:08 AM

Re: How can I use language variable in Extra Fields?
 
Moving to complete mods forum.

tomsell 05-03-2012 07:00 AM

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!


All times are GMT -8. The time now is 12:51 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.