Contemplate creates menu errors

perarnet - March 2, 2008 - 21:13
Project:Content Templates (Contemplate)
Version:6.x-0.3
Component:Code
Category:bug report
Priority:normal
Assigned:jrglasgow
Status:closed
Description

When enabling contemplate I get the following error on many pages (/admin for example):
warning: Invalid argument supplied for foreach() in [..]l\includes\menu.inc on line 258.

I'm running Drupal 6.1 and I verified the problem both hosted and on xampp.

#1

msensintaffar - March 2, 2008 - 21:42

I get the same error on drupal 6.0

#2

jrglasgow - March 3, 2008 - 03:54

that's what I get for not showing errors on the page and just logging them

#3

drdrup - March 3, 2008 - 04:33

I see the same warning. (see #228591: Invalid argument supplied for foreach() in /.../includes/menu.inc which I marked as duplicate]

#4

jrglasgow - March 3, 2008 - 04:49
Assigned to:Anonymous» jrglasgow
Status:active» fixed

This was caused by a mistake in the new menu system, or at least the way I implemented it with the upgrade.

When implementing the new menu system you need to make sure all the 'arguments' in the array are arrays themselves, I replaced

<?php
$items
['admin/content/templates'] = array(
   
'title' => t('Content templates'),
   
'description' => t('Create templates to customize output of teaser and body content.'),
   
'access callback' => 'user_access',
   
'access arguments' => 'administer templates',
   
'page callback' => 'contemplate_edit_type',
   
'page arguments' => array(3),
  );
?>

with this
<?php
$items
['admin/content/templates'] = array(
   
'title' => 'Content templates',
   
'description' => 'Create templates to customize output of teaser and body content.',
   
'access callback' => 'user_access',
   
'access arguments' => array('administer templates'),
   
'page callback' => 'contemplate_edit_type',
   
'page arguments' => array(3),
   
'type' => MENU_CUSTOM_ITEM,
  );
?>

You need to make sure you clear all cache tables in your database.
This at least fixed it on my system, if someone is still having this problem let me know.

#5

jrglasgow - March 3, 2008 - 05:07

Fix will appear in the next release 6.x-0.4

#6

perarnet - March 6, 2008 - 22:30

Thanks for the quick work!

#7

jrglasgow - March 7, 2008 - 02:43

I try

#8

jrglasgow - March 7, 2008 - 02:54

I try

#9

spmonahan - March 11, 2008 - 20:48

This helped me fix a problem I was having with one of my own modules. Can you provide a link to where you found the info about the arguments needing to be arrays?

#10

jrglasgow - March 11, 2008 - 23:33

I did a search for

foreach() menu.inc

in the drupal.org search and I found this
#201290: Invalid argument supplied for foreach() in menu.inc

#11

Anonymous (not verified) - March 25, 2008 - 23:41
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.