I did the following steps to try and create a bartik sub-theme.
1. Created a folder in my sites themes folder called bartik-sub
2. Created a .info file called bartik-sub.info which looks like this:
name = Bartik Sub-Theme
description = A sub-theme of Bartik.
package = Core
version = 1.0
core = 7.x
engine = phptemplate
base theme = bartik
stylesheets[all][] = css/custom.css
3. Created a "custom.css" file and placed it within a folder called "css." which is in my themes folder.
For testing within my custom.css file I put
body {
color: #F00;
}
4. Cleared All Caches. configuration > performance > clear all caches
5. Enabled bartik-sub and set it as the default theme. Also made sure the original bartik is enabled.
---------------------------------------------------------------------------------------------------------------------------------------------
Instead of the body text turning red I get about 10 errors that look like this, here are the first 2 errors out of 10:
# Notice: Undefined index: featured in include() (line 168 of C:\Documents and Settings\lpinho\Desktop\Drupal\drupal-7.0-beta1\themes\bartik\templates\page.tpl.php).
# Notice: Undefined index: triptych_first in include() (line 220 of C:\Documents and Settings\lpinho\Desktop\Drupal\drupal-7.0-beta1\themes\bartik\templates\page.tpl.php).
Note: I tried this method changing my base theme to stark. All body text turned red and everything worked properly. So my method works perfect with Stark.
Is bartik a theme that you can't make a sub-theme for???? Am I making a dumb mistake???? Please let me know how I should setup a working Bartik sub-theme.
Comments
Try defining the regions on
Try defining the regions on the .info file. Copy from bartik .info file.
hope it helps...
_
That did the trick for me, thanks.
This might be helpful
http://drupal.org/node/1028196
delete the template.php file
Did you delete the template.php file. I was having trouble setting up a sub theme and realised that you needed to delete this in order for it to work. Hope this helps...
I don't think the
I don't think the template.php should be deleted but rather the occurences of 'bartik' should be replaced by the new sub-theme name for instance 'bartiksub'.
I did this and it seems ok but I am having troubles with the color (module) settings causing errors and the wrong color being used for the header top and bottom (apparently taken/inherited from bartik).
If someone could confirm that a sub-theme of bartik is possible with a normally working color module it would be interesting to know how it was done.
EDIT:
Ok I finally managed to get it work correctly, at least until now... :)
Here is what I did to get rid of all these errors:
1) I disabled the color module (core)
2) I deleted all the folders in ...sites/default/files/color
3) I re-enabled the color module and saved the default scheme on bartiksub (which created a new bartiksub folder in the color folder as mentioned in 2) above. NB: Before there was absolutely no color styling left (browser default colors I guess).
I also tested with bartik and the color styles are normal on both themes now. My statement in brackets above about the color being inherited is wrong. The colors were actually taken from the colors.css file under themes/bartik/css and I was mistaken because I thought that my colors.css file which I copied over to my bartiksub directory was the original one but this was not true. So I retrieved the original one from a former backup.
Anyway I hope this will help others trying to have a bartik sub-theme to work. :)
This was what ended up working for me
I found these steps which were posted by someone else when I searched google.
1. Copy the bartik theme from \themes
2. Paste it into \sites\all\themes
3. Rename the folder to mytheme (obviously replace mytheme with whatever name you like)
4. Open the folder and rename bartik.info to mytheme.info
5. Delete the template.php file (or empty its contents)
6. Open mytheme.info and add the line "base theme = bartik" under the line core = 7.x
7. Find the line stylesheets[all][] = css/style.css and rename style.css to mytheme.css
8. Navigate to mytheme/css and rename the style.css file to mytheme.css
Everything works perfectly, color module etc.
works perfectly !
above posted workflow works like a charm
obvious note : the template.php file can indeed be deleted cause of the base theme reference.
All later templating functions that apply to the newly created (sub)theme should just be added to the (then newly created) template.php in the subtheme folder.
are you saying the code in
are you saying the code in sub-theme template.php is stacking on top of base theme template.php? So two template.php having the same code will crash the display, but having different template.php coding is ok.
More on sub-theme template.php
Yes. Copying template.php like that without deleting it, will result in duplicate function declarations. For example
bartik_preprocess_html()will be declared once in themes/bartik/template.php and then in sites/all/themes/mytheme/template.php and PHP does not allow a function to be declared more than once.To make own variations of the functions in the base theme template.php, copy the code to the subtheme template.php and simply substitute the function prefix with your own theme name, for example
mytheme_preprocess_html().The code in template.php is inherited, so if you don't want to alter it in your sub-theme, you just delete it from your subtheme folder.
See Creating a sub-theme.
one more step required for me
even trying all the above (and more) I could not get the colours chosen in 'settings' to show up on live pages, only in the preview.
A directory was being created correctly in sites/default/files/color which had the styles defined etc, but this generated stylesheet was not being referenced when pages were rendered - the default Bartik colors.css was being referenced instead
eventually, I tracked it down to this line in colors.module, which is meant to rewrite the css paths
if (basename($old_path) == basename($color_path))
so the rewrite only happens if there is a file of the same name defined in the sub theme. None of the instructions I've read told me that my sub theme had to include colors.css, so there was nothing to rewrite
TL;DR .... add
stylesheets[all][] = css/colors.css
to your_sub_theme.info
P.S. ..... It was also necessary to copy the 'color' directory from the base theme directory to my sub theme directory
Still doesn't work :(
I followed the steps mentioned here very very carefully and unfortunately it still doesn't work... The website is currently up here, any help would be really appreciated...
Just minutes after posting i
Just minutes after posting i found my issue :) I was overwriting the CSS generated by the color module with my mysite.css. Copy/paste code really is an antipattern...
Instructions followed... but?
Followed the instructions above[very clear] and checked for the colors css statement in the info file, so far so good.
when i went to set as default to try out the sub theme, there were two Bartiks enither one indicating which was the sub-theme and which the original Bartik.
to add confusion, bioth themes when activated/set as default, showed altered theme colours and a main menu hover colour that has been added. but with the original TNR font.
So it seems I have some old and some new.
My questions are:
How is the sub-theme defined/identified through admin>appearance>
Do I need to rename another file which denotes the representation of the sub-theme via appearance
Is there something else required to confirm which theme files Drupal is using to render the site
I want to avoid being too brutal as i am not an expert in this area at all and have just started from scrath again as some change i had previously made had the site running like a wheel in mud. I am being much more careful and particular this time about how I manage any changes.
Looks like in trying to avoid destroying base code, I have succeeded in stuffing it up.
Welcome any insights.
Fixed thanks
I am not sure how, but in the process of troubleshooting the above i managed to fix the problem. More good luck than good management, but pleased with the result nonetheless.
Thanks
Thanks to jtunney1 & aparimana for these instructions, they work beautifully and I am now happily working from mysubtheme!
theme file/machine name tip - don't use hyphens!
I thought I would add that when renaming the files for your sub theme, I found that you can't use hyphens in your theme name. if you do, it won't appear in the theme lists.
e.g.
my-theme-bartik.info - won't work.
my_theme_barktik.info - will.
Thanks!
Thanks for this comment this was my problem exactly! :)