Question

I'm creating a new Drupal theme for news web sites, which needs some fields to be added to the Article content type to work. For example, the theme will change the header image into something science-related when the user is viewing an article tagged with the term "Science" of a taxonomy called "Section".

I have set up the "Section" vocabulary and added it as a field to my Article content type manually, but the theme I'm making should be "shippable" to end customers, meaning that someone should be able to download it and install it without manually creating taxonomies and fields.

The theme must in some way notify the user that it depends on the Taxonomies module, and, when installed, the theme must create the relevant taxonomies and add fields for it to the "Article" content type.

What is the best way to accomplish this in Drupal 7? The only way I can think of is to create a specific "installer module" for my theme, that officially depends on Taxonomies and are able to add the right fields to Article etc, but there must be a more robust and "standard" way to accomplish this?

Was it helpful?

Solution

Making a theme depend on modules isn't very "standard". Themes only deal with the display, while modules deal with function. If you're making this theme only for this client, I wouldn't bother trying to integrate the two. Now if you're wanting to keep this for down the road, then it's like an installation profile, or themes you would see on ThemeForest that come bundled with a database.

I'd recommend moving any non-theme parts (like content type, fields, etc) into a feature using the Features module. It will help you keep your functionality separate from the theme. If you want to add custom CSS into the feature, just use the drupal_add_css() hook the in .module file that gets generated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top