[support] Sub-theme

Jamie Holly hovercrafter at earthlink.net
Fri Oct 11 03:31:48 UTC 2013


The only requirements in the .info file are name, core and base theme 
(for a sub-theme). Description is optional, but highly recommended. 
Version can be put in for your own usage, but if you are planning on 
releasing it on Drupal.org, then remove it. Drop the package = Core line.

Yes the database does need to know information about the theme. Whenever 
you change something in a .info file, add a new .tpl.php or add a 
template override in your template.php file, you must clear Drupal's 
cache. If you're doing a lot of this, I highly suggest intalling the 
admin_menu module so you can clear the cache right from the toolbar 
(alternatively use Drush). The caching is all tied to performance. 
Without it Drupal becomes a huge anchor.

If you specify a base theme in your .info file, those CSS files are 
loaded first. You can then override the rules in your new theme's CSS 
files. Also any .tpl.php files in the base theme will be used, unless 
you have those files in your theme. The theme layer will look in your 
theme, then in any base themes (it's not uncommon to have 2 or even 3 
base themes). If not found then it will use the theme function/template 
specified in the module that declared the theme.

Here's a good page on making a sub-theme of Bartik:

https://drupal.org/node/1114190

But the biggest thing that always catches people is the caching issue. 
Make sure you clear that cache when making the changes I outlined above, 
and if something isn't acting right, go ahead and clear the cache 
anyways. It won't hurt anything and a lot of times you find out that was 
the culprit.

Jamie Holly
http://hollyit.net

On 10/10/2013 11:03 PM, Roger wrote:
> <snip>
> So, either the database must be updated somewhere, somehow, by someone,
> -- OR -- Drupal must look at the filesystem and realize that there is
> more to the story than the database knows and extend the list. So, how
> does Drupal become aware of the custom sub-theme?
> </snip>
>
> I'm lost as to why you want to do this, because what you want doesn't
> make sense but here goes:
>
> Drupal default core reads core themes, if theme not found reads
> /sites/default/themes/
>
> Ok here's what I did just now!.
> Created /sites/all/themes/Bartik_cfm folder. Underscore not hyphen,
> explained below!
> Copied bartik.info over to this folder, renamed it Bartik_cfm.info
>
> Copied stylesheets[all][] = css/layout.css to the Bartik_cfm/css and
> renamed to stylesheets[all][] = css/local.css
>
> Deleted everything in the .info file except:
>
>    name = Bartik_cfm
> description = Yadda Yadda Yadda stuff about the copy.
> package = Core
> version = VERSION
> core = 7.x
>
> stylesheets[all][] = css/local.css
>
> version = "7.23"
> project = "drupal"
> datestamp = "1375928238"
>
> Notes:
> -- If the Theme name has a hyphen it will not work - It seems to require
> an underscore.
> -- Underscore is a recognised variable name separator in php, ruby and
> other languages, hyphen can be interpreted as a minus sign. Avoid
> hyphens in names and terms.
> -- The last 3 lines are required in the info file or it won't work (for
> me). Don't know why!
>
> Hope this helps
> Roger
>
>



More information about the support mailing list