Get current page / url on hook

In hook_css_alter, I want to disable stylesheets on specific pages. It was good for the first page requirement with the following snippet:

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

Now I need to delete certain styles on the photo album page. I thought of several ways to do this, but I would like to do it by drupal.

The closest function I found is drupal_get_destination (), I donโ€™t think it meant that, but it returns the current path in the array, as shown in the following snippet added to css_alter.

 echo " PATH = " . var_dump(drupal_get_destination()); Output: PATH = array(1) { ["destination"]=> string(6) "photos" } 

Is this the recommended way to get the path from within the / hook function, or is there some kind of variable in the global namespace that I should use instead?

+4
source share
1 answer
+9
source

Source: https://habr.com/ru/post/1341914/


All Articles