Fix for Fix for Fix for block theme

  1. /**
  2.  * Implements hook_theme().
  3.  */
  4. function mymodule_theme() {
  5.   return array(
  6.     'myblock' => array( // este es el nombre del theme_hook que se remplaza por theme_myblock
  7.       'argument' => array('text' => NULL , 'origin' => NULL),
  8.     )
  9.   );
  10. }
  11.  
  12.  
  13. /**
  14.  * Implements hook_block().
  15.  */
  16. function mymodule_block($op = 'list', $delta = 0, $edit = array()) {
  17.   switch ($op) {
  18.     case 'list':
  19.       $blocks['myblock']['info'] = t('bloque ejemplo');
  20.       $blocks['myblock']['cache'] = BLOCK_CACHE_GLOBAL;
  21.       return $blocks;
  22.  
  23.       break;
  24.    case 'view':
  25.       if ($delta == 'myblock') {
  26.          $block['subject'] = t('titulo se puede omitir');
  27.          $block['content'] = theme('myblock'); // esta funcion es un auxiliar de drupal que remplaza el theme_hook()
  28.  
  29.          return $block;
  30.          break;
  31.   }
  32. }
  33.  
  34. /**
  35.   * Se llama con el hook_theme y se asigna al content del bloque y esto es lo que hace el html del bloque.
  36.   */
  37. function theme_myblock() {
  38.    $output = '';
  39.  
  40.     $output .= llamo_a_otra_funcion_que_regresa_string_html();
  41.     $output .= '<div>asdasdasd</div>';
  42.  
  43.     return $output;
  44. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.