Wednesday, October 14, 2015

How to get base paths/urls in Drupal 7

This is very useful.

Get urls:

$GLOBALS['base_url'] => http://example.com/drupal

base_path() => /drupal/

request_uri() => /drupal/documentation?page=1

request_path() => documentation

current_path() => node/26419

global $base_url; print $base_url;
 
$imgurl = file_create_url(path_to_theme().'/images/blah.png'); ///path to theme dir

No comments:

Post a Comment