I'm trying to add some javascript to my template.php file on a Drupal 7 site. I'd like the javascript to load on a specific set of pages, based on the url. For example, I'd like the script to load on:
mysite.com/blog/page1
mysite.com/blog/page2
but not on:
mysite.com
or mysite.com/blog
or mysite.com/about
I'm using
function mytheme_preprocess_html(&$variables) {
$theme_path = path_to_theme();
$path = drupal_get_path_alias();
if($path == 'blog/page1') {
drupal_add_js($theme_path . '/js/example.js');
}
}
to load the script on that specific page, but is there any way to use a url argument or wildcard or something so that all internal blog pages (i.e. blog/page1, blog/page2, blog/page3) will load the script?
Thanks!