2

I have a "page--front.tpl.php" and get these notices:

Notice: Undefined index: nodes include() (line 47 in file /home/dunmicro/public_html/sites/all/themes/dunartis/page--front.tpl.php).

Notice: Trying to get property of non-object include()(line 47 in file /home/dunmicro/public_html/sites/all/themes/dunartis/page--front.tpl.php).

Here is my code:

<?php if ($site_name): ?>
    <?php if ($title): ?>
      <div id="site-name"<?php if ($disable_site_name) { print ' class="hidden"'; } ?>>
        <strong>
          <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home">
                      <span><?php print $page['content']['system_main']['nodes']['63']['#node']->title; ?></span></a>
        </strong>
      </div>
    <?php else: /* Use h1 when the content title is empty */ ?>
      <h1 id="site-name"<?php if ($disable_site_name) { print ' class="hidden"'; } ?>>
        <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home">
                    <span><?php print $page['content']['system_main']['nodes']['63']['#node']->title; ?></span></a>
      </h1>
    <?php endif; ?>
  <?php endif; ?>

How do I fix these notices?

1 Answer 1

2

You need to check if $page['content']['system_main']['nodes'] is set or not:

Please check updated code:

<?php if ($site_name): ?>
    <?php if ($title): ?>
      <div id="site-name"<?php if ($disable_site_name) { print ' class="hidden"'; } ?>>
        <strong>
          <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home">
                      <span>
<?php if(isset($page['content']['system_main']['nodes'])):?>
<?php print $page['content']['system_main']['nodes']['63']['#node']->title; ?>
<?php endif;?>
</span></a>
        </strong>
      </div>
    <?php else: /* Use h1 when the content title is empty */ ?>
      <h1 id="site-name"<?php if ($disable_site_name) { print ' class="hidden"'; } ?>>
        <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home">
                    <span>
<?php if(isset($page['content']['system_main']['nodes'])):?>
<?php print $page['content']['system_main']['nodes']['63']['#node']->title; ?>
<?php endif;?>
</span></a>
      </h1>
    <?php endif; ?>
  <?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.