Post by pradeeprajk » Thu Feb 14, 2013 7:18 pm

It is extremely boring to set all the language variables in the controller .So i am writing a shortcut function to reduce the number of lines of code in opencart..

First go and write the code below in a file called Library/custom_functions.php
<?php

function __($word=null,$just_return=false){

global $language;
//$language=$GLOBALS['registry']->get('language');
$word=$GLOBALS['registry']->get('language')->get($word);
if($just_return) return $word;
echo $word;
}


?>

Then include this file inside startup file as
require_once(DIR_SYSTEM . 'library/custom_functions.php');

And to use in the .tpl files
just use it as
__('entry_t('entry_description') etc etc ..


Hope this reduces your headache of setting up all the language variables in controller files and Opencart includes this in the next version

Attachments

A file to write all your custom functions and don't forget to include it in the startup.php file


Newbie

Posts

Joined
Thu Feb 14, 2013 7:06 pm

Post by pradeeprajk » Sat Feb 16, 2013 5:14 am

correction

And to use in the .tpl files
just use it as
__(''entry_description') etc etc ..

Newbie

Posts

Joined
Thu Feb 14, 2013 7:06 pm

Newbie

Posts

Joined
Tue Mar 03, 2015 7:20 pm
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 2 guests