My watchdog gets a bunch of errors:

Notice: Undefined variable: base_path in genesis_theme() (line 24 of /Users/rcourtna/Projects/wpg/sites/all/themes/genesis/genesis/template.php).

Line 24 is:

include_once $base_path . drupal_get_path('theme', 'genesis') . '/template.conditional-styles.inc';

$base_path is not a variable available to the function. Should it be $GLOBALS['base_path'] ?

function genesis_theme(&$existing, $type, $theme, $path){
  
  // Compute the conditional stylesheets.
  if (!module_exists('conditional_styles')) {
    include_once $base_path . drupal_get_path('theme', 'genesis') . '/template.conditional-styles.inc';
    // _conditional_styles_theme() only needs to be run once.
    if ($theme == 'genesis') {
      _conditional_styles_theme($existing, $type, $theme, $path);
    }
  }  
  $templates = drupal_find_theme_functions($existing, array('phptemplate', $theme));
  $templates += drupal_find_theme_templates($existing, '.tpl.php', $path);
  return $templates;
}

Comments

ryan_courtnage’s picture

Actually, after looking at this again, I'm not sure that "$base_path" has any business being in the include_once line. IMHO, it should look like:

include_once drupal_get_path('theme', 'genesis') . '/template.conditional-styles.inc';
yoroy’s picture

Confirming this issue. I get:

notice: Undefined variable: primary_menu in /Users/yoroy/Sites/d6/sites/all/themes/ark/templates/page/page.tpl.php on line 152.
notice: Undefined variable: secondary_menu in /Users/yoroy/Sites/d6/sites/all/themes/ark/templates/page/page.tpl.php on line 152.
notice: Undefined variable: base_path in /Users/yoroy/Sites/d6/sites/all/themes/genesis/genesis/template.php on line 24.
Jeff Burnz’s picture

base_path is redundant and can ship out (committed to DEV) but the other undefined variables I can't reproduce, whats your environment yoroy, I'm running E_ALL as per normal and can't seem to trigger the notices in 6.x-2.4.

Just asking in case you know, but if the notice occurs on line 152 then why not again on lines 155 and 159? 152 is just there to add a conditional wrapper DIV (which IMO has turned out to be a bit redundant) and could be removed.

152    <?php if ($primary_menu or $secondary_menu): ?>
153      <div id="nav" class="clear-block">

Note, in the DEV version I've changed the way the primary_menu/secondary_menu vars are built, to bring it inline with my other themes, I've been meaning to commit that for a long time, so maybe try the DEV version and see it you get the same issue although I'd really like to suss this out, its odd that I don't get the notices (Apache2/PHP5.2.12/Win7 and Apache2/PHP5.2.11/Ubuntu).

ryan_courtnage’s picture

Jeff,

FYI, my Genesis_SUBTHEME subtheme was also giving undefined notices for $primary_menu and $secondary_menu. To eliminate, I added 'isset':

    <?php if ((isset($primary_menu) && $primary_menu) or (isset($secondary_menu) && $secondary_menu)): ?>
      <div id="nav" class="clear-block">

        <?php if (isset($primary_menu) && $primary_menu): ?>
          <div id="primary"><?php print $primary_menu; ?></div>
        <?php endif; ?>

        <?php if (isset($secondary_menu) && $secondary_menu): ?>
          <div id="secondary"><?php print $secondary_menu; ?></div>
        <?php endif; ?>

      </div> <!-- /nav -->
    <?php endif; ?>

PHP 5.2.6
MAMP
E_ALL

Jeff Burnz’s picture

@ryan - yes, that's the obvious solution, I still am baffled why you guys are getting the notices and I am not!

You can clean that up a bit...

    <?php if (isset($primary_menu) or isset($secondary_menu)): ?>
      <div id="nav" class="clear-block">

        <?php if (isset($primary_menu)): ?>
          <div id="primary"><?php print $primary_menu; ?></div>
        <?php endif; ?>

        <?php if (isset($secondary_menu)): ?>
          <div id="secondary"><?php print $secondary_menu; ?></div>
        <?php endif; ?>

      </div> <!-- /nav -->
    <?php endif; ?>
marcvangend’s picture

I'm getting a similar error after unchecking the logo check box at /admin/appearance/settings/genesis_mytheme:

Notice: Undefined variable: site_logo in include() (line 20 of D:\www\d7\sites\all\themes\genesis_mytheme\templates\page.tpl.php).

However I do not really like 'the obvious solution' as Jeff calls it. First of all, there is a difference between if (isset($site_logo) && $site_logo) and if (isset($site_logo)). See this example:

$foo = '';
if (isset(foo)) {
  // Code here will be executed.
}
if (isset($foo) && $foo) {
  // Code here will NOT be executed.
}

All these isset() statements will make the .tpl.php more complex than needed, especially for new Drupal developers and people with limited php skills.

Instead, I think this should be solved in template.php. If you just initialize the variables like this:

  // Set variables for the logo and site_name.
  $vars['site_logo'] = ''; // This line was inserted on line 53 of genesis/template.php.
  if ($vars['logo']) {
    $vars['site_logo'] = '<a href="'. $vars['front_page'] .'" title="'. t('Home page') .'" rel="home"><img src="'. $vars['logo'] .'" alt="'. $vars['site_name'] .' '. t('logo') .'" /></a>';
  }

Then you can be sure that the variables always set and you can keep using the simple if ($site_logo) syntax.

jpw1116’s picture

Version: 6.x-2.4 » 7.x-1.x-dev

In D7 Alpha 4, on a very "Drupal friendly" hosting service, I *just* installed my first instance of a Genesis subtheme . . . yet can't even set the favicon.

It's identical to marcvangend's "Undefined variable . . . line 20" (through line 23) errors and I agree, this is complex for new Drupal developers. (Cue raised hand now!)

Is there any plan to prioritize an update?

Jeff Burnz’s picture

Yeah for sure, just trying to find the time at the moment, been so busy on Bartik and Corolla for Drupal core, looks like my effort on those should be wrapping up soon so I can work on my own projects!

jpw1116’s picture

Great, thank you. I appreciate all the effort you have been making, no doubt!

Plus, I noticed that some of the checkboxes in the settings of the Genesis subtheme were not sticky. I was eventually able to reselect the right ones and get the default favicon to show, but still no custom one.

I'll continue to test out Genesis on 7 Alpha 4.

Jeff Burnz’s picture

See what crops up, theres been a lot of changes in Drupal since I made the last commit for Genesis D7, so if quite out of date and lots of things to fix and repair.