Preprocess functions

A Views Slideshow: Dynamic Display Block uses two preprocess functions to convert view fields into template variables. One for the whole slideshow template and one for the pager template.

Important to understand about field data from views used in the preprocess functions.

  • The data used from the view for fields is "RAW" data, settings in views like trimming etc. are not used in the data for the field.
  • When you want e.g., trim data in a field you need to add the code yourself in the preprocess function.
  • An example of code used from trimming a field can be found at: #21
  • In version 2 of the views_slideshow_ddblock module, rendered data from the view is used, and all views functionality is available.
  • Install preprocess functions

    • The preprocess functions have to be placed in the template.php file of your theme.
    • Copy the preprocess function code from the template.php.txt file to the template.php file. The template.php.txt file is part of the package
    • Replace [***THEME_NAME***], including the brackets, with the name of your overall site theme name you use, in both preprocess functions.
    • Change the view_name in both preprocess functions if your view has another name than: news_items. See Changing view_name and or view_field names below.
    • Change the field_names if you have other fieldnames in your view. See Changing view_name and or view_field names below.

    Note: You can see the view_name and the available field_names by showing the debug info, by setting this in the views ddblock configuration page.

    In the example preprocess function the following variables are now available in the slideshow template for each slide.

    • $slider_items['slide_image']
    • $slider_items['slide_text']
    • $slider_items['slide_title']
    • $slider_items['slide_read_more']
    • $slider_items['slide_node']

    and the following for each custom-pager-item

    • $pager_items['image']
    • $pager_items['text']

    Changing view_name and view_field names
    If you use a different view_name and view fields than the default news_items view and field names, you have to change them in the preprocess functions.

    Show debug info which you can configure at the views ddblock configuration page.

    [***THEME_NAME***]_preprocess_views_slideshow_ddblock and [***THEME_NAME***]_preprocess_views_slideshow_ddblock_pager_content

    You will now see the result of the drupal_set_message lines, which shows the view_name and the view_fields of your view. You can use this for changing the view_name and the view_field names in the preprocess functions in the template.php file.

    Changing view_name
    In the line:

    if ($settings['view_name'] == 'news_items') {

    you fill in your own viewname

    if ($settings['view_name'] == '[VIEW_NAME]') {

    Changing view_field_names
    In the lines like:

    if (isset($result->node_data_field_pager_item_text_field_slide_text_value)) {
      $slider_items[$key1]['slide_text'] =  check_markup($result->node_data_field_pager_item_text_field_slide_text_value);

    You fill in your own view_field_names

    if (isset($result->[VIEW_FIELD_NAME])) {
      $slider_items[$key1]['slide_text'] =  check_markup($result->[VIEW_FIELD_NAME]);

    After you have changed the view_name and view_field go back to your views ddblock configuration page and set, Show debug info to <none> again.