1

I am a newbie to Drupal, and I really don't understand the difference between sub-theme and base theme. Why can't I directly edit the base theme?

I am working on a website which is live and has bartik as default theme. I don't know where to start.

  • Welcome to Drupal Answers. Please take a moment to review the FAQ and understand the Drupal Answers community even better! – chrisjlee Feb 15 '13 at 7:14
6

You haven't really asked a question. But i'll assume that you want to know what a base and sub-theme is in drupal.

TLDR version

A drupal subtheme inherits the template files (*.tpl.php) and assets (javascript, css, images) of the base theme. If you need to modify or change the template files.

More on subthemes

I think your best bet is to google it. I googled, "drupal subtheme" and found you drupal documentation regarding subthemes:

Sub-themes are just like any other theme, with one difference: They inherit the parent theme's resources. There are no limits on the chaining capabilities connecting sub-themes to their parents. A sub-theme can be a child of another sub-theme, and it can be branched and organized however you see fit. This is what gives sub-themes great potential.

Source: Creating a sub-theme (drupal.org)

In addition to the node page, if you're more inclined to watch a video this is probably a good bet: Drupal Subthemes (youtube.com)

Why should you avoid modifying a base theme

  • Flexibility: Base themes maintain flexibility. If there is an update, your child theme inherit these changes
  • Losing your changes: Modifying your base theme means that when an update to the theme comes along your modifications could potentially be lost
  • Maintain simpler code base: The base theme allows you to abstract a lot of functionality and reduce the code base. This means less maintenance in the long run.

Best Practices with subthemes:

  • Copy files from the base theme or use the drush command (when available)
  • Utilize subtheme theme hooks to override your theme
|improve this answer|||||
  • Great answer, this question could easily have been closed as not constructive but I think your response is more than enough to keep it open :) – Clive Feb 15 '13 at 9:16
  • I have one more question, Why can't we use css injector in place of sub-theme? – cartman Feb 16 '13 at 1:06
0

Besides the reasons stated on the other answer, you should not modify the base themes because of updates.

Think about a situation where you get a base theme and heavily modify it, then a bug, or worse a security bug is found in the base theme. If you apply the update, you will loose the changes made to that theme and if you don't apply the update, well who knows what could happen.

More here about upgrading and subtheming in general.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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