Saturday, October 24, 2020

View pre render hook work for .

 When only one picture is uploaded the caroussel on the space page should work with that one picture.

/**

 * Implements hook_views_pre_render().

 */

function hook_views_pre_render(&$view) {

  if ($view->name == 'slideshow' && $view->current_display = 'panel_pane_1') {

    $result = $view->result;

    //only one picture is uploaded the caroussel on the  page

    if(isset($result) && (count($result) == 1)){

      $slider_arr = array();

      $slider_arr = $view->result;

      $view->result[1] = $slider_arr[0];

    }

  }

}

Field label change

 $view->field['created']->options['label'] = t('Request sent on');

$view->field['field_st_int_iden']->options['label'] = t('Space');

$view->field['field_listing_enquiry_arr_date']->options['label'] = t('From');

$view->field['field_listing_enquiry_dep_date']->options['label'] = t('To');

Field value change

$view->display_handler->view->result[0]->field_name[0]["rendered"]["#markup"] = "hello"

 $result->field_name[0]["rendered"]["#markup"] 


No comments:

Post a Comment

If you have any problem please let me know.