Posted by mikedrupalfan on December 23, 2012 at 6:20pm
1-What is the '$variable' mean ?
2-What data its store?
3- And what the template_preprocess function really does ?
I read but i haven't understand
http://api.drupal.org/api/drupal/includes%21theme.inc/function/template_...
<?php
function template_preprocess_formexample_nameform(&$variables) {
$variable['formexample_nameform'] = array();
$hidden = array();
//Provide variable named after form keys so themers can print each element
independently.
foreach (element_children($variables['form']) as $key) {
$type = $variables['form'][$key]['#type'];
if ($type == 'hidden'|| $type == 'token') {
$hidden[] = drupal_render($variables['form'][$key]);
}
else {
$variables['formexample_nameform'][$key] = drupal_render($variables['form'][$key]);
}
}
//Hidden form element have no value to themers. No need for separation.
$variables['formexample_nameform']['hidden'] = implode($hidden);
// Collect all form element to make it easier to print the whole form.
$variables['formexample_nameform_form'] = implode($variables['formexample_nameform']);
}
?>
Comments
It should be reasonably self
It should be reasonably self explanatory. The template preprocess function will allow you to view & or alter variables passed to that preprocessor (yes there is a sequence).
Maybe this would be more suitable.
Chairs,