Skip to content

Instantly share code, notes, and snippets.

@ritcheyer
Created July 10, 2014 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritcheyer/387963d8554357d11435 to your computer and use it in GitHub Desktop.
Save ritcheyer/387963d8554357d11435 to your computer and use it in GitHub Desktop.
Rather than have a giant if statement that is used for page-specific css and javascript, use the $path_alias provided by Drupal
// TODO: there are better ways to do this. needs research
// maybe something like this: https://www.drupal.org/project/autoload_js
$path_alias = drupal_get_path_alias($_GET["q"]);
$theme_path = $base_url . '/' . drupal_get_path('theme', 'tesla_theme');
/**
* DESCRIPTION:
* page-specific CSS added through this function based on the $path_alias
* AUTHOR: eritchey@teslamotors.com
*/
$page_level_CSS = array(
'#tag' => 'link',
'#attributes' => array(
'href' => $theme_path . '/css/' . $path_alias . '.css',
'rel' => 'stylesheet',
'media' => 'all'
),
'#weight' => '-99995',
);
drupal_add_html_head($page_level_CSS, 'page_level_CSS');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment