1

How do you check if logo/sitename/slogan & secondary links are enabled from within a function? (outside of preprocess_page)

This seems to work for logo:

$logo = theme_get_setting('logo');
if (empty($logo)) {
...
}

but this doesn't for secondary links:

$secondary_links = theme_get_setting('toggle_secondary_links');
if (empty($secondary_link)) {
...
}
1
  • Your example sets $secondary_links but then checks empty($secondary_link). Assuming that error is not unique to your example, that may be your problem. Jun 7, 2012 at 12:33

1 Answer 1

1

$secondary_links = theme_get_setting('toggle_secondary_links'); is working fine.

It doesn't work if secondary menu is disabled form admin/appearance/settings

It works when secondary menu is disabled form admin/appearance/settings/theme-name

OR

It works when secondary menu is disabled form admin/structure/menu/settings source of Source for the Secondary links is set to 'No Secondary links'

4
  • So.. is there a reliable method to check if it and sitename/slogan are present or not from outside of the preprocess_page function in all of these circumstances?
    – krisbulman
    Jun 7, 2012 at 11:39
  • use variable_get('menu_secondary_links_source') or $theme_settings = variable_get('theme_mytheme_settings'); $theme_settings['toggle_secondary_menu']; see $theme_settings for further details.
    – jibran
    Jun 7, 2012 at 12:41
  • Thanks, I neglected to dsm theme_settings, and was using toggle_secondary_links instead of toggle_secondary_menu.
    – krisbulman
    Jun 7, 2012 at 14:37
  • Another problem I have with this method, is that if the items in the secondary links menu are tied to permissions (such as my account, and login).. then when logged out the menu does not appear, however the value still returns true. I understand why this is happening, but is there any way to check if the menu has links?
    – krisbulman
    Jun 9, 2012 at 17:00

Your Answer

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

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