warning: Invalid argument supplied for foreach() in template.php on line 143.

I do not get the warning when i switch to any other themes on my drupal 6.10 installation.

Interestingly, the warning is only displayed on pages that display a view. Using Views 6.x.2.3.

Any help is appreciated. This seems to be a really good theme.

Thanks

Comments

kong’s picture

Assigned: Unassigned » kong

This is interesting. I'd like to have more info on what's going on in that page. Could you add this line to the template.php file:

drupal_set_message('<pre>'.htmlspecialchars(print_r($vars, TRUE), ENT_QUOTES).'</pre>');

in the line just right after function phptemplate_preprocess_node(&$vars) { (~line 96) and open the page which has the problem.

You can copy the output message into file and attach it here. Thanks :)

ookello’s picture

StatusFileSize
new297.89 KB

One one of the pages that display a view and that warning, I got a php memory limit error after tryig to display the output message.

Although, I did copy the output message from a page displaying a different view. On this page the invalid argument warning is for line 144 in template.php. The text is attached.

The page is not a direct page to a view, rather I embedded a view into the page using the below code.

$view = views_get_view('name_of_the_view');
print $view->execute_display('page');
ookello’s picture

I guess the line # changed after i edited the template.php for posting messages.

The warning was again generated for the same function:

// put all comment related links into a separate variable
foreach ($vars['node']->links as $key => $value) {

Wish i could help you debug this but i'm not really a programmer. Nevertheless, I will still keep fighting this.Thanks again.

kong’s picture

Attached is the modified template.php.
Please backup the original file and use this file to see if it fix the problem.

If everything's OK then I'll apply the changes to the theme package.

kong’s picture

StatusFileSize
new3.25 KB

Whoops, forgot to attach the file...

ookello’s picture

That fixed it. No more warnings.

Thanks much. :)

kong’s picture

Status: Active » Fixed
ookello’s picture

StatusFileSize
new105.54 KB

I guess that did introduce a minor bug in the comment display. For unauthenticated users the comment display below the title does not show up correctly. It displays correctly for authenticated user.

I have attached a screenshot. Left window is for the authenticated user, and right unauthenticated.

Here is the html for authenticated user:

for unauthenticated user:

Login or register to post comments

Not sure if i should open up a new issue for this?

kong’s picture

Ah... that's the same issue as #442694: login to post comment displays as html, which I already fixed in CVS.

You may want to download the 6.x-1.x-dev package OR you can modify template.php by copy & paste the code in green background on this page :)

Status: Fixed » Closed (fixed)

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