ArtcoInc Posted May 20, 2018 Share Posted May 20, 2018 I have a very small file called /catalog/conditions_modal.php. The contents are: <?php require('includes/languages' . $language . '/conditions.php'); echo TEXT_INFORMATION: ?> This is called by a Modal to pop up my Terms and Conditions information. My problem is: I am getting a "Undefined variable: language" error. If I change the file to: <?php require('includes/languages/english/conditions.php'); echo TEXT_INFORMATION: ?> everything works fine. So, how or where do I define the $language variable? I looked into /admin/define_language.php. I see that in order for a file to be displayed here, there needs to be a 'language' file associated with the mother file. So, I created a file /catalog/includes/language/english/conditions_modal.php. With this file in place, I can now see that conditions_modal.php is listed as a file in admin/define_language.php. Yet, my problem still exists. So again, what do I have to do to define $language in this file? TIA Malcolm PS: If you are wondering what I'm doing, or why, it's this: I wrote the Modal to pop-up the T&C info as a content_footer module. Everything worked fine, but it loaded the entire T&C 'information' into the footer of every page in the shop. To reduce the page size, I am now using a process to Load Dynamic Content into the modal. This way, the content of the Modal (in this case, the T&C 'information') is only loaded dynamically when the modal is triggered. This trigger calls the above mentioned file, which then echos the T&C information. Like I said, this all works ... except for the $language variable problem. Link to comment Share on other sites More sharing options...
♥JcMagpie Posted May 20, 2018 Share Posted May 20, 2018 Clould it just be this? I have just checked my code and I have, require('includes/languages/' . $language . '/conditions.php'); Link to comment Share on other sites More sharing options...
Jack_mcs Posted May 20, 2018 Share Posted May 20, 2018 Add this to the file or function with the problem to fix it: global $language; Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
ArtcoInc Posted May 20, 2018 Author Share Posted May 20, 2018 @Jack_mcs Thank you. I added the global statement to the conditions_modal.php file (as listed above). That removed the Undefined Variable error, but the variable $language is blank. I tried adding the global statement to the content_footer module, but it had no effect. Link to comment Share on other sites More sharing options...
♥raiwa Posted May 20, 2018 Share Posted May 20, 2018 try to add it to the file where the modal is addressed/fired About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
ArtcoInc Posted May 20, 2018 Author Share Posted May 20, 2018 Just now, raiwa said: try to add it to the file where the modal is addressed/fired I've tried adding it to the content_footer file, and to its template file. No luck. Link to comment Share on other sites More sharing options...
♥raiwa Posted May 20, 2018 Share Posted May 20, 2018 could you post your entire code About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
ArtcoInc Posted May 20, 2018 Author Share Posted May 20, 2018 /catalog/conditions_modal.php (includes test code) <?php global $language; require('includes/languages' . $language . '/conditions.php'); // require('includes/languages/english/conditions.php'); echo "The variable language is: " . $language; echo TEXT_INFORMATION; ?> /catalog/includes/modules/content/footer/templates/conditions_modal.php <?php global $language; ?> <script> $('.ModalConditions').on('click',function(){ $('.modal-body').load('conditions_modal.php?id=2',function(){ $('#ModalConditions').modal({show:true}); }); }); </script> <div class="modal fade" id="ModalConditions" tabindex="-1" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> X </button> <h3 class="modal-title-site text-center" > <?php echo MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_HEADING_TITLE; ?> </h3> </div> <!-- /.modal-header --> <div class="modal-body"> </div> <!-- /.modal-body --> <div class="modal-footer"> </div> <!-- /.modal-footer --> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.Modal Conditions --> /catalog/includes/modules/content/footer/cm_footer_conditions_modal.php <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ class cm_footer_conditions_modal { var $code; var $group; var $title; var $description; var $enabled = false; function cm_footer_conditions_modal() { $this->code = get_class($this); $this->group = basename(dirname(__FILE__)); $this->title = MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_TITLE; $this->description = MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_DESCRIPTION; if ( defined('MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_STATUS') ) { $this->enabled = (MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_STATUS == 'True'); } } function execute() { global $oscTemplate, $language; ob_start(); include('/includes/modules/content/' . $this->group . '/templates/conditions_modal.php'); $template = ob_get_clean(); $oscTemplate->addContent($template, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_STATUS'); } function install() { tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Conditions Modal', 'MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_STATUS', 'True', 'Do you want to enable the Conditions Modal content module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); } function remove() { tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_CONTENT_FOOTER_CONDITIONS_MODAL_STATUS'); } } Link to comment Share on other sites More sharing options...
♥raiwa Posted May 20, 2018 Share Posted May 20, 2018 $language is defined in application_top.php, so you have to include it before using $language. Global $language is not required if you use it in the main page file, remove it everywhere. and yes, @JcMagpie is right, you missed one slash, it must be: require('includes/languages/' . $language . '/conditions.php'); About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
ArtcoInc Posted May 20, 2018 Author Share Posted May 20, 2018 @raiwa Thank you! 1) I removed the define from everything except the content_footer module 2) I added a require('includes/application_top.php'): to the trigger file: <?php require('includes/application_top.php'); require('includes/languages/' . $language . '/conditions.php'); echo TEXT_INFORMATION; ?> Now it is working! Thank you again! Malcolm Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.