Hey Phillip,

I've been trying to get IMCE to work with this and have read the tutorial posted for the regular ddblock however just can't get it working. I noticed that whats causing it is you don't put the $filepath in the preprocess functions for this one, like you do for the regular ddblock. Is there a way that IMCE could be integrated with this, or I should say, is there a way that will allow me to have the $filepath variable in the preprocess functions so I can integrate IMCE with it.

Any and all help is greatly appreciated. Thank-you kindly,

Pete

CommentFileSizeAuthor
#5 template.php_.txt18 KBneptunus

Comments

ppblaauw’s picture

Status: Active » Postponed (maintainer needs more info)

In the views_slideshow_ddblock preprocess function I use a function in the module to add an image to make it more simple for users.

You can use the same code which you would use in the preprocess function of the ddblock module to add an image.

What is the code you would use with the ddblock module to add IMCE support?

Please attach the code, so I can help you better.

PMatwyuk’s picture

Hey Phillip,

This is the code I found that would allow IMCE and DDBLOCK to talk. - http://drupal.org/node/460778

However the pre-process functions for the view are different then that of the regular ddblock module. Which is why I was wondering about having the $filepath added into the view pre-process functions.

If I use the code as is with the views pre-process functions then I get a N/A reurnted. Ive found its returning this because the pre-process function is looking for a FID number and not the path to the file.

PMatwyuk’s picture

Update...

I've managed to get the files from the IMCE CCK Image field to appear in the slide, but not the pager. Where is the image for the scrollable pager being set so that I can also set that to contain the IMCE image?

ppblaauw’s picture

You can use the same code in the preprocess function

([vsd_theme_name]_preprocess_views_slideshow_ddblock_pager_content) 

for the pager as you did in the content preprocess function

 ([vsd_theme_name]_preprocess_views_slideshow_ddblock).

Do you have a link to the Internet site?

Hope this helps you further, please let me know.

neptunus’s picture

StatusFileSize
new18 KB

Hi,

May I ask You to share me information how can I use IMCE Image with Views Slideshow: Dynamic Display Block?
The regular ddblock is working fine with the IMCE, but no success with the Views version.

Here is a piece of my template.php code (The After the ====== signs is the regular ddbloc, and after the ++++++ signs is the views ddblock. I don't show my modifications at the views part because it don't work)

/*!

 * =========================================================================================
 *
 * DYNAMIC DISPLAY BLOCK preprocess functions

 * Copyright (c) 2008 - 2009 P. Blaauw All rights reserved.

 * Version 1.6 (01-OCT-2009)

 * Licenced under GPL license

 * http://www.gnu.org/licenses/gpl.html

 */



 /**

 * Override or insert variables into the ddblock_cycle_block_content templates.

 *   Used to convert variables from view_fields to slider_items template variables

 *

 * @param $vars

 *   An array of variables to pass to the theme template.

 * 

 */

function casio3_preprocess_ddblock_cycle_block_content(&$vars) {

  if ($vars['output_type'] == 'view_fields') {

    $content = array();

    // Add slider_items for the template 

    // If you use the devel module uncomment the following line to see the theme variables

    // dsm($vars['settings']['view_name']);  

    // dsm($vars['content'][0]);

    // If you don't use the devel module uncomment the following line to see the theme variables

//    drupal_set_message('<pre>' . var_export($vars['settings']['view_name'], true) . '</pre>');

//    drupal_set_message('<pre>' . var_export($vars['content'][0], true) . '</pre>');

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

      if (!empty($vars['content'])) {

        foreach ($vars['content'] as $key1 => $result) {

          // add slide_image variable 

 
          // SNO-modification start ----------------------------------
          //   initialize & reset path
	  $filepath = FALSE;
          // try to find a filename (path) to the image, either via IMCEImage..
          if (isset($result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path)) {
	    $filepath=$result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path;
	    // is there an initial '/'?
	    $position = strpos($filepath, '/');  // this should normally be 0
	    if(  ($position !== FALSE) && ($position == 0)) {
	      // if so, strip it
	      $filepath = substr($filepath, 1);
	    }
          } // .. or via ImageField..
	  else
            // SNO-modification end ----------------------------------

           if (isset($result->node_data_field_image_field_image_fid)) {

            // get image id

             $fid = $result->node_data_field_image_field_image_fid;

            // get path to image

            $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));

          // SNO-modification start ----------------------------------

            }

           // if filepath was found either via text field or via ImageField module, then
	  // add slide_image variable to the slider_items
          if ($filepath) {

          // SNO-modification end ----------------------------------

          //  use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)

            if (module_exists('imagecache') && is_array(imagecache_presets()) && $vars['imgcache_slide'] <> '<none>'){

              $slider_items[$key1]['slide_image'] = 

              theme('imagecache', 

                    $vars['imgcache_slide'], 

                    $filepath,

                    check_plain($result->node_title));

            }

            else {          

              $slider_items[$key1]['slide_image'] = 

                '<img src="' . base_path() . $filepath . 

                '" alt="' . check_plain($result->node_title) . 

                '"/>';     

            }          

          }

          // add slide_text variable

          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);

          }

          // add slide_title variable

          if (isset($result->node_title)) {

            $slider_items[$key1]['slide_title'] =  check_plain($result->node_title);

          }

          // add slide_read_more variable and slide_node variable

          if (isset($result->nid)) {

            $slider_items[$key1]['slide_read_more'] =  l('Read more...', 'node/' . $result->nid);

            $slider_items[$key1]['slide_node'] =  base_path() . 'node/' . $result->nid;

          }

        }

      }

    }    

    $vars['slider_items'] = $slider_items;

  }

}  

/**

 * Override or insert variables into the ddblock_cycle_pager_content templates.

 *   Used to convert variables from view_fields  to pager_items template variables

 *  Only used for custom pager items

 *

 * @param $vars

 *   An array of variables to pass to the theme template.

 *

 */

function casio3_preprocess_ddblock_cycle_pager_content(&$vars) {

  if (($vars['output_type'] == 'view_fields') && ($vars['pager_settings']['pager'] == 'custom-pager')){

    $content = array();

    // Add pager_items for the template 

    // If you use the devel module uncomment the following lines to see the theme variables

    // dsm($vars['pager_settings']['view_name']);     

    // dsm($vars['content'][0]);     

    // If you don't use the devel module uncomment the following lines to see the theme variables

//    drupal_set_message('<pre>' . var_export($vars['pager_settings'], true) . '</pre>');

//    drupal_set_message('<pre>' . var_export($vars['content'][0], true) . '</pre>');

    if ($vars['pager_settings']['view_name'] == 'news_items') {

      if (!empty($vars['content'])) {

        foreach ($vars['content'] as $key1 => $result) {

          // SNO-modification start ----------------------------------

//initialize & reset path
	  $filepath = FALSE;

	  // try to find a filename (path) to the image, either via IMCEImage..
          if (isset($result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path)) {
	    $filepath=$result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path;
	    // is there an initial '/'?
	    $position = strpos($filepath, '/'); // this should normally be 0
	    if(  ($position !== FALSE) && ($position == 0)) {
	      // if so, strip it
	      $filepath = substr($filepath, 1);
	    }
          } // .. or via ImageField
          else 

          // SNO-modification end ----------------------------------

          // add pager_item_image variable

          if (isset($result->node_data_field_image_field_image_fid)) {

            $fid = $result->node_data_field_image_field_image_fid;

            $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));


            // SNO-modification start ----------------------------------

           }

	  // if filepath was found either via text field or via ImageField module, then

            // SNO-modification end ----------------------------------

	  // add pager_items image variable
	  if ($filepath) {
            //  use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)

            if (module_exists('imagecache') && 

                is_array(imagecache_presets()) && 

                $vars['imgcache_pager_item'] <> '<none>'){

              $pager_items[$key1]['image'] = 

                theme('imagecache', 

                      $vars['pager_settings']['imgcache_pager_item'],              

                      $filepath,

                      check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value));

            }

            else {          

              $pager_items[$key1]['image'] = 

                '<img src="' . base_path() . $filepath . 

                '" alt="' . check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value) . 

                '"/>';     

            }          

          }

          // add pager_item _text variable

          if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) {

            $pager_items[$key1]['text'] =  check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value);

          }

        }

      }

    }

    $vars['pager_items'] = $pager_items;

  }    

}




/*!
 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 *
 * VIEWS SLIDESHOW DYNAMIC DISPLAY BLOCK preprocess functions

 * Author P.P. Blaauw

 * Version 1.3 (07-SEP-2009)

 * Licenced under GPL license

 * http://www.gnu.org/licenses/gpl.html

 */



 /**

 * Override or insert variables into the views_slideshow_ddblock_cycle_block_content templates.

 *   Used to convert variables from view_fields to slider_items template variables

 *

 * @param $vars

 *   An array of variables to pass to the theme template.

 * 

 */

function casio3_preprocess_views_slideshow_ddblock(&$vars) {

  drupal_rebuild_theme_registry();

  $settings = $vars['views_slideshow_ddblock_slider_settings'];

  // for showing debug info

  views_slideshow_ddblock_show_content_debug_info($vars);

  if ($settings['output_type'] == 'view_fields') {

    if ($settings['view_name'] == 'hangszerek' && $settings['view_display_id'] == 'block_1') {

      if (!empty($vars['views_slideshow_ddblock_content'])) {

        foreach ($vars['views_slideshow_ddblock_content'] as $key1 => $result) {

          // add slide image variable

          $slider_items[$key1]['slide_image'] = views_slideshow_ddblock_add_image(

            $vars,

            // determines which imagcache preset to use, leave to 'slider_item_image'

            'slider_item_image',

            // name of CCK generated image field, change if needed.
            $result->node_data_field_image_field_image_fid,


            // alt attribute of image or NULL

            $result->node_title,

            // cck content type for default image or NULL, change if needed

            NULL, //'ddblock_news_item',

            // cck fieldname for default image or NULL, change if needed

            NULL, //'field_image',

            // to link the image to or NULL, change if needed

            NULL // base_path() . 'node/' . $result->nid

          );

          // add slide_text variable

          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);

          }

          // add slide_title variable

          if (isset($result->node_title)) {

            $slider_items[$key1]['slide_title'] =  check_plain($result->node_title);

          }

          // add slide_read_more variable and slide_node variable

          if (isset($result->nid)) {

            $slider_items[$key1]['slide_read_more'] = '<a href="' . base_path() . 'node/' .  $result->nid . '">' . t('Read more') . '</a>';

            $slider_items[$key1]['slide_node'] = base_path() . 'node/' . $result->nid;

          }

        }

      }

    }    

    $vars['views_slideshow_ddblock_slider_items'] = $slider_items;

  }

}  

/**

 * Override or insert variables into the views_slideshow_ddblock_cycle_pager_content templates.

 *   Used to convert variables from view_fields  to pager_items template variables

 *  Only used for custom pager items

 *

 * @param $vars

 *   An array of variables to pass to the theme template.

 *

 */

function casio3_preprocess_views_slideshow_ddblock_pager_content(&$vars) {

  $settings = $vars['views_slideshow_ddblock_pager_settings'];

  // for showing debug info

  views_slideshow_ddblock_show_pager_debug_info($vars);

  if (($settings['output_type'] == 'view_fields') && 

      ($settings['pager'] == 'number-pager' || 

      $settings['pager'] == 'custom-pager' ||

      $settings['pager'] == 'scrollable-pager' )) {

    if ($settings['view_name'] == 'hangszerek' && $settings['view_display_id'] == 'block_1') {

      if (!empty($vars['views_slideshow_ddblock_content'])) {

        foreach ($vars['views_slideshow_ddblock_content'] as $key1 => $result) {

          // add pager_item_image variable

          $pager_items[$key1]['image'] = views_slideshow_ddblock_add_image(

            $vars,

            // determines which imagcache preset to use, leave to 'pager_item_image'

            'pager_item_image',

            // name of CCK generated image field, change if needed.

            $result->node_data_field_image_field_image_fid,

            // alt attribute of image or NULL

            $result->node_data_field_pager_item_text_field_pager_item_text_value,

            // cck content type for default image or NULL, change if needed

            NULL, //'ddblock_news_item',

            // cck fieldname for default image or NULL, change if needed

            NULL, //'field_image',

            // to link the image to or NULL, change if needed

            NULL // base_path() . 'node/' . $result->nid

          );

          // add pager_item _text variable

          if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) {

            $pager_items[$key1]['text'] =  check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value);

          }

        }

      }

    }

    $vars['views_slideshow_ddblock_pager_items'] = $pager_items;

  }    

}

Thank youall of your help!

Peter

neptunus’s picture

Assigned: Unassigned » neptunus

OK, Here is the solution to my question:

Views Slideshow: Dynamic Display Block + IMCE Image field

Copy this code to your theme's template.php with out the < ? php in the first line.
(IMCE Image field name may be something else)

/*!
 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
 * VIEWS SLIDESHOW DYNAMIC DISPLAY BLOCK preprocess functions
 * Author P.P. Blaauw
 * Version 1.3 (07-SEP-2009)
 * Licenced under GPL license
 * http://www.gnu.org/licenses/gpl.html
 */

 /**
 * Override or insert variables into the views_slideshow_ddblock_cycle_block_content templates.
 *   Used to convert variables from view_fields to slider_items template variables
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 * 
 */
function casio3_preprocess_views_slideshow_ddblock(&$vars) {
  drupal_rebuild_theme_registry();
  $settings = $vars['views_slideshow_ddblock_slider_settings'];
  // for showing debug info
  views_slideshow_ddblock_show_content_debug_info($vars);
  if ($settings['output_type'] == 'view_fields') {
    if ($settings['view_name'] == 'hangszerek' && $settings['view_display_id'] == 'block_1') {
      if (!empty($vars['views_slideshow_ddblock_content'])) {
        foreach ($vars['views_slideshow_ddblock_content'] as $key1 => $result) {
          // add slide image variable

// BB FILEPATH CODE START

$filepath = FALSE;
          if (isset($result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path)) {
	    $filepath=$result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path;
	    // is there an initial '/'?
	    $position = strpos($filepath, '/'); // this should normally be 0
	    if(  ($position !== FALSE) && ($position == 0)) {
	      // if so, strip it
	      $filepath = substr($filepath, 1);
	    }
          } // .. or via ImageField
          else 
          if (isset($result->node_data_field_image_field_image_fid)) {
            $fid = $result->node_data_field_image_field_image_fid;
            $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
           }

	  if ($filepath) {
              $slider_items[$key1]['slide_image'] = 
                '<img src="' . base_path() . $filepath . 
                '" alt="' . check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value) . 
                '"/>';     
        
          }

// BB FILEPATH CODE END

          // add slide_text variable
          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);
          }
          // add slide_title variable
          if (isset($result->node_title)) {
            $slider_items[$key1]['slide_title'] =  check_plain($result->node_title);
          }
          // add slide_read_more variable and slide_node variable
          if (isset($result->nid)) {
            $slider_items[$key1]['slide_read_more'] = '<a href="' . base_path() . 'node/' .  $result->nid . '">' . t('Read more') . '</a>';
            $slider_items[$key1]['slide_node'] = base_path() . 'node/' . $result->nid;
          }
        }
      }
    }    
    $vars['views_slideshow_ddblock_slider_items'] = $slider_items;

  }

}  
/**
 * Override or insert variables into the views_slideshow_ddblock_cycle_pager_content templates.
 *   Used to convert variables from view_fields  to pager_items template variables
 *  Only used for custom pager items
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 *
 */
function casio3_preprocess_views_slideshow_ddblock_pager_content(&$vars) {
  $settings = $vars['views_slideshow_ddblock_pager_settings'];
  // for showing debug info
  views_slideshow_ddblock_show_pager_debug_info($vars);
  if (($settings['output_type'] == 'view_fields') && 
      ($settings['pager'] == 'number-pager' || 
      $settings['pager'] == 'custom-pager' ||
      $settings['pager'] == 'scrollable-pager' )) {
    if ($settings['view_name'] == 'hangszerek' && $settings['view_display_id'] == 'block_1') {
      if (!empty($vars['views_slideshow_ddblock_content'])) {
        foreach ($vars['views_slideshow_ddblock_content'] as $key1 => $result) {
          // add pager_item_image variable

// BB FILEPATH CODE START

$filepath = FALSE;
          if (isset($result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path)) {
	    $filepath=$result->node_data_field_pager_item_text_field_imce_imagepath_imceimage_path;
	    // is there an initial '/'?
	    $position = strpos($filepath, '/'); // this should normally be 0
	    if(  ($position !== FALSE) && ($position == 0)) {
	      // if so, strip it
	      $filepath = substr($filepath, 1);
	    }
          } // .. or via ImageField
          else 
          if (isset($result->node_data_field_image_field_image_fid)) {
            $fid = $result->node_data_field_image_field_image_fid;
            $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
           }

	  if ($filepath) {
                      $pager_items[$key1]['image'] = 
                '<img src="' . base_path() . $filepath . 
                '" alt="' . check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value) . 
                '"/>';     
        
          }

// BB FILEPATH CODE END


          // add pager_item _text variable
          if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) {
            $pager_items[$key1]['text'] =  check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value);
          }
        }
      }
    }
    $vars['views_slideshow_ddblock_pager_items'] = $pager_items;
  }    

}

All the best!

Peter

ppblaauw’s picture

Title: $filepath and IMCE » Using IMCE images with the views slideshow ddblock module (Fixed)
Status: Postponed (maintainer needs more info) » Fixed

Thank you Peter for posting the complete code you use.
Set Status to fixed
Changed the issue title

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.