How create a new variable according field value Please I need a hand, I would like to create a new variable like the native "frontpage" variable. I have a content type called "Config", in this CT I have some boolean fields and I need check for this field values to print a view in my page.tpl

Something like this, my example field "display reviews block?", its may be set "yes" or "no". So, I need create a new variable "$display_reviews" according this value and print this in page.tpl:

&lt;?php if (isset($display_reviews)): ?&gt;
 &lt;?php print views_embed_view('reviews', 'block'); ?&gt;
&lt;?php endif; ?&gt;


Sincerly, I dont know how to do this, but i tried something like this:

function mytemplate_preprocess_page(&amp;$variables) {
  if (isset($variables['node'])) {
    $n = $variables['node'];

    if ($variables['node']-&gt;type == 'config') {

        if (isset($n-&gt;field_display_reviews == 'yes') {
          $variables['display_reviews'] = 'this variable need be created';

        }
    }    

 }
}


UPDATE

Considering I want to print this variable in my node.tpl not in my page.tpl, I have decided to try with directly query, I dont know if is the better and fast way, but this is my code. Its not working yet, this is broking my site, but now I can display the FIELD ID. Im trying to use the field_attach_load to get the field value but no luck:

/**
* Implementation of preprocess_().
*/
function mytemplate_preprocess_node(&amp;$variables, $hook) {

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'config')
  -&gt;propertyCondition('status', 1)
  // value 1 from boolean field
  -&gt;fieldCondition('field_display_reviews','value', '1', '=');
$result = $query-&gt;execute();

if (isset($result['node'])) {
  $stories = $result['node'];

  $fields = field_info_instances('node', 'config');

  // Get id of field
  $reviews = $fields['field_display_reviews']['field_id'];
  field_attach_load('node', $stories, FIELD_LOAD_CURRENT, array('field_id' =&gt; $reviews));
  $output = field_get_items('node', $stories, 'field_display_reviews');

  $variables['display_reviews'] = $output;



}

}
Your code is already there, i think you didn't extract the value of the field_display_reviews correctly, try the following:

 /**
 * Implements hook_preprocess_HOOK().
 */
function mytemplate_preprocess_page(&amp;$variables) {
  if (isset($variables['node'])) {
    $node = $variables['node'];
    if ($node-&gt;type == 'config') {
      if (
        isset($node-&gt;field_display_reviews[LANGUAGE_NONE][0]['value'])
        &amp;&amp; $node-&gt;field_display_reviews[LANGUAGE_NONE][0]['value'] == 'yes'
      ) {
        $variables['display_reviews'] = 'this variable need be created';
      }
    }
  }
}


NOTE: if your display_reviews field of type Boolean the value it will be 1 instead of yes, print the value of $node-&gt;field_display_reviews[LANGUAGE_NONE][0]['value'] before if to see.