yogeshnaik Posted March 2, 2013 Posted March 2, 2013 I've recently installed oscommerce 2.3.3 How to create a new infobox in oscommerce..? I got this solution online * Copy catalog/includes/modules/boxes/bm_information.php and give it a new name. * Edit that file and change bm_information to your new box name throughout that file. * Change all of the constants that include _INFORMATION_ to include your new name instead. Keep them in all caps. * Change the content to what you want in your new box. If you are using links to new files, keep the same format as the links in that box. * The part that generates the box is in the execute() method. * Copy catalog/includes/languages/english/modules/boxes/bm_information.php and give it a the same name as you did the file in step 1. * Make the same changes to the constants in this file that you made in step 3. * Upload your two new files. * Go to your store Admin > Modules > Boxes and install your new module. Give it a sort order that will place it where you want it. But when i tried that, i got this warning message and bestseller module disappeared. Warning: reset() expects parameter 1 to be array, null given in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 228 Warning: Variable passed to each() is not an array or object in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 229 What exactly is the issue..? A man is great by Deeds, not by Birth....
yogeshnaik Posted March 4, 2013 Author Posted March 4, 2013 I tried to install shopping_cart module but i still get those 2 warnings.. Its like in admin area I go to Modules then Boxes... then its like the image below... I click on Install Modules button and i get a set of modules to be installed. But instead of getting install button I get Edit and Remove Module buttons. http://i.imgur.com/C4OQNBN.png[/img] If i click on any of these modules (Shopping Cart or Information or Manufacturer info) I get 2 warnings ... and then I'm not at all able to install those modules. http://i.imgur.com/ri9WUAa.png[/img] I checked the page modules.php and the code is something like this.... switch ($action) { case 'edit': $keys = ''; reset($mInfo->keys); while (list($key, $value) = each($mInfo->keys)) { $keys .= '<strong>' . $value['title'] . '</strong><br />' . $value['description'] . '<br />'; if ($value['set_function']) { eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');"); } else { $keys .= tep_draw_input_field('configuration[' . $key . ']', $value['value']); } $keys .= '<br /><br />'; } $keys = substr($keys, 0, strrpos($keys, '<br /><br />')); $heading[] = array('text' => '<strong>' . $mInfo->title . '</strong>'); $contents = array('form' => tep_draw_form('modules', FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module'] . '&action=save')); $contents[] = array('text' => $keys); $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']))); break; default: $heading[] = array('text' => '<strong>' . $mInfo->title . '</strong>'); if ($mInfo->status == '1') { $keys = ''; reset($mInfo->keys); while (list(, $value) = each($mInfo->keys)) { $keys .= '<strong>' . $value['title'] . '</strong><br />'; if ($value['use_function']) { $use_function = $value['use_function']; if (preg_match('/->/', $use_function)) { $class_method = explode('->', $use_function); if (!isset(${$class_method[0]}) || !is_object(${$class_method[0]})) { include(DIR_WS_CLASSES . $class_method[0] . '.php'); ${$class_method[0]} = new $class_method[0](); } $keys .= tep_call_function($class_method[1], $value['value'], ${$class_method[0]}); } else { $keys .= tep_call_function($use_function, $value['value']); } } else { $keys .= $value['value']; } $keys .= '<br /><br />'; } $keys = substr($keys, 0, strrpos($keys, '<br /><br />')); $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_EDIT, 'document', tep_href_link(FILENAME_MODULES, 'set=' . $set . (isset($HTTP_GET_VARS['module']) ? '&module=' . $HTTP_GET_VARS['module'] : '') . '&action=edit')) . tep_draw_button(IMAGE_MODULE_REMOVE, 'minus', tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=remove'))); if (isset($mInfo->signature) && (list($scode, $smodule, $sversion, $soscversion) = explode('|', $mInfo->signature))) { $contents[] = array('text' => '<br />' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' <strong>' . TEXT_INFO_VERSION . '</strong> ' . $sversion . ' (<a href="http://sig.oscommerce.com/' . $mInfo->signature . '" target="_blank">' . TEXT_INFO_ONLINE_STATUS . '</a>)'); } if (isset($mInfo->api_version)) { $contents[] = array('text' => tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' <strong>' . TEXT_INFO_API_VERSION . '</strong> ' . $mInfo->api_version); } $contents[] = array('text' => '<br />' . $mInfo->description); $contents[] = array('text' => '<br />' . $keys); } elseif (isset($HTTP_GET_VARS['list']) && ($HTTP_GET_VARS['list'] == 'new')) { if (isset($mInfo)) { $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_MODULE_INSTALL, 'plus', tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=install'))); if (isset($mInfo->signature) && (list($scode, $smodule, $sversion, $soscversion) = explode('|', $mInfo->signature))) { $contents[] = array('text' => '<br />' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' <strong>' . TEXT_INFO_VERSION . '</strong> ' . $sversion . ' (<a href="http://sig.oscommerce.com/' . $mInfo->signature . '" target="_blank">' . TEXT_INFO_ONLINE_STATUS . '</a>)'); } if (isset($mInfo->api_version)) { $contents[] = array('text' => tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' <strong>' . TEXT_INFO_API_VERSION . '</strong> ' . $mInfo->api_version); } $contents[] = array('text' => '<br />' . $mInfo->description); } } break; } I don't know exactly where and what I've to edit..... :( Anyone else has encountered a similar issue before...? Thanks. A man is great by Deeds, not by Birth....
yogeshnaik Posted March 4, 2013 Author Posted March 4, 2013 Ok so the problem is somewhere here ... switch ($action) { case 'edit': $keys = ''; reset($mInfo->keys); while (list($key, $value) = each($mInfo->keys)) { $keys .= '<strong>' . $value['title'] . '</strong><br />' . $value['description'] . '<br />'; if ($value['set_function']) { eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');"); } else { $keys .= tep_draw_input_field('configuration[' . $key . ']', $value['value']); } $keys .= '<br /><br />'; } I saw php manual... reset() and each() functions expect an array as parameter.... so they expect $key to be an array in this case... but $key= '' so I'm getting the warnings: Warning: reset() expects parameter 1 to be array, null given in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 228 Warning: Variable passed to each() is not an array or object in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 229 but I didn't modified the admin/modules.php page.... I created a new folder and did a fresh installation of oscommerce 2.3.3 and then checked for admin/modules.php.... $keys is null in the code... Now I'm bit confused is it the error in modules page or somewhere else..?? :wacko: A man is great by Deeds, not by Birth....
yogeshnaik Posted March 5, 2013 Author Posted March 5, 2013 My shopping Cart module was not getting installed.... I was getting these 2 warnings Warning: reset() expects parameter 1 to be array, null given in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 228 Warning: Variable passed to each() is not an array or object in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 229 and Install button module showed 5 modules pending... But then when I removed currencies module I was able to install Shopping Cart module. Now whatever modules I'm creating I'm not able to install them... If I uninstall some existing modules like Categories or Best Sellers.....then I'm able to install my newly created modules and they do show up in my browser properly.... What sort of bug is this... problem is in my database..? :'( A man is great by Deeds, not by Birth....
♥kymation Posted March 5, 2013 Posted March 5, 2013 Yes, you've messed up the configuration table in your database. You may have not changed all of the constants in the installation and keys sections of your new module, so some of those got duplicated. You can try removing all of your modules and then reinstalling them one at a time. You may need to remove those constants from the database using your host's database management tool (usually phpMyAdmin.) Regards Jim See my profile for a list of my addons and ways to get support.
yogeshnaik Posted March 6, 2013 Author Posted March 6, 2013 Yes, you've messed up the configuration table in your database. You may have not changed all of the constants in the installation and keys sections of your new module, so some of those got duplicated. You can try removing all of your modules and then reinstalling them one at a time. You may need to remove those constants from the database using your host's database management tool (usually phpMyAdmin.) Regards Jim Thanx for your reply sir.... I removed all the modules and installed them back.....While installing ... The following modules got installed without any issues... Best Sellers Module Categories Currencies Information Languages Manufacturer Info Manufacturers Order History Product Notifications Product Social Bookmarks Reviews Problem started when i tried to install Search module. That Install Module button was showing '4' These 4 default modules were pending to be installed.... Search Shopping Cart Specials What's New Then i selected "Search" module and clicked Install Module button. It did not install and it was still Install Module(4) Then I clicked on Search Module link again.... and then i got these same 2 warnings... Warning: reset() expects parameter 1 to be array, null given in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 228 Warning: Variable passed to each() is not an array or object in C:\xampp\htdocs\oscommerce-2.3.3\catalog\admin\modules.php on line 229 Then i exported my configuration table, opened in text editor and saw that like other default modules, for Search also there are 3 entries present...... INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES .... .... .... ..... (1302, 'Enable Search Module', 'MODULE_BOXES_SEARCH_STATUS', 'True', 'Do you want to add the module to your shop?', 6, 1, NULL, '2013-03-06 13:37:09', NULL, 'tep_cfg_select_option(array(''True'', ''False''), '), (1303, 'Content Placement', 'MODULE_BOXES_SEARCH_CONTENT_PLACEMENT', 'Left Column', 'Should the module be loaded in the left or right column?', 6, 1, NULL, '2013-03-06 13:37:09', NULL, 'tep_cfg_select_option(array(''Left Column'', ''Right Column''), '), (1304, 'Sort Order', 'MODULE_BOXES_SEARCH_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', 6, 0, NULL, '2013-03-06 13:37:09', NULL, NULL); I haven't created this search module, neither I've added any constants.... bm_search.php was already present after installation of oscommerce2.3.3 in catalog/includes/modules/boxes There are three constants in both keys() and install() MODULE_BOXES_SEARCH_STATUS MODULE_BOXES_SEARCH_CONTENT_PLACEMENT MODULE_BOXES_SEARCH_SORT_ORDER and these constants occur only once in configuration.sql Where exactly I need to search for error, I mean is there any other place where i need to edit something..? A man is great by Deeds, not by Birth....
yogeshnaik Posted March 6, 2013 Author Posted March 6, 2013 Finally resolved the issue......... Can't believe the issue was due to the Data Type in configuration table... The database file which i was working in had different table structure i mean the data type... it was like CREATE TABLE IF NOT EXISTS `configuration` ( `configuration_id` int(11) NOT NULL AUTO_INCREMENT, `configuration_title` varchar(64) NOT NULL, `configuration_key` varchar(64) NOT NULL, `configuration_value` varchar(255) NOT NULL, `configuration_description` varchar(255) NOT NULL, `configuration_group_id` int(11) NOT NULL DEFAULT '0', `sort_order` int(5) DEFAULT NULL, `last_modified` datetime DEFAULT NULL, `date_added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `use_function` varchar(255) DEFAULT NULL, `set_function` varchar(255) DEFAULT NULL, PRIMARY KEY (`configuration_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1305 ; Then I installed a fresh copy of oscommerce 2.3.3 and checked the database there table structure was CREATE TABLE IF NOT EXISTS `configuration` ( `configuration_id` int(11) NOT NULL AUTO_INCREMENT, `configuration_title` varchar(255) NOT NULL, `configuration_key` varchar(255) NOT NULL, `configuration_value` text NOT NULL, `configuration_description` varchar(255) NOT NULL, `configuration_group_id` int(11) NOT NULL, `sort_order` int(5) DEFAULT NULL, `last_modified` datetime DEFAULT NULL, `date_added` datetime NOT NULL, `use_function` varchar(255) DEFAULT NULL, `set_function` varchar(255) DEFAULT NULL, PRIMARY KEY (`configuration_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=259 ; I made the necessary changes... Changed `configuration_title` varchar(64) NOT NULL, `configuration_key` varchar(64) NOT NULL, `configuration_value` varchar(255) NOT NULL, to `configuration_title` varchar(255) NOT NULL, `configuration_key` varchar(255) NOT NULL, `configuration_value` text NOT NULL, And then I closed my browser.. cleared cache.. and started again... and this time I was able to install all my modules. Thanx Jim for your kind help. A man is great by Deeds, not by Birth....
Recommended Posts
Archived
This topic is now archived and is closed to further replies.