zizoo Posted March 15, 2013 Share Posted March 15, 2013 I'm using version 1.5.3.1 Not using multishop When adding a custom link to the top menu, the link is accepted but afterwards it is not shown in the link menu (in admin panel) , nor in the top menu of the site. I receive following errors in the error log : [Wed Mar 13 10:54:38 2013] [warn] [client 84.192.X.X] mod_fcgid: stderr: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client1/web4/web/modules/blocktopmenu/blocktopmenu.php on line 262, referer: http://tablets.zizoo.be/admin1/index.php?controller=AdminModules&token=59ba6552e8350fddadd6c83b6516bc83 [Wed Mar 13 10:54:38 2013] [warn] [client 84.192.204.192] mod_fcgid: stderr: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client1/web4/web/modules/blocktopmenu/blocktopmenu.php on line 407, referer: http://tablets.zizoo.be/admin1/index.php?controller=AdminModules&token=59ba6552e8350fddadd6c83b6516bc83 Any tips ? Link to comment Share on other sites More sharing options...
NemoPS Posted March 15, 2013 Share Posted March 15, 2013 This is the line it is referring to: $links = MenuTopLinks::gets($id_lang, null, (int)Shop::getContextShopID()); foreach ($links as $link) It seems that it can't get links. Is there anything in the database for te menu? At least, for the current language? Link to comment Share on other sites More sharing options...
zizoo Posted March 15, 2013 Author Share Posted March 15, 2013 I'm not sure where to look in the database.. Link to comment Share on other sites More sharing options...
NemoPS Posted March 15, 2013 Share Posted March 15, 2013 I believe it's ps_linksmenutop Link to comment Share on other sites More sharing options...
zizoo Posted March 15, 2013 Author Share Posted March 15, 2013 I have both ps_linksmenutop and ps_linksmenutop_lang and both filled correctly Link to comment Share on other sites More sharing options...
NemoPS Posted March 15, 2013 Share Posted March 15, 2013 what do you get if you try dumping $links? Link to comment Share on other sites More sharing options...
zizoo Posted March 15, 2013 Author Share Posted March 15, 2013 I'm sorry you lost me. How do I dump $links ? Link to comment Share on other sites More sharing options...
NemoPS Posted March 15, 2013 Share Posted March 15, 2013 var_dump($links) Link to comment Share on other sites More sharing options...
zizoo Posted March 15, 2013 Author Share Posted March 15, 2013 Where and in which file do i put the var_dump ? Link to comment Share on other sites More sharing options...
NemoPS Posted March 15, 2013 Share Posted March 15, 2013 /modules/blocktopmenu/blocktopmenu.php on line 262, as the error says, between the other 2 lines, like this: $links = MenuTopLinks::gets($id_lang, null, (int)Shop::getContextShopID()); var_dump($links) foreach ($links as $link) Link to comment Share on other sites More sharing options...
zizoo Posted March 16, 2013 Author Share Posted March 16, 2013 When i do this, i receive an error : "bool(false)" Link to comment Share on other sites More sharing options...
NemoPS Posted March 16, 2013 Share Posted March 16, 2013 Uhm, it's not able to get links then, for some reason. This is the query: $sql = 'SELECT l.id_linksmenutop, l.new_window, ll.link, ll.label FROM '._DB_PREFIX_.'linksmenutop l LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_linksmenutop = ll.id_linksmenutop AND ll.id_lang = '.(int)$id_lang.' AND ll.id_shop='.(int)$id_shop.') WHERE 1 '.((!is_null($id_linksmenutop)) ? ' AND l.id_linksmenutop = "'.(int)$id_linksmenutop.'"' : '').' AND l.id_shop IN (0, '.(int)$id_shop.')'; Are you maybe using the multishop feature? Link to comment Share on other sites More sharing options...
zizoo Posted March 16, 2013 Author Share Posted March 16, 2013 I have used the multi-shop feature in the past on that site but have disabled it for some time now. Link to comment Share on other sites More sharing options...
NemoPS Posted March 16, 2013 Share Posted March 16, 2013 Try removing AND l.id_shop IN (0, '.(int)$id_shop.')';from the previous call, it's in menutoplinksclass.php (or something like that, it's in the same folder as blocktopmenu anyway) it's in the first function there Link to comment Share on other sites More sharing options...
zizoo Posted March 16, 2013 Author Share Posted March 16, 2013 if i do that i get an error : [PrestaShop] Fatal error in module menutoplinks.class: syntax error, unexpected T_STRING I replaced : public static function gets($id_lang, $id_linksmenutop = null, $id_shop) { $sql = 'SELECT l.id_linksmenutop, l.new_window, ll.link, ll.label FROM '._DB_PREFIX_.'linksmenutop l LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_linksmenutop = ll.id_linksmenutop AND ll.id_lang = '.(int)$id_lang.' AND ll.id_shop='.(int)$id_shop.') WHERE 1 '.((!is_null($id_linksmenutop)) ? ' AND l.id_linksmenutop = "'.(int)$id_linksmenutop.'"' : '').' AND l.id_shop IN (0, '.(int)$id_shop.')'; return Db::getInstance()->executeS($sql); With public static function gets($id_lang, $id_linksmenutop = null, $id_shop) { $sql = 'SELECT l.id_linksmenutop, l.new_window, ll.link, ll.label FROM '._DB_PREFIX_.'linksmenutop l LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_linksmenutop = ll.id_linksmenutop AND ll.id_lang = '.(int)$id_lang.' AND ll.id_shop='.(int)$id_shop.') WHERE 1 '.((!is_null($id_linksmenutop)) ? ' AND l.id_linksmenutop = "'.(int)$id_linksmenutop.'"' : '').' ; return Db::getInstance()->executeS($sql); } Link to comment Share on other sites More sharing options...
NemoPS Posted March 17, 2013 Share Posted March 17, 2013 Of course, you have a tralining. there, remove the dot like this public static function gets($id_lang, $id_linksmenutop = null, $id_shop) { $sql = 'SELECT l.id_linksmenutop, l.new_window, ll.link, ll.label FROM '._DB_PREFIX_.'linksmenutop l LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_linksmenutop = ll.id_linksmenutop AND ll.id_lang = '.(int)$id_lang.' AND ll.id_shop='.(int)$id_shop.') WHERE 1 '.((!is_null($id_linksmenutop)) ? ' AND l.id_linksmenutop = "'.(int)$id_linksmenutop.'"' : '') ; return Db::getInstance()->executeS($sql); } Link to comment Share on other sites More sharing options...
zizoo Posted March 17, 2013 Author Share Posted March 17, 2013 This worked, but still no effect. I can't add links. Link to comment Share on other sites More sharing options...
NemoPS Posted March 18, 2013 Share Posted March 18, 2013 Yes, but what kind of error are you getting this time? If you still get null from this, it's because you don't have links for the current language Link to comment Share on other sites More sharing options...
Recommended Posts