i'm studying, trying hard to understand what is show in the kpr($page) output. So as an exercise, I'm trying to change #show_messages element. by default, i get this

....(Array, 10 elements)
◦ #show_messages (Boolean) TRUE

so in the theme_hook_alter() function i did this (before the kpr() output).

$page['show_messages'] = FALSE;

but when i refresh it's not changing the output. why is that.

also, i don't really understand the difference between elements with a # before them and the ones without.

  • in Drupal every thing is array. $page is an array which contains your page. kpr equals to var_dump but in a well formatted shape. – M a m a D Jun 4 '14 at 5:48

 * Implements hook_preprocess_HOOK()
function YOURTHEME_preprocess_page(&$vars) {

    // All you need to do is to set the appropriate preprocess variable:
    $vars['show_messages'] = false;

    We also have $vars['page'] which is an array.

    $page = $vars['page'];
    This array is a Drupal Render Array which means would pass through drupal_render() function.
    In a Render Array keys starting with # are attributes and the others are children elements.
    Read more about that on @see https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_render/7

  • $vars['#show_messages'] – Petro Popelyshko Jun 4 '14 at 6:05
  • @neok Keys in $vars turn into variables so they never start with a # character. – Alexar Jun 4 '14 at 6:41

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.