Hi all,

I'd like to use the Bartik theme with some modifications for my Drupal 7 site. I thought the best way to do this is to create a child theme of Bartik, but this is proving to be quite difficult for me (and I couldn't find any help on this after scouring the web and forums for a few hours). I created a "BartikChild" theme by:

  1. Creating sites/all/themes/BartikChild
  2. Creating a file within that folder called BartikChild.info that looks like this:
    name = BartikChild
    description = A child theme of Bartik.
    package = Core
    version = VERSION
    core = 7.x
    base theme = Bartik
    

After I enable the theme, I see the following error on my home page (or any page for that matter):

Notice: Trying to get property of non-object in drupal_alter() (line 981 of /Applications/MAMP/htdocs/drupal-7.0/includes/module.inc).
[This message repeats several times]
Notice: Undefined index: Bartik in drupal_theme_initialize() (line 99 of /Applications/MAMP/htdocs/drupal-7.0/includes/theme.inc).
Notice: Trying to get property of non-object in phptemplate_init() (line 13 of /Applications/MAMP/htdocs/drupal-7.0/themes/engines/phptemplate/phptemplate.engine).
Notice: Trying to get property of non-object in drupal_alter() (line 981 of /Applications/MAMP/htdocs/drupal-7.0/includes/module.inc).
Notice: Trying to get property of non-object in drupal_alter() (line 981 of /Applications/MAMP/htdocs/drupal-7.0/includes/module.inc).
[This message repeats quite a few more times]
Notice: Trying to get property of non-object in _theme_build_registry() (line 523 of /Applications/MAMP/htdocs/drupal-7.0/includes/theme.inc).
Notice: Trying to get property of non-object in _theme_build_registry() (line 525 of /Applications/MAMP/htdocs/drupal-7.0/includes/theme.inc).
Notice: Trying to get property of non-object in _theme_build_registry() (line 527 of /Applications/MAMP/htdocs/drupal-7.0/includes/theme.inc).
Notice: Trying to get property of non-object in _theme_build_registry() (line 527 of /Applications/MAMP/htdocs/drupal-7.0/includes/theme.inc).
Notice: Trying to get property of non-object in drupal_alter() (line 981 of /Applications/MAMP/htdocs/drupal-7.0/includes/module.inc).
[This message repeats about 20 more times]

I tried clearing my theme registry cache through Drush in hopes that would help, but nothing changed. I ideally want to have a child theme of Bartik since Bartik will be well-maintained, but because this wasn't working, I even tried copying the entire Bartik folder to my sites/all/ and renaming the theme to "BartikCopiedUnmodified" (i.e., I changed the name in the .info file, renamed bartik.info to bartikCopiedUnmodified.info, and changed the folder name to sites/all/BartikCopiedUnmodified). After enabling this theme, this seemed to work initially. However, when I refreshed the site, I saw this error message:

Notice: Undefined variable: hide_site_name in include() (line 99 of /Applications/MAMP/htdocs/drupal-7.0/sites/all/themes/bartikCopiedUnmodified/templates/page.tpl.php).
Notice: Undefined variable: hide_site_name in include() (line 109 of /Applications/MAMP/htdocs/drupal-7.0/sites/all/themes/bartikCopiedUnmodified/templates/page.tpl.php).
Notice: Undefined variable: hide_site_slogan in include() (line 116 of /Applications/MAMP/htdocs/drupal-7.0/sites/all/themes/bartikCopiedUnmodified/templates/page.tpl.php).

This didn't go away even after I cleared the theme registry cache. Any insight as to what I can do to make my child theme work? Is there a better way to do this?

Thanks in advance.

Comments

brightbold’s picture

I am not an info file expert but here are a couple of changes you should make:

  • You should remove the "package" line — this tells drupal how to group your module or theme (for modules, this determines what fieldgroup they appear in on the modules page; I'm not sure how it's used for themes, since they're grouped by enabled/disabled in D7), and since your theme is not a core theme, take that out. (I doubt it's causing any problems though.)
  • According to http://drupal.org/node/171205, "version" is discouraged, so remove that line too. Also not the root of your problem, however.
  • I think this next one may do the trick: on the "Base theme" line, Drupal is looking for the machine name of the theme, which is usually lowercase. So if you change it to "bartik" I think your problem will be fixed.

If you download a copy of the Zen theme, it comes with a folder called STARTERKIT to use as a starting point for making a child theme of Zen. Even though it's Zen-specific, it's helpful as a reference for making sub-themes of other themes. For instance, you can see how they've written a child theme info file and use that as a model to create your own.

I hope this solves your problem!

viv1234’s picture

Thanks a lot! Making those changes seems to have solved the problem.

PhilipReed’s picture

Just confirming that worked for me too -- FTR, deleting the package line was the incremental change that appeared to do it. [EDIT: but then the problem came back -- so i'd better troubleshoot more carefully.]

walzo’s picture

Hi,

I've run into the same exact issue trying to create a Bartik sub-theme (same error description).

I've deleted 'version,' 'package' and changed 'Bartik' to lower-case. I'm still seeing the same issue. Any ideas?

brightbold’s picture

@walzo - Did you clear your cache? Whenever you change the .info file you have the clear the cache for the changes to take effect. If you've already done that, I'm stumped.

pjaxon’s picture

Thanks much, BrightBold... I had core listed and also referred to the base theme without all lowercase. Solved

niccottrell’s picture

I'm still having the problem after a cache reset. My subtheme.info is:

name = BRIDGE Eval
description = Extension of Bartik for the Evaluation system
core = 7.x
base name = bartik

stylesheets[all][] = css/overrides.css

--- repeat of regions from bartik.info ---

I've tried with Performance > aggregation both de- and enabled... What's next to check?

Is it fine to leave bartik in ROOT/themes/bartik and have my subtheme in /sites/mysite/themes/subtheme ?

niccottrell’s picture

I'm an idiot! "base name" should be "base theme" obviously!!!

kurageart’s picture

Hi, I created a nice working baritik subtheme just following this guide:
http://drupal.org/node/225125
My info file structure is:

name = Mytheme
description = Whatever
core = 7.x
base theme = bartik
stylesheets[all][] = css/colors.css
stylesheets[all][] = css/overrides.css
regions[header] = Header
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[highlighted] = Highlighted

regions[featured] = Featured
regions[content] = Content
regions[sidebar_first] = Sidebar first
regions[sidebar_second] = Sidebar second

regions[triptych_first] = Triptych first
regions[triptych_middle] = Triptych middle
regions[triptych_last] = Triptych last

regions[footer_firstcolumn] = Footer first column
regions[footer_secondcolumn] = Footer second column
regions[footer_thirdcolumn] = Footer third column
regions[footer_fourthcolumn] = Footer fourth column
regions[footer] = Footer

Note that, as suggested, I copied regions rows, since in the guide is written that those will not be inherited...
To have the "colors" module working, I copied "colors.css" from bartick css folder to my new theme css folder, and the entire colors
folder from bartik theme to my subtheme menu. So I can have separated setting for admin and viewers browsing..

If you find better-lighter approach, please let me know!