I have a specific tpl being defined within the theme and the specific view function contains a function that calls the webservice.
It saves it within the items array which then outputs as variables to the tpl file. However, there is another tpl which is an alternative view for original file but currently has no values.
To fix this, in the original webservice, i store it within sessions and grab data that way. What would be the drupal solution??
function EXAMPLE_theme(){
return array(
'list_view' => array(
'template' => 'list-view',
'variables' => array('items' => NULL)
),
'table_view' => array(
'template' => 'table-view',
'variables' => array('items' => NULL)
)
);
}
function list_view($form_state){
$items = array();
$data = form_data($form_state);
// FOR LIST VIEW TEMPLATES
$items['data'] = webservice($data);
//FOR OTHER TEMPLATES (TABLE-VIEW)
if(isset($_SESSION['data_view'])){
unset($_SESSION['data_view']);
}
$_SESSION['data_view'] = $items['data'];
return theme('list_view', $items);
}
list_view()
will never be called. If it were,theme('list_view', $items)
would cause an infinite loop, since it would be calling that theme function over and over. Also, it is good practice to prefix a theme function with theme_ and the short name of the module. And if you are overriding another theme function.hook_theme()
doesn't work.list_view()
will never be called because Drupal loads the list-view.tlp.php file instead, as for your instructions inEXAMPLE_theme()
. That is in the case no other module defines list_view as theme function: if that is the case, there is probably a conflict. And if that is the case, you cannot usehook_theme()
.