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 :
    • Export_files_V1.6.zip
    • Note: If you still use the 6.x-3.0-alpha versions of imagefield and filefield, download: Export_files.zip.

    Important:

    • 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];
    }

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

    FAQ

    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.

Comments

instagram profile view

I feel Instagram as a better option in comparison to Facebook as a social network website. Instagram is faster, smooth to scroll, better applications and nicest way to share my photos and videos, however i sometimes feel a little insecure after seeing website providing private instagram profile viewer, does these websites do really provide access to sometimes private stuff over Instagram like their photos etc, Or it's just nothing i am worrying for and private Instagram profile viewer is just a fake name.

view_names and view_field_names

What are view_names and view_field_names? It says to change them to my own names, but I have no idea what they are or where to find them. When I uncomment the drupal_set_message lines nothing happens.

Unable to paste without error

Hello,

I get various errors when pasting the pre-process code. I've renamed the theme_name to the theme that is currently being used for the site.

I am pasting the pre-process code right at the bottom and it comes up with"Parse error: syntax error, unexpected '[', expecting T_STRING in C:\Inetpub\drupal-6.17\themes\customtheme\template.php on line 126

Can someone assist as soon as please?

Please ignore my comment, the

Please ignore my comment, the brackets [ and ] should be removed when renaming (as per post below!)

Can't add my own field

I am trying to display different fields than in the example, but the field I want to use is not showing up when I uncomment the drupal_set_message lines. Specifically, my content type has a CCK Link field that allows multiple values (i.e., each node can have multiple links). My view includes this field and shows the links in the preview.

I was also wondering why all the field names contain "field_pager_item_text": why is it "node_data_field_pager_item_text_field_slide_text_value" and not "node_data_field_slide_text_value"?

Thanks for your help and this nice module

Re: Can't add my own field

For multiple value field you need to disable group fields so for each value a row is made for the slideshow.

Hope this helps you further.

If not please make an issue in the issue queue.

I agree with this very good

I agree with this very good comment.
Jeu gratuit

How to link slide_title to

How to link slide_title to the node? Is it possible to make in the template.php in line
$slider_items[$key1]['slide_title'] = check_plain($result->node_title) ; ??

Re: How to link slide_title to node

You can use:

 
$slider_items[$key1]['slide_title'] =  l(check_plain($result->node_title), 'node/' . $result->nid);

Hope this helps you further, please let me know.

Great module. Doc. suggestion.

Hi, you might want to specify that you have to rename the entire "[THEME_NAME]", including the brackets. So that people don't try this: "[some_theme_name]_preprocess_ddblock_cycle_block_content", when it should be this: "some_theme_name_preprocess_ddblock_cycle_block_content".

Otherwise this is great documentation for a great module.

Re: Great module. Doc. suggestion.

Thanks for the suggestion. Done. We always try to improve the documentation. More suggestions welcome.

Theme other then Garlad?

Thank you for the awesome module.

My ddblock node displays fine in garland theme, but not in a new them I installed. I updated template.php and appended the theme name. The debug info shows fine, but not the ddblock.

Any thoughts?

Thanks!

RE: Theme other then Garland?

Ahh!
I forgot to upload the ddblock custom theme folder to the new theme.
Also, remeber to run update.php when you modify your theme files.

RE: Theme other then Garland?

Running update.php is definitely not neccessary... but you should empty your site-cache.