Hey,
I'm pretty new to drupal, and was advised to get the latest version 7 to do what i needed it to do. I am adding an if clause to the title section of the page.tpl.php so if the node type is image then no title is printed. It seems to work, the title is only visible on pages that are not images, but I keep getting the error message:
Notice: Undefined variable: node in include() (line 125 of /sites/all/themes/angel/templates/page.tpl.php).
Is it a bug, or am I doing something incorrectly. code line is:
<?php if ($node->type !== 'image'): print '<h1 class="title" id="page-title">'; ?> <?php print $title; endif; ?></h1>
Many thanks for any help in advance.
Comments
Comment #1
danillonunes CreditAttribution: danillonunes commentedSome pages are not related to any node (like the user/login page, for example), so the variable $node is not defined.
Try:
if ($node && $node->type !== 'image'):
Comment #2
agbwatson CreditAttribution: agbwatson commentedTried that, cleared all the cache, but still got an undefined variable error message. For now, I've got round it by removing the title from the page.tpl.php and adding my own field for when I need it.
Thanks very much for the info, I'm certain I'll need that code as I delve further into customizing!
Comment #3
danillonunes CreditAttribution: danillonunes commentedagbwatson,
so try instead:
Or you can do it changing the theme_preprocess_page into template.php (read the "CREATE OR MODIFY VARIABLES FOR YOUR THEME" instructions in your template.php file for more details. That's way is better, IMHO, because you keep the logic out of the .tpl files.
Also, note that this is not really a Zen bug.
Comment #4
agbwatson CreditAttribution: agbwatson commentedChanging in the template.php worked like a charm. Thanks so much for the help.
I put this in the bug area, as I believed at the time it was. That's the problem with not knowing quite enough about php yet...but learning. Thanks again.
Comment #5
agbwatson CreditAttribution: agbwatson commentedComment #6
alex.87 CreditAttribution: alex.87 commentedHey i have similar issue like agbwatson. I use this code to get my widgets in sidebar:
And i keep getting error
Notice: Undefined property: stdClass::$field_adds in include() (line 69 ofhome/dev2fabr/public_html/QPQ/sites/all/themes/qpq/page.tpl.php).
any sugestions?
Comment #7
artwreck CreditAttribution: artwreck commentedTry
Comment #8
knalstaaf CreditAttribution: knalstaaf commentedI must say this code from #3 works (added a missing bracket):
I wouldn't recommend the method in #7 or the short line in #3. Both removed the page title of my View page displays as well.
Comment #9
knalstaaf CreditAttribution: knalstaaf commentedComment #10
stewit CreditAttribution: stewit commentedI found that the short code from #3 worked for me, as I was trying to load a different template file if it was a forum page.
This is what I used for those in the future that require overriding all the forum pages and articles;
Placed this in my page.tpl.php file. Works fine for me.
Comment #11
batuka CreditAttribution: batuka commentedPls I have a similar problem, I'm getting this error:
Notice: Undefined variable: image in include() (line 1 of /Applications/mampstack/apache2/htdocs/xxxx/sites/all/modules/views_bootstrap/templates/carousel/views-bootstrap-carousel-plugin-rows.tpl.php).
Please help
Comment #12
apadernoNotice that this issue has been posted in issue queue for a sandbox project without code. It's not an issue queue to ask support for, or post bugs in, Drupal core or third-party modules.
Despite the project name, this sandbox project is not linked to Drupal core in any way, and it may be removed at any time.