4

In hook_css_alter, I want to disable style-sheets on specific pages. Was ok for the front page requirement with following snippet:

function morin_css_alter(&$css) {
  if(drupal_is_front_page()){
    foreach ($css as $data => $item) {
      unset($css[$data]);
    }
  }
}

Now I need to remove specific styles on a photo-album page. I have thought of a few ways to do this, but I'd like to do it the drupal way.

The closest function I have found to do this is drupal_get_destination() , I don't think it's meant for this but it does return the current path in an array, as shown by the following snippet added in css_alter hook.

echo " PATH = " . var_dump(drupal_get_destination());

Output: PATH = array(1) { ["destination"]=> string(6) "photos" }

Is this the recommended way of getting the path from inside a function/hook, or is there some variable in global namespace I should use instead?

Stephane Gosselin
  • 9,030
  • 5
  • 42
  • 65
  • See [this post...](http://stackoverflow.com/questions/703426/how-to-get-the-full-url-of-a-drupal-page) If Eaton says it, it IS the Drupal way in my book :) – geaw35 Mar 02 '11 at 02:07

1 Answers1

9

You want http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/request_path/7.

For Drupal 6, one has to use $_GET['q'].

Berdir
  • 6,881
  • 2
  • 26
  • 38
  • drupal_get_destination() doest not always return the current path. The current path is actually the default value when no other destination (to be used in a redirect in case of, for instance, a successful form submit) has been provided. See the drupal_get_destination()'s documentation. – Pierre Buyle Mar 02 '11 at 07:46
  • I said nothing about drupal_get_destination(), I assume you meant that as an additional information? – Berdir Mar 02 '11 at 08:02
  • Yep, this is additional information as the original question mentioned using drupal_get_destination(). Sorry, I should have made it clearer. – Pierre Buyle Mar 02 '11 at 10:30
  • Hey guys thanks for the insight, just was I was looking for. drupal_get_destination did not feel right for this, now I see why. – Stephane Gosselin Mar 03 '11 at 07:04