Framework 7.x-3.4

I have created a subtheme in the usual fashion but get this error

Warning: Invalid argument supplied for foreach() in theme_links() (line 1441 of /home/karljaco/public_html/includes/theme.inc).
Warning: Invalid argument supplied for foreach() in theme_links() (line 1441 of /home/karljaco/public_html/includes/theme.inc).

any ideas on how to clear it?

Comments

brettm’s picture

I'm getting the same error. Any solution?

checker’s picture

I have the same error and it happens in framework_preprocess_page() in template.php. I'm using a sub theme.

elpino’s picture

My fix was to delete all functions from template.php copied from the original template files leaving only
<?php

Maybe deleting the file altogether if you aren't using it will work too.

I was accustomed to renaming functions with my own theme name, maybe template_preprocess_page() has an issue being redefined in the same way twice... I dunno.

elpino’s picture

Status: Active » Needs review
tim.plunkett’s picture

In the parent theme, template_preprocess_page() passes the array $vars['main_menu'] to theme_links__system_main_menu(), and then overwrites $vars['main_menu'] with the resulting string. The subtheme comes with the same code, except now instead of being an array, $vars['main_menu'] is a string, hence the error.

Core and Zen get around this by calling theme_links__system_main_menu() directly in the page.tpl.php, which isn't necessarily the best solution. One way to fix this would be something like this:

In the parent theme:

if (isset($vars['main_menu'])) {
  $vars['main_menu_links'] = $vars['main_menu'];
  $vars['main_menu'] = theme('links__system_main_menu', array(
    'links' => $vars['main_menu_links'],
    'attributes' => array(
      'class' => array('links', 'main-menu', 'clearfix'),
    ),
    'heading' => array(
      'text' => t('Main menu'),
      'level' => 'h2',
      'class' => array('element-invisible'),
    )
  ));
}
else {
  $vars['main_menu'] = FALSE;
}

In the sub theme:

if (isset($vars['main_menu_links'])) {
  $vars['main_menu'] = theme('links__system_main_menu', array(
    'links' => $vars['main_menu_links'],
    'attributes' => array(
      'class' => array('links', 'main-menu', 'clearfix'),
    ),
    'heading' => array(
      'text' => t('Main menu'),
      'level' => 'h2',
      'class' => array('element-invisible'),
    )
  ));
}
andregriffin’s picture

I see. The next version of Framework will use the default method of rendering the menus. The D6 branch already does this, and the next release of the D7 branch will be identical to what is found in the "Stark" page.tpl.

andregriffin’s picture

Status: Needs review » Reviewed & tested by the community
andregriffin’s picture

Status: Reviewed & tested by the community » Fixed

fixed in 3.6

tim.plunkett’s picture

Please read over http://drupal.org/node/52287, it explains how to write proper commit messages. Each fix from each issue should have a separate commit with a descriptive message.

andregriffin’s picture

Yeah, my working habits are probably not too great in this regard. Currently, I make changes as I see fit, address any open issues, and generally get the new incarnation into a state that's release-ready. Then I write up a rough list of changes, and commit the whole thing. That probably sounds nightmarish for thorough developers and users. I'll change my ways after I push this D6 port of the 7x branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

payamspot’s picture

Thanks elpino. Deleting everything except "<?php" in template.php did the work.

hairidine’s picture

Issue summary: View changes