Question

I am new to drupal theme . I have created a direcory mytheme and added mytheme.info to it and copied other files from drupal's default theme directory . Now after editing the page.tpl.php, drupal is showing the errors below .

Notice: Undefined variable: hide_site_name in include() (line 99 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined variable: hide_site_name in include() (line 109 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: featured in include() (line 168 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: highlighted in include() (line 187 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: sidebar_second in include() (line 212 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_first in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_middle in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_last in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_firstcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_secondcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_thirdcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_fourthcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).

After searching on google, I have found that clearing cache will solve the problem . But even after clearing my cache,it remains the same !

Was it helpful?

Solution

Generally these errors occurred when you call a region in your page.tpl.php file that doesn't exist in the theme's .info file.

In your page.tpl.php:

$page['footer_firstcolumn'];

In your theme's .info:

regions[footer_firstcolumn] = Footer first column

After rechecking all regions, don't forget to flush the cache.

OTHER TIPS

If you want to create a fresh theme best practice is to use something like Zen. It's blank and fully customizable.

As long as you follow the prescribed instructions, you will avoid nasty errors like the ones you have above

i had almost the same problem of messages saying "Notice: undefined index: myIndex in include() (line n in some/path/myPage.tpl.php)" whe i was coding my custom sub-template

I kind of solved the problem using php's function isset() for every line told in the Notice message.

For example in your line 99 i would use:

if(isset(hide_site_name)){
    //use hide_site_name in the normal way
}

or in your line 168

if(isset( some_var[featured] )){
    //use "featured" index in the normal way
}

hope this helps someone as this helped me after a long time searching for a solution. i never found the cause of this behavior btw. sorry for bad grammar, if there's any.

I had the same problem after creating a sub theme and I followed the answer by Meiker and it worked great about including isset. But as I do not have a lot of experience with programing I ran into a snag with line 220 and multiple triptych in the same line.

Notice: Undefined index: triptych_first in include() (line 220 of C:\wamp\www\dtest\sites\all\themes

So I added isset like this:

if(isset($page['triptych_first']) || (isset($page['triptych_middle']) || (isset($page['triptych_last'])))) :

and did the same for similar error lines and now I do not have any more errors appearing.

I hope this helps others who are programming challenged.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top