Skip to content

About

A lightweight, JSON-driven library for Backdrop CMS that simplifies theme setup by importing sample content, configurations, and layouts using native Backdrop APIs.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Theme Setup for Backdrop CMS

A simpler way to prepare sample content and site configuration for Backdrop CMS themes.

Theme Setup is a lightweight, JSON-driven library that helps theme designers deliver ready-to-use themes with sample content, taxonomy terms, menu links, fields, Views filters, and layout configurations.

The library uses native Backdrop APIs and Configuration Management (CMI), reducing the need to write custom PHP import routines.

Theme Setup is independent of CSS frameworks and can be integrated into any Backdrop CMS theme.

Why Theme Setup?

Theme Setup is designed to simplify the theme development experience and keep the learning curve short.

  • Easy integration with just a few lines of PHP.
  • Ready-to-use setup options in the theme settings page.
  • Simple, readable JSON configuration files.
  • No need to write custom import routines for supported operations.
  • Flexible integration with existing theme settings.
  • Duplicate prevention when setup operations are repeated.
  • Designed with performance and shared hosting environments in mind.
  • No additional contributed modules required by the library itself.

Theme designers remain in control of which setup options are available to their users.

Quick Integration

Copy the library's includes/ directory and the required settings-content/ files into your theme.

Add the following code to your theme's theme-settings.php file, replacing MYTHEME with your theme's machine name:

<?php

/**
 * Implements hook_form_system_theme_settings_alter().
 */
function MYTHEME_form_system_theme_settings_alter(&$form, &$form_state) {

  require_once __DIR__ . '/includes/theme-setup-form.inc';

  theme_setup_form($form, $form_state);
}

That's all you need to display the available Theme Setup options on your theme settings page.

Select specific setup options

You do not need to display every available operation. Select only the options required by your theme:

theme_setup_form($form, $form_state, array(
  'import_terms',
  'import_content',
  'import_menu_links',
));

Group setup options

To display the selected operations within a single settings group:

theme_setup_form($form, $form_state, array(
  'import_terms',
  'import_content',
  'import_menu_links',
), array(
  'grouped' => TRUE,
));

To group all available operations, use:

theme_setup_form($form, $form_state, NULL, array(
  'grouped' => TRUE,
));

Theme Setup can also be used alongside custom theme settings and custom submit handlers, allowing designers to maintain their existing settings interface.

Theme Setup Builder

Theme Setup Builder is a separate companion module designed to make preparing configuration files easier.

Instead of manually creating JSON files, theme designers can use the Builder's administration interface to prepare and export configuration from a development website.

The two projects have complementary responsibilities:

  • Theme Setup Builder: Helps designers prepare and export configuration files during theme development.
  • Theme Setup: Imports and applies the prepared configuration from the theme settings page.

Theme Setup Builder is optional. It is intended as a development tool and does not need to be installed on the websites using the finished theme.

Together, these tools aim to reduce repetitive development tasks, shorten the learning curve, and make theme development in Backdrop CMS more accessible.

Supported Operations

Operation Description
Enable required modules Enable available modules declared by the theme
Import field configurations Import field definitions and instances through CMI
Import taxonomy terms Create taxonomy terms, including hierarchical terms
Import sample content Create sample nodes with supported field values and files
Import menu links Create menu links and nested menu structures
Update Views filters Resolve taxonomy terms and update existing Views filters
Apply layout settings Configure existing layouts
Configure layout blocks Add, remove, move, or configure layout blocks
Flush image styles Flush selected existing image styles

All operations are optional. Theme designers can select the features that match their theme's requirements.

Configuration Structure

Theme Setup uses JSON files stored in the theme's settings-content/ directory.

MYTHEME/
├── MYTHEME.info
├── theme-settings.php
├── config/
├── includes/
│   ├── theme-setup.inc
│   └── theme-setup-form.inc
└── settings-content/
    ├── modules/
    │   └── modules.json
    ├── fields/
    ├── taxonomy/
    │   └── terms.json
    ├── content/
    │   └── content.json
    ├── files/
    ├── menu/
    │   └── links.json
    ├── views/
    │   └── filters.json
    └── layouts/
        ├── settings.json
        └── blocks.json

Only include the configuration files and directories required by your theme.

Configuration files

File or directory Purpose
modules/modules.json Declare required modules
fields/ Field definitions and instances in CMI format
taxonomy/terms.json Taxonomy terms and their relationships
content/content.json Sample content and field values
files/ Sample images and other referenced files
menu/links.json Menu links and parent-child relationships
views/filters.json Taxonomy-based

Credits

License

Backdrop Theme Setup is free and open-source software licensed under the GNU General Public License, version 2 or later (GPL-2.0-or-later).

See LICENSE.txt for the full license text.

About

A lightweight, JSON-driven library for Backdrop CMS that simplifies theme setup by importing sample content, configurations, and layouts using native Backdrop APIs.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages