drupal 7中的hook_block_view()不呈现

时间:2016-01-18 17:34:18

标签: drupal-7

我有2个服务器生产和开发,我的问题是模块,偶尔我的模块渲染到developpemnt但生产服务器不渲染,我清理缓存这么多次,调试模块永远不会通过另一方面,hook_block_view()传递给menu_hook,所有de admin hooks,包括我可以看到模块的管理表单,但模块的块没有。

有人有类似的问题吗?

我的代码如下:

/**
 * Implements hook_menu()
 */
function contenido_primario_menu () {
  $items['admin/structure/contenido_primario'] = array(
    'title' => t('Contenido Primario'),
    'description' => t('Configurar imagenes y mapas'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('contenido_primario_configuration_form'),
    'access arguments' => array('admnister contenido_primario'),
    'file' => 'contenido_primario.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  );

  $items['admin/structure/contenido_primario_modal'] = array(
    'title' => t('Contenido Primario Modal'),
    'description' => t('Configurar iconos correspondientes a la ventana modal'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('contenido_primario_modal_form'),
    'file' => 'contenido_primario.modal.inc',
    'access arguments' => array('admnister contenido_primario_modal'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

/**
 * Implements hook_block_info()
 */
function contenido_primario_block_info() {
  $bloque = array();

  $bloque['contenido_primario_block'] = array(
    'info' => t('Bloque de información, despligue de contenido primario'),
    'cache' => DRUPAL_NO_CACHE,
  );

  return $bloque;
}

/**
 * Implements hook_permission()
 */
function contenido_primario_permission() {
  return array(
    'admnister contenido_primario' => array(
      'title' => t('Administrar Contenido Primario de la pagina Principal'),
      'description' => t('Bloque de Administración para Contenido Primario'),
    ),
    'admnister contenido_primario_modal' => array(
      'title' => t('Administrar Contenido Primario de la pagina Principal'),
      'description' => t('Bloque de Administración para Contenido Primario'),
    ),
  );
}

/**
 * Implements hook_contextual_links_view_alter()
 */
function contenido_primario_contextual_links_view_alter(&$element, $items) {

  if(isset( $element['#element']['#block']->module) &&
        $element['#element']['#block']->delta == 'contenido_primario_block') {
    $element['#links']['contenido_primario'] = array(
      'title' => t('Configurar Contenido Primario'),
      'href' => 'admin/structure/contenido_primario',
    );
    $element['#links']['contenido_primario_modal'] = array(
      'title' => t('Agregar iconos a ventana modal'),
      'href' => 'admin/structure/contenido_primario_modal',
    );
  }
}


/**
 * Implements hook_theme()
 */
function contenido_primario_theme($existing, $type, $theme, $path) {
  return array(
    'contenido_primario_template' => array(
      'template' => 'view',
      'path' => $path . '/templates',
    ),
  );
}

/**
 * Implements hook_theme()
 */
function contenido_primario_block_view($block_name = '') {
  $block = array();
  $icons = array();
  //echo '<pre>';

  if($block_name == 'contenido_primario_block' && current_path() == 'node') {                        


    $module_path = base_path() . drupal_get_path('module', 'contenido_primario') . '/';

    $files_path = base_path() .
        variable_get('file_public_path', conf_path() . '/files') . '/contenido_primario/';
    $icons_path =base_path() .
        variable_get('file_public_path', conf_path() . '/files') . '/icons/';


    //$list = module_list();

    $background_color = variable_get('contenido_primario_modal_background', '');
    // Get all available slides
    //variable_set('contenido_primario_banner_settings', array());
    $slides = variable_get('contenido_primario_banner_settings', array());
    $modal_icons = variable_get('contenido_primario_icons_settings', array());

    if(is_array($slides) && count($slides) > 0) {
      $icons = array();

      // weight, published, delete, fid, title, url
      foreach ($slides as $key => $value) {
        $alias = empty($value['url']) ? '' : $value['url'];
        $file = file_load($value['fid_map']);

        if (!empty($file)) {
          $map_filename = $file->filename;
          $image_map =  _generate_image($file);          
        }

        $file = file_load($value['fid_image']);
        if (!empty($file)) {
          $place_filename = $file->filename;
          $image_place =  _generate_image($file);
        }

        $titlecode = str_replace(' ', '-', $value['title']);
        $titlecode = strtolower($titlecode);
        $_placeurl = (!isset($value['url']) && empty($value['url'])) ? '': $value['url'];

        $icon = array(
          'path' => file_create_url($file->uri),
          'title' => $value['title'],
          'titlecode' => $titlecode,
          'description' => $value['description']['value'],
          'published' => $value['published'],
          'map_image' => $image_map,
          'place_image' => $image_place,
          'place_filename' => $place_filename,
          'map_filename' => $map_filename,
          'url_place' => $_placeurl,
          'alias' => $alias,
        );

        $icons[] = $icon;
      }
    }

    $theme_args = array(
      'background_color' => $background_color,
      'icons_path' => $icons_path,
      'files_path' => $files_path,
      'module_path' => $module_path,
      'modal_icons' => $modal_icons,
      'icons' => $icons, 
      'active' => 'active',
    );

    #db_query("DELETE FROM {cache};");
    $content = theme('contenido_primario_template', $theme_args);

    $block = array(
      'content' => $content,
    );


  }

  return $block;
}

我的开发和生产服务器之间存在这些问题。

0 个答案:

没有答案