Views Slideshow: Dynamic Display Block + IMCE

neptunus képe

Sziasztok!

A segítségeteket szeretném kérni!

Sikerült beüzemelni a "Views Slideshow: Dynamic Display Block"-ot, ami Imagefield-et használ képfeltöltéshez. Én IMCE Image-t szeretnék használni és nem Imagefield-et az IMCE jobb és kézreállóbb szolgáltatásai miatt.

A normál (nem a Views-os) DDBLOCK modulnál sikerült megoldanom ezt a problémát a következő leírás alapján: http://drupal.org/node/460778

Ez a template.php-be illesztett preprocess funkciót írta felül (ld az előbb megadott linket és ld a lent mellékelt kódrészletet).

Ugyan ebbe a template.php-be illesztettem a Views-os ddblock modul preprocess funkcióját, (ami az imagefield-el működik is) amit át szertnék írni úgy, hogy az IMCE Image field-ben tárolt képet használja. Úgy látom, hogy a a Views-os ddblock-ban a filepath-t nem a preprocess, hanem a modul csinálja.

Segítség képpen:

Views Slideshow: DDBlock oldala:
http://drupal.org/project/views_slideshow_ddblock
A szükséges import file-ok (köztük a template.php-hez szükséges prepocess funkció)

A DDBLOCK fejlesztőinek oldala és abban a Views-os field-ekkel goglalkozó rész:
http://ddblock.myalbums.biz/node/980

Fórum, ami alapján sikeresen megcsináltam a normál ddblock-hoz a prepocess módosítást:
http://drupal.org/node/460778

Az én problémámmal foglalkozó fórum, ami azonban számomra nem nyújtott elegendő segítséget:
http://drupal.org/node/657540

A Viewsom kimenete akkor amikor imagefile-del működik és a views-ba már beállítottam az IMCE mezőt:

Pager Settings => array (
  'delta' => 1,
  'debug_info' => 'drupal',
  'output_type' => 'view_fields',
  'pager' => 'custom-pager',
  'pager_container' => '.custom-pager-item',
  'pager_event' => 'click',
  'pager_position' => 'top',
  'pager2' => 0,
  'pager2_position' => 
  array (
    'slide' => 'slide',
    'pager' => 0,
  ),
  'pager2_pager_prev' => 'prev',
  'pager2_pager_next' => 'next',
  'pager2_slide_prev' => '',
  'pager2_slide_next' => '',
  'slide_text' => 1,
  'slide_text_info_button' => NULL,
  'template' => 'vsd-upright50',
  'custom_template' => '',
  'view_name' => 'hangszerek',
  'view_display_id' => 'block_1',
)
 
#

View - name => 'hangszerek'
 
#

View - display_Id => 'block_1'
 
#

Number of slides => 3
 
#

Imgcache_slide => NULL
 
Content first slide => stdClass::__set_state(array(
   'nid' => '61',
   'node_title' => 'News Item Title 1',
   'node_data_field_pager_item_text_field_pager_item_text_value' => 'News item Pager 1',
   'node_type' => 'ddblock_news_item',
   'node_vid' => '61',
   'node_data_field_pager_item_text_field_slide_text_value' => '
News item Slide text 1
',
   'node_data_field_image_field_image_fid' => '207',
   'node_data_field_image_field_image_list' => '1',
   'node_data_field_image_field_image_data' => 'a:3:{s:11:"description";s:0:"";s:3:"alt";s:0:"";s:5:"title";s:0:"";}',
   'node_revisions_body' => '
News item Body 1 News item Body 1 News item Body 1 News item Body 1.
 
 
 
News item Body 1 News item Body 1 News item Body 1 News item Body 1 News item Body 1 News item Body 1News item Body 1News item Body 1。
',
   'node_revisions_format' => '4',
   'node_data_field_pager_item_text_field_imce_imagepath_imceimage_path' => '/./sites/sno.hu/files/images/200px-Casio_logo.svg_.png',
   'node_data_field_pager_item_text_field_imce_imagepath_imceimage_width' => '200',
   'node_data_field_pager_item_text_field_imce_imagepath_imceimage_height' => '40',
   'node_data_field_pager_item_text_field_imce_imagepath_imceimage_alt' => '',
   'node_created' => '1265376523',

A fentiek alapján az IMCE mezőm amit használni kéne:

node_data_field_pager_item_text_field_imce_imagepath_imceimage_path

Ide másolom az én template.php-m azon részét, ami a ddblock és a views-os ddblock funkciókat tartalmazza: (SNO-val jelöltem amiket én módosítottam a leírások alapján. A views-os részt módosítások nélkül látható, mert amikkel próbálkoztam nem működtek)

A ==== jelek után a normál ddblock következik (ebben látszik az IMCE-smegoldás, a ++++++ jelek után a Views-os, amit módosítani kéne, hogy működjön az IMCE-vel:

/*!
 
 * ====================================================
 *
 * 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-KEZDODIK ----------------------------------
          //   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-VEGZODIK ----------------------------------
           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-KEZDODIK ----------------------------------
 
            }
 
           // if filepath was found either via text field or via ImageField module, then
	  // add slide_image variable to the slider_items
          if ($filepath) {
 
          // SNO-VEGZODIK ----------------------------------
 
          //  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-KEZDODIK ----------------------------------
 
//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-VEGZODIK ----------------------------------
          // 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-KEZDODIK ----------------------------------
           }
 
	  // if filepath was found either via text field or via ImageField module, then
            // SNO-VEGZODIK ----------------------------------
	  // 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;
 
  }    
 
}

Segítségeteket előre is köszönöm!

Péter

Drupal verzió: 
neptunus képe

Ha valakit érdekel a téma, akkor itt a megoldása a kérdésemnek. Csak a Views-os DDBLOCK-ra vonatkozó részt másolom ide,amit a template.php-be kell beilleszteni az első sor (< ? php) nélkül

/*!
 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
 * 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;
  }    
 
}

Remélem, lesz aki tudja használni!
Üdvözlet mindenkinek!
Péter

0
0

Földes Péter

tiburi képe

Hát nem tudom, nekem sehogyan se működik ez a ddblock, pedig ezer féle opciót, szinte minden lehetőséget kipróbáltam, de semmi. Feladom.

0
0