I have a block with a select box and submit button. The main purpose of the select box is to store a variable in the session. I used template_preprocess_node to filter contents based on user selection.
function blackout_preprocess_node(&$vars) {
$node = $vars['node'];
// define a variable to hold your rendered content
$newContent = "";
if($_SESSION['myid'] == '1' && $node->field_field1[0]['value'] != '') {
$newContent = $node->field_field1[0]['view'];
} else if($_SESSION['myid'] == '2' && $node->field_field2[0]['value'] != '') {
$newContent = $node->field_field2[0]['view'];
} else {
$newContent = $node->body;
}
if (strlen($newContent)) $vars['content'] = $newContent;
}
Everything is working fine except I have to click submit twice to reload the page contents or I have to move to another page to see re-loaded content. How can I reload content with just one click?