Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ju-73 on
Hello!
I'm trying to build my own theme from scratch to have only what I need for my sites.
I have less regions than the system's own, and I get an error :
Notice : Undefined index: sidebar_first dans include() (ligne 138 dans /.../modules/system/page.tpl.php).
The "sidebar_first" region isn't used in my theme, causing an error.
The regions I'm using are declared in the .info file and show up correctly in the blocks page, but aparently my page.tpl.php doesn't fully override the one from the system. Any idea what I should do ?
Thank you !
Comments
examples of code used
Regions from my theme :
I placed my custom page.tpl.php in my_theme/templates/system/
suppressed the two paragraphs :
if ($page['sidebar_first']):
print render($page['sidebar_first']);
endif;
if ($page['sidebar_second']):
print render($page['sidebar_second']);
endif;
I added my own regions, which didn't cause any problems.
Did you clear the cache after
Did you clear the cache after creating that new page template file? In Drupal 7 you can enable theme debugging which will help you verify which template file it's using.
Woolwich Web Works: Custom web development
Thanks
Well that was the only thing I was sure about and thought I had done... but probably forgot or cleared the caches on the wrong site..
I checked about theme debugging, I'll do it :
$conf['theme_debug'] = true;
line to add in settings, right ?
Thanks again
How do I switch the question to resolved ?
You're trying to include
You're trying to include sidebar_first and sidebar_second, but those are not defined in your theme.
Subject ok
Thank you for your answer Jaypan, but no, I'm not trying to include sidebar_first and sidebar_second because I don't want them in my theme ; my page.tpl.php simply hadn't overwritten the one from Drupal's core yet (which was, as you say, trying to include the regions).
Thanks to Megan M who reminded me to check twice the logical things even if you think it's ok, the caches are now cleared, the new page.tpl has taken over, everything is fine !
I'm trying to remember how to pass the subject to resolved..
Thanks again to you both