I want to use in my module custom jQuery UI theme from the themeroller. What is the best way to do it?

link|improve this question

75% accept rate
I couldn't create jQuery UI tag. – Xio Apr 18 '11 at 13:00
it can't be separated by spaces or else it understands they are 2 different tags :) – Alex Apr 18 '11 at 13:39
This is the first question tagged with jQuery Ui. I don't have permission to create new tag :) – Xio Apr 18 '11 at 14:25
To which Drupal version are you interested? – kiamlaluno Apr 19 '11 at 22:38
I am using Drupal 7. – Xio Apr 20 '11 at 13:00
feedback

3 Answers

up vote 4 down vote accepted

Assuming you are using the jquery_ui module, all you have to do is:

  • Build a custom download for jQuery UI including your custom theme from ThemeRoller and copy it under the jquery_ui folder, following the instructions in the module's README.txt
  • Alternatively, you could just build your custom theme, download it, and copy it to jQuery UI's theme directory

EDIT:

However, since Drupal 7 already ships with the latest jQuery UI, all you gotta do is download your custom jQuery UI theme and include it using one of the following methods:

  • Copy the directory to your theme's folder and include the css file in your theme's .info
  • Create a custom module, and implement hook_init() and use drupal_add_css() to add your custom stylesheet:

    function mymodule_init() { $options = array( 'group' => CSS_THEME, 'every_page' => TRUE, 'weight' => 9999 ); drupal_add_css(drupal_get_path('module', 'mymodule'), 'mymodule.css', $options); }

link|improve this answer
I haven't found drupal 7 version of jquery_ui and I don't think that coping my files into drupal core directory is the best way. – Xio Apr 18 '11 at 14:28
My bad, agreed, I've edited my original post to fix this :) – Alex Apr 18 '11 at 14:33
Doesn't drupal_add_css just add new css files but not replace them? I'm going to use jQuery UI only on a single page. – Xio Apr 18 '11 at 14:52
drupal_add_css replaces files with the same name, so if you name your css 'jquery.ui.theme.css' for example it will be used instead of the default version – Alex Apr 18 '11 at 16:11
feedback

If you are adding the UI via drupal_add_library(), you can change the style using hook_library_alter(). For example:

/**
 * Implements hook_library_alter().
 */
function YOURMODULENAME_library_alter(&$libraries, $module) {
  unset($libraries['ui']['css']['misc/ui/jquery.ui.theme.css']);
  $libraries['ui']['css']['path/to/your/custom/theme/jquery.ui.theme.css'] = array();
}
link|improve this answer
feedback

For Drupal 7, the stock Seven theme does this (repository link) (abridged):

function seven_css_alter(&$css) {
  if (isset($css['misc/ui/jquery.ui.theme.css'])) {
    $css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';
  }
}

Modify accordingly—i.e. replace "seven" with the name of your theme, and point the path to your jQuery UI theme's CSS file.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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