Jump to content

Can't add link to top menu (invalid argument)


Recommended Posts

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

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

/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

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

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

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

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

×
×
  • Create New...