Hello,

I am working on migrating two sites to Drupal: one that was non-dynamic and one which was implemented with Geeklog.

I have the need to use taxonomies, pages etc. in conjunction with URL Aliasing. I also need to write some graphics to the page dynamically based on the "section". I would like to do this by accessing the current or requested URL Alias, as that would allow me to forgoe getting the type (node, taxonomy etc.) in order to determine which graphics need to be displayed. The URL Alias does not appear to be one of the arg(x) values available in the URL string. How can I tell what the URL Alias is using PHP? Is there an array that I can make available, or a variable I can reference? I searched the forums and found a reference to "$url_alias" but was unable to determine how to gain access to that variable.

Thanks, and congrats on developing such an impressive CMS.

-- averageyoungman

Comments

averageyoungman’s picture

OK. I can use the $_SERVER environment array to get the current path, but it would be nice if there was some sort of access to whatever the URL Alias var is.

Thanks,

-- averageyoungman

averageyoungman’s picture

You can do the following:

$preAlias = $_SERVER['REQUEST_URI'];
$alias = substr(strrchr($preAlias, "/"), 1);

That will give you the current alias.

Thanks,

-- averageyoungman

patrickharris’s picture

Thank you for that - it's very useful!

patrickharris’s picture

Thank you for that - it's very useful!

jsims281’s picture

That is a very nice snippet, thanks!

kenorb’s picture