Just letting everyone here know that David (the maintainer of this project) has made a note here: #573094: See the CSS Injector module and decide how to relate to it pointing to the CSS Injector project. Here is the related issue in that project's issue queue: #669106: Merge custom css and js module with css injector (it has no activity since December 2010 though).

I myself use CSS Injector for adding css (and I've been really happy with it so far), but I am not sure how well it handles JS injection (if not at all). Good news is that that module seems to be maintained pretty well. It already has a stable 7.x release dating less than 2 months ago and a 7.x-dev version that got updated only 2 days ago! (its 6.x versions date a year ago though). It has a usage count of more than 7000 sites (compared to the ~570 of this project here), of which more than 500 use one of the 7.x versions.

Finally, there is JS Injector, counting ~750 sites using it (no official 7.x version yet though). Here is the issue for its D7 port: #1018156: Port JS injector module to drupal 7. In post #7 of that issue you will find an initial first shot at a 7.x version that was created a month ago based on code from the 7.x-dev version of CSS Injector. I am heading there to help with testing and hope to see you all there...

PS: brad has posted some code that says works for him in non-multisite setups. Find it down in post #3

CommentFileSizeAuthor
#11 customcssjs.zip7.65 KBclayfreeman

Comments

Anonymous’s picture

?

brad.mrumlinski’s picture

Can I provide you with the drupal 7 port to put up? Is this module still maintained?

brad.mrumlinski’s picture

Title: Port Custom CSS and JavaScript files module to drupal 7 » D7?
Version: 6.x-1.x-dev » 6.x-1.6
Issue tags: -D7 porting, -port to d7, -d7 ports

Okay... So for anyone that finds this module useful I have done a quick port to D7 which I am posting here...


<?php

 
function customcssjs_help($path, $arg) {
  $output = '';  //declare your output variable
  switch ($path) {
  case "admin/help#customcssjs":
    $output = '<p>'.  t("Add folder for extra CSS and JS files") .'</p>';
    break;
  }
  return $output;
} 


// permissions
function customcssjs_perm() {
  return array('administer custom css and js') ;
}


function customcssjs_init() {
  // Add the CSS and JS
  
  $basedir = 'sites/default/files/' ;
  $css_path = variable_get('customcssjs_css', array()) ;
  
  if (!empty($css_path)) {
    $css_files = file_scan_directory( $basedir. $css_path, "/css/i", array('callback' => '_customcssjs_add_css', 'key'=> 'filename'), 2 );
  }
  $js_path = variable_get('customcssjs_js', array()) ;
  if (!empty($js_path)) {
    $css_files = file_scan_directory( $basedir . $js_path, "/js/i", array('callback' => '_customcssjs_add_js', 'key'=> 'filename'), 2 );
  }
}

/**
 * Functions to add custom handler for files to be added
 */

function _customcssjs_add_css($filename) {
  //echo "adding $filename";
  //exit();
  drupal_add_css($filename, 'file') ;
}

function _customcssjs_add_js($filename) {
  drupal_add_js($filename, 'file') ;
}


function customcssjs_menu() {
  
  $items = array();
  $items['admin/config/development/customcssjs'] = array(
    'title' => 'Custom CSS and JS files',
    'description' => 'Here you can tune your custom js and css folder files',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('customcssjs_admin'),
    'access callback' => 'user_access',
    'access arguments' => array('administer custom css and js'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

function customcssjs_admin() {
  $default_css_path = 'customcssjs/css';
  $default_js_path = 'customcssjs/js';

  $form = array() ;
  $form['customcssjs_css'] = array(
    '#type' => 'textfield',
    '#title' => t('Folder for CSS files'),
    '#default_value' => variable_get('customcssjs_css', $default_css_path),
    '#size' => 50,
    '#maxlength' => 50,
    '#required' => TRUE,
  ) ;
  $form['customcssjs_js'] = array(
    '#type' => 'textfield',
    '#title' => t('Folder for JS files'),
    '#default_value' => variable_get('customcssjs_js', $default_js_path),
    '#size' => 50,
    '#maxlength' => 50,
    '#required' => TRUE,
  ) ;
  return system_settings_form($form) ;
}


function customcssjs_admin_validate($form, &$form_state) {
  
  $css_path = $form_state['values']['customcssjs_css'] ;
  $css_full_path = file_default_scheme() .'/'. $css_path;
  file_prepare_directory($css_full_path, 1, 'customcssjs_css');
  $js_path = $form_state['values']['customcssjs_js'] ;
  $js_full_path = file_default_scheme() .'/'.  $js_path;
  file_prepare_directory($js_full_path, 1, 'customcssjs_js');
}


Chicago Drupal Development

Anonymous’s picture

#brad.mrumlinski
Thanks for your D7 version, I will test it.

I don't know if this module is still maintained.

Anonymous’s picture

Error customcssjs.install line 5. The install file from Drupal 6.
I found out that Drupal 7 renamed the code 'file_directory_path()' to 'file_default_scheme()'.
I changed the few lines with no succes.

Reading the script above I found

function customcssjs_init() {
  // Add the CSS and JS
   $basedir = 'sites/default/files/' ;

Does that mean that this script cannot work in multisite drupal , only in the default site folder?

I have no php skills, so I cannot solve this.

brad.mrumlinski’s picture

Yeah this was just a quick and dirty port to get it working in 7... not tested on a multi-site installation. Works fine for me on my single site installation though.

I was hoping the maintainer would pick this up...

Anonymous’s picture

I was hoping the maintainer would pick this up...

The last reaction from our maintainer is one year ago ...., hello, are you there? Do you stil maintain and have some time for opgrading it to D7?

klonos’s picture

Title: D7? » Port Custom CSS and JavaScript files module to drupal 7
Version: 6.x-1.6 » 6.x-1.x-dev
Issue tags: +D7 porting, +port to d7, +d7 ports

...making this issue's title lass vague + adding tags.

Now that we have issue summaries and revisions for them, I am updating this one. Read at the top of this page people...

klonos’s picture

Issue summary: View changes

...updating with latest info. Making people aware of the CSS injector & JS injector projects.

klonos’s picture

...PS: @davebv: hey David! Your input regarding your intentions would be greatly appreciated. We need to know where we stand here. At least please update the project's page to let people know. I would suggest the following:

- place a link to the project's page pointing to this issue here.
- also point people to the JS Injector project and #1018156: Port JS injector module to drupal 7

Thanx in advance.

klonos’s picture

Anyone still interested in taking over this project should follow the procedure described here: Dealing with abandoned projects. I would strongly suggest that we focus our efforts on JS injector though.

clayfreeman’s picture

Title: D7? » Port Custom CSS and JavaScript files module to drupal 7
Version: 6.x-1.6 » 6.x-1.x-dev
Issue tags: +D7 porting, +port to d7, +d7 ports
StatusFileSize
new7.65 KB

--

lquessenberry’s picture

I have been using clayfreeman's port without any trouble on a few sites that we're building. I prefer to theme this way as a way to test out different CSS stylings without overwriting the original base theme. Of course, you can always just rewrite the original base theme stylesheets with your own, but the way clayfreeman did this module allows original theme files to remain in tact for future security updates that may come about from the original theme developer. It's quite a handy tool and becomes very useful when developing a mobile version of a site along side the full version.

There are some considerations to take concern of when implementing this module and I am sure that clayfreeman can point those out to you if you have any trouble using his version of the module. He can also provide a plain vanilla port of the module without the sub folders that are created for each theme. This would make his version a full port of the Drupal 6 functionality to Drupal 7. I have tested this functionality on several development sites myself and as expected, this works very well.

Patricia_W’s picture

I'm interested in including a js library in my site. I'm not sure where to include it. The code in particular has sub-folders. In D6 it was in the files sub-directory. But that doesn't seem to work now and I see that there is a js folder for each of the themes which I presume was created when I installed the module. But will the sub-folders be referenced? So far the code is not being invoked.

Patricia_W’s picture

Issue summary: View changes

...minor typo/grammar edits.

clayfreeman’s picture

Status: Active » Closed (outdated)