Invalid argument supplied for foreach in template.php
You may have just recovered from a ‘White screen of death’ and having now activated PHP’s error reporting as in my blog posting here.
Now that you have found what the error is: (mine specifically was)
* warning: Invalid argument supplied for foreach() in /htdocs/mythemename/sites/all/themes/mythemename/template.php on line xxx.
(xxx could be pretty much any line number depending on your template)
I found the fix on a lullabot node on the Drupal site, but it did take some digging to find and so even if it’s just for my own reference I’m adding the solution here so when I build my next Drupal website I’ll at least have a record of – and solution to all the problems I came across developing a Drupal site.
Find the template.php file in sites/all/themes/mythemename and look for the code:
if ($object->uid && $object->name) {
And then change it to this:
if ($object->uid && $object->name && module_exists(‘profile’)) {
It works like a charm, refresh your page and boom! Error gone.
Comments
Powered by Facebook Comments
Related posts:
- WordPress – PHP Warning: Invalid argument supplied for foreach() in php … on line 86
- Drupal 6.x Why do I see candidate function names and not candidate template files?
- Drupal – The selected file… could not be uploaded. Only JPEG, PNG and GIF images are allowed
- Ubercart – This transaction is invalid. Please return to the recipient’s website to complete your transaction using their regular checkout flow.
- I hate pepperjam.com
- Access denied – Drupal 6.x
- Drupal 6.x Countries_api – Data too long for column ‘iso3′ at row 1 query: INSERT INTO countries_api_countries
Leave a Reply
Hot Topics
- WordPress Contact Form 7 & WP-Mail-SMTP problem solved
- How to take Ownership of a Drive, Folder or File in Windows 7
- The environment variable Home is not set (Solved)
- Excel 2007 sort columns & rows data.
- Failed to initialize OpenGL (Checklist)
- Android SDK Manager won’t start (Solved)
- Creating a Drupal 6 custom login form – Step by Step tutorial.
- Android requires compiler compliance level 5.0 or 6.0. Found ’1.7′ instead. Please use Android Tools > Fix Project Properties.
- IIS7 – No HTTP redirect icon
- 7129/6105195 Edward Leedskalnin’s anti-gravity – How he built Coral Castle.
Archives
- April 2013
- March 2013
- February 2013
- December 2012
- November 2012
- July 2012
- June 2012
- May 2012
- February 2012
- November 2011
- September 2011
- August 2011
- June 2011
- January 2011
- December 2010
- November 2010
- October 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- January 2009
- December 2008
- August 2008
- June 2008
