Hi,

I'm in the process of building a base distribution that presets certain functionality, etc, for a base to build new sites from, and I was building the ability to have the omega-html5 starterkit copied into the new 'sites/*/themes' directory when I stumbled onto Omega Tools.

While the Drush and Wizard functionality is cool, it would be nice if there was either some direct integration in the Profile module or a simple enough command to run in a profiles hook_install() to do the same thing.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered’s picture

Here's a snippet I've put together so far, not perfect yet but it's a start. Goes in hook_install() in your profile.

  $form_state = array('subtheme' => (object) array_merge((array) omega_tools_cache_get('omega'), array(
    'new' => TRUE,
    'name' => 'Test',
    'machine_name' => 'test',
    'destination' => conf_path() . '/themes/custom/test',
    'status' => 1,
    'default' => TRUE,
  )));
  omega_tools_subtheme_wizard_finish($form_state);
Deciphered’s picture

Ok, think I've got it figured out now:

  module_load_include('inc', 'omega_tools', 'includes/omega_tools.admin');
  module_load_include('inc', 'omega_tools', 'includes/omega_tools.wizard');

  $form_state = array(
    'values' => array(
      'name' => 'test',
      'machine_name' => 'test',
      'automated' => 1,
      'destination' => str_replace('sites/', '', conf_path()),
      'base' => 'omega',
      'starterkit' => 'starterkit_omega_html5',
    ),
  );
  omega_tools_subtheme_add_submit(array(), $form_state);

  $form_state = array(
    'subtheme' => omega_tools_cache_load('test'),
  );
  $form_state['subtheme']->destination = conf_path() . '/themes/custom/test';
  omega_tools_subtheme_wizard_finish($form_state);

Note: Fill in any necessary value, mine is just using placeholders.

 

Obviously something like the following built into profile would be easier:

omega_subtheme[test][name] = "test"
omega_subtheme[test][machine_name] = "test"
omega_subtheme[test][destination] = "custom/test"
omega_subtheme[test][destination] = "custom/test"
omega_subtheme[test][base] = "omega"
omega_subtheme[test][starterkit] = "starterkit_omega_html5"
himerus’s picture

Assigned: Unassigned » himerus

I like it... I've been considering recently (based on a few projects I'm involved with) the ability to select and/or generate a new subtheme on the fly at install profile completion...

I'll play with this a bit and see where I get.

Deciphered’s picture

Status: Active » Needs review
FileSize
1.41 KB

Profiler support in attached patch, syntax as following:

omega-tools[{machine_name}][new] = 1
omega-tools[{machine_name}][name] = [conf_path:dir:prefix] theme
omega-tools[{machine_name}][machine_name] = [conf_path:dir:prefix]_theme
omega-tools[{machine_name}][base] = omega
omega-tools[{machine_name}][path] = [conf_path]/themes/[conf_path:dir:prefix]_theme
omega-tools[{machine_name}][default] = 1
omega-tools[{machine_name}][status] = 1

Three psuedo tokens are supplied:
[conf_path] - returns value of conf_path() (ie, sites/abc.com)
[conf_path:dir] - returns directory from conf_path() (ie, abc.com)
[conf_path:dir:prefix] - return prefix of directory from conf_path() (ie, abc)

Deciphered’s picture

Status: Needs review » Needs work
+++ b/omega_tools.moduleundefined
@@ -643,4 +643,45 @@ function _omega_tools_is_editable($theme) {
+    'conf_path:dir' => preg_filter('/(sites\/)(.*)/', '$2', conf_path()),

preg_filter() is only available with PHP 5.3+, will need to be replaced with another approach.

Deciphered’s picture

Status: Needs work » Needs review
FileSize
799 bytes
1.51 KB

Updated patch:
- Added drupal_atler to allow other modules the ability to modify the available tokens
- Changed preg_filter to preg_replace