Preprocess functions

An advanced Dynamic display block slideshow uses two preprocess functions to convert view fields into template variables. One for the whole slideshow template and one for the pager template.

Note: Only a custom pager needs a preprocess function for the pager template.

The preprocess functions have to be placed in the template.php file of your theme.

Download and install preprocess functions

  • Download preprocess functions from the template.php.txt file at the Download page :
    • Note: If you still use the 6.x-3.0-alpha versions of imagefield and filefield, download:


    • Place the preprocess functions e.g. at the end of the template.php file, as long as you don't put it in an existing function.
    • Don't copy the <?php tag from the file to your template.php file.
    • When your theme does not have a template.php file, create one and copy the preprocess functions in it, including the <?php tag
    • In this step you don't use the cck export and the views export file. The cck export is for importing a content type. The views export is for importing a view.

    Make changes to the preprocess functions

    • Replace [THEME_NAME], including the brackets, in both preprocess
      functions, with the name of the site theme you use (NOT the ddblock theme) .
    • 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 fields to convert 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 view fields by uncommenting the drupal_set_message or dsm debug lines at the top of each preprocess function.

    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 or view_field names
    If you use a different view_name and/or view fields than in the advanced slideshow tutorial you have to change them in the preprocess functions.

    Uncomment the drupal_set_message lines at the top of the two preprocess function.

    [theme_name]_preprocess_ddblock_cycle_block_content and [theme_name]_preprocess_ddblock_cycle_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 ($vars['settings']['view_name'] == 'news_items') {

    you fill in your own viewname

    if ($vars['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'] =  $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'] =  $result->[VIEW_FIELD_NAME];

    After you have changed the view_name and field_names comment the drupal set_message line again.


    Several users have an issue with the preprocess functions. In the trouble shooting part of the FAQ you can find the solutions. The FAQ question are:

    Preprocess snippets

    Several preprocess snippets can be found in the preprocess snippets section, like how to link the slide image to a page, etc.