I'm trying to remove some regions if the page is admin like this:

function mytheme_page_alter(&$page) { 
if (current_path() == 'admin') {

But it's not removing the contents and highlighted regions from localhost/drupal/admin


I dont see any issue with the code. I tried the exact same code in my custom module and it works as expected.

Can you check what the base_url is in your case? I am guessing the current_path in your case is returned as drupal/admin and this is not matching the if condition you added. You may want to print the value for current_path() using the statement drupal_set_message(current_path()); to confirm the same.

  • you mean like this ? if (drupal_set_message(current_path()) == 'admin') { – Navin Rauniyar May 8 '14 at 4:44
  • No! drupal_set_message is used fir displaying the value in the message section of the page. You may want to try code function mytheme_page_alter(&$page) { drupal_set_message(current_path()); if (current_path() == 'drupal/admin') { unset($page['content']); unset($page['highlighted']); } } code – Bhuvana May 8 '14 at 4:46
  • still unclear, where to put drupal_set_message ... – Navin Rauniyar May 8 '14 at 4:49
  • relook at my updated comment – Bhuvana May 8 '14 at 4:50
  • Oh through the drupal_set ... I knew node/2 and tried that and removed...thanks... and how can I hide the logo – Navin Rauniyar May 8 '14 at 5:11

you may want to create a template file instead of making all these changes in a hook. Refer to this link for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.