'Template Language', 'pi_version' => '0.1.0', 'pi_author' => 'Maurice Faeh - SHOPLER AG', 'pi_author_url' => 'http://www.shopler.ch/', 'pi_description' => 'Change language localization settings from within templates.', 'pi_usage' => template_language::usage() ); // ---------------------------------------- // Plugin class // ---------------------------------------- class template_language { // ---------------------------------------- // mandatory plugin attributes // ---------------------------------------- var $return_data = ""; // ---------------------------------------- // plugin parameter attributes // ---------------------------------------- var $template_language = ''; // ---------------------------------------- // class constructor // ---------------------------------------- function template_language() { $this->set_template_language(); $this->set_userdata_language_variable(); $this->reload_language_file(); } // ---------------------------------------- // plugin 3rd segment functions // ---------------------------------------- function future() { $this->set_template_language(); $this->set_userdata_language_variable(); $this->set_anonymous_user_language_cookie(); $this->reload_language_file(); } // ---------------------------------------- // setter and getter functions // encapsulation for class attributes // ---------------------------------------- function set_template_language($template_language = '') { //encapsulation of template_language attribute global $TMPL; if ($template_language != '') { $this->template_language = $template_language; } else { if ($TMPL->fetch_param('language') != '') { $this->template_language = $TMPL->fetch_param('language'); } } } function get_template_language() { //encapsulation of template_language attribute return $this->template_language; } // ---------------------------------------- // various subfunctions // ---------------------------------------- function set_userdata_language_variable() { //set the userdata language variable //this works to change pagination language items etc. on the current page global $SESS; $SESS->userdata['language'] = $this->get_template_language(); // current page } // ---------------------------------------- function set_anonymous_user_language_cookie() { //set the language cookie for users that are not logged in //this works for future pages called from this template page i.e. newsletter message templates etc. //ATTENTION: users that are logged in overwrite this cookie with their own localization setting global $FNS; $FNS->set_cookie('language', $this->get_template_language(), 60*60*24*3); // future pages } // ---------------------------------------- function reload_language_file() { //some language variables are loaded before the templates are even parsed. //reset the language class and load those variables again global $LANG; $LANG->cur_used = array(); // empty language array $LANG->fetch_language_file('core'); // reload core language variables } // ---------------------------------------- // ---------------------------------------- // Plugin Usage // ---------------------------------------- function usage() { ob_start(); ?> INTRODUCTION: (A) Override any site wide language localization settings and any user control panel language preferences for a CURRENT template/page. OR (B) Override any site wide language localization settings and any user control panel language preferences for FUTURE templates/pages (that a user will visit after the current one). This works only for ANONYMOUS (not logged in) users. Tags: (1) {exp:template_language ...} (2) {exp:template_language:future ...} Parameters: (1) language Variables: (None) Conditional Variables: (None) Tags: (1) The {exp:template_language ...} tag: Add the following tag to your template. You don't need a closing tag. Use it to f.ex: - set the {pagination_link} tag's language to appear in english - etc. *****example***** * * {exp:template_language language="english"} * ***** (1) The {exp:template_language:future ...} tag: Add the following tag to your template. You don't need a closing tag. Use it to f.ex: - set the language for the "user message template" (such as the "mailinglist subscription message") to appear in english - etc. *****example***** * * {exp:template_language:future language="english"} * ***** * ATTENTION: This will only work for ANONYMOUS users. * ***** Parameters: (1) The "language" parameter: Specify a language other then the site wide language localization setting or any user control panel language preference. - Mandatory - One value only. Any name of any language pack category that you installed in EE Last Modification 4th November 2005