I am trying to edit a default drupal 6.2 theme (bluemarine) to include my custom CSS and Javascripts, I know that there is a default style.css and script.js but how would I allow drupal to include my custom scripts. Im pretty sure there is a function like drupal_allow_js() or something but what is the syntax for using this, same for the css. Any help would be appreciated!

Thanks,
r00tk1ll

Comments

r00tk1ll’s picture

Ok from these two functions:

drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE, $preprocess = TRUE)

drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE)

I dont see how I can just simply add my 1 css file and my 2 js files, I mean can I not just say use 1 css file and 2 js files? I am working on a semi-static slightly interactive site that doesnt need to change much.

Basically what Im saying is, if I have 3 files (design.css, spry.js, and customeffects.js) how do I plug that into that function, and then what .tpl file calls this function?

Just trying to learn something,
Thanks

cog.rusty’s picture

The API pages explain what those parameters are. Put your file paths (relative to Drupal) in $data and in $path, respectively (in quotes). Repeat for each file.

r00tk1ll’s picture

I have tried countless variations on these functions and still receive nothing just a white page with no style. A couple of examples I have tried in my page.tpl.php are:

 print $head
    drupal_add_css('/themes/bluemarine/design.css', 'theme', 'all', TRUE);
  print $scripts
   print $styles 

//php tags removed for cleanliness

 print $head
    drupal_add_css($path = '/themes/bluemarine/design.css', $type = 'module', $media = 'all', $preprocess = TRUE);
  print $scripts
   print $styles 

//php tags removed for cleanliness

I have tried many variations with single qoutes, double qoutes, statement order, semi colon at the end for both javascript and CSS.

Nothing works at all, please help!!

Oblivious-1’s picture

I think you may have to call drupal_add_css and/or drupal_add_js from a module or template.php. I usually create a module called {whatever}_helpers to manage things like that.

--
Erik

Oblivious-1’s picture

Note that if you just want to get a site launched in a hurry, you can link the style sheet in page.tpl.php like you would with any normal html file. Files you link this way can't be aggregated by Drupal, but the site will launch on time.

--
Erik

r00tk1ll’s picture

Thanks, I will give it a try and let you know. Also I have been reading through the drupal 6 theme guide and noticed this:

"Traditionally, themes could add javascripts by calling drupal_add_js() in their template.php file. Starting in 6.x, themes can also add javascripts by adding lines to their .info file:
scripts[] = script.js"

And the same with the CSS, now I will also try this method. Since I am new to drupal theming I am trying to just build off of the default bluemarine, but Im sure Im not supposed to be editing it directly. Is this how you handle your drupal theming, or do you manually create all the necessary files?

r00tk1ll

Oblivious-1’s picture

Copy the theme folder to /sites/all/themes/ . Rename it "mytheme", or whatever. Rename bluemarine.info to mytheme.info and change any references to bluemarine in that file to reference mytheme instead. Activate the theme in your admin settings.

--
Erik

r00tk1ll’s picture

All is going good now, except what about the admin page and the content? Are they defined through any certain variables that I need to print. For example I have started a book content type and all of my text is gone, same for the admin page. If I can solve this I think I am on my way!

Oblivious-1’s picture

That sounds odd. I have to hit the sack; I'm turning into a pumpkin as we speak. I'll check back to see how things are going in the morning.

--
Erik

r00tk1ll’s picture

Thank you Oblivious, moving the theme to /sites/all/themes/mytheme, plus the following alterations to mytheme.info did the trick:
scripts[] = customeffects.js
scripts[] = SpryEffects.js
stylesheets[all][] = design.css

I learned allot about drupal, and even after being familiar with PHP/Javascript/CSS I still found there is much to learn.

Appreciate it.