Passing data from form to theme

There is a self-written search module for drupal.
The question is how to pass an array from the my_search_submit function to a function that displays information on the screen.
The essay is below. There must definitely be a normal way, but I can’t find it.

  //Описание блоков
   function my_search_hblock($op = 'list', $delta = 0, $edit = array()){
   switch ($op) {
   case 'list':
   $blocks[0] = array(
       'info' => t('Поиск GM'),
   );
   $blocks[1]= array(
       'info' =>t('Результат поиска'),
   );
   return $blocks;
   case 'view':
   switch ($delta) {
     case 0:
     $block['content'] = my_search_page();//форма для поиска
     break;
     case 1:
     $block['content'] = my_search_result_contents();//результат поиска
     break;
   }
   return $block;
   }
}
   //Сам сабмитер
   function my_search_form_submit($form, &$form_state){
   //некоторый код
   container($keywords);
   }
 function container($result=NULL){
 /**
  * Это что-то типа контейнера 
  * Если в функцию передана переменная--то её данные заносятся в сессию
  * Если ничего не переданно--то из сссии извлекаются данные, сама сессия обнуляться.
  **/
    if(is_null($result)){
        $result=$_SESSION['result'];
        unset($_SESSION['result']);
        return $result;
    }elseif(!is_null($result)){
        $_SESSION['result']=$result;
    }
}
  function my_search_result_contents(){
    $result=container();
    $output = theme('search', $result);
    return $output;
    }

Answer 1, authority 100%

Actually, the question is closed. The lead programmer came and said that immediately after the submitter comes the hiader. So the data really needs to be pushed into the session and used. At the same time, he showed the scheme of how the form works in “Pro Drupal Development”. There was also an option to shift all the work with processing to Ajax or JayQuery, and the submitter will do echo html. Who has the rights to close the topic, pliz.

Leave a reply

Please enter your comment!
Please enter your name here