Hej,

I am working on a new site and I am trying to get the news item slideshow working. The template is called sky and I am working with kanal_items. The portion of the template.php is:

/* Preprocess for the DDblock module */

/**
 * 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 sky_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'] == 'kanal_items') {
      foreach ($vars['content'] as $key1 => $result) {
        // add slide_image variable 
        if (isset($result->node_data_field_pager_item_text_field_image_fid)) {
          // get image id
          $fid = $result->node_data_field_pager_item_text_field_image_fid;
          // get path to image
          $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
          $slider_items[$key1]['slide_image'] = $filepath;      
        }
        // add slide_text variable
        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;
        }
        // add slide_title variable
        if (isset($result->node_title)) {
          $slider_items[$key1]['slide_title'] =  $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'] =  '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 sky_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'] == 'kanal_items') {
      foreach ($vars['content'] as $key1 => $result) {
        if (isset($result->node_data_field_pager_item_text_field_image_fid)) {
          $fid = $result->node_data_field_pager_item_text_field_image_fid;
          $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
          $pager_items[$key1]['image'] = $filepath;
        }
        if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) {
          $pager_items[$key1]['text'] =  $result->node_data_field_pager_item_text_field_pager_item_text_value;
        }
      }
    }
    $vars['pager_items'] = $pager_items;
  }    
}

The system does seem to work but no image is displayed. The code on the page simply shows up the sites base path the image field does not seem to be loaded. I can edit the code in firebug and the image is displayed in the correct way.

An extract from Firebug:

<div class="slide clear-block border" style="position: absolute; top: 0pt; left: 0pt; display: none; z-index: 2; opacity: 0;">
<div class="slide-inner clear-block border">
<img src="/dev/site/"/>
<div class="slide-text slide-text-horizontal slide-text-top clear-block border" style="">
</div>
</div>
</div>
<div class="slide clear-block border" style="position: absolute; top: 0pt; left: 0pt; display: block; z-index: 1; opacity: 0.899;">

If I edit the code after /dev/site/ and add the path to the image it functions.

Help please, sorry I can't give the site URL as it is a client development site. Please let me know if you need any more information.

Comments

ppblaauw’s picture

Status: Active » Postponed (maintainer needs more info)

Don' t see anything wrong with your code.

First can you try to clear the cache at administration > site configuration > performance.

If this does not help.

You can debug the preprocess functions to see if the field-names in your view are the same as in the preprocess functions.

If you use the Devel module you can uncomment the dsm lines in both preprocess functions to help debugging
If you don't use the Devel module you can uncomment the drupal_set_message lines in both preprocess functions to help debugging.

Hope this helps you solve the issue.
If you can not solve the issue please also send the result of the debug lines.

Please let me know the results.

pbrough’s picture

Status: Postponed (maintainer needs more info) » Active

I have uncommented the drupal_set line and the code is:

    *

      'kanal_items'

    *

      stdClass::__set_state(array(
         'nid' => '169',
         'node_title' => 'TV',
         'node_data_field_pager_item_text_field_pager_item_text_value' => 'TV',
         'node_data_field_pager_item_text_nid' => '169',
         'node_type' => 'ddblock_kanal_item',
         'node_data_field_slide_text_field_slide_text_value' => '

      TEXT Removed but appears here as entered
      ',
         'node_data_field_slide_text_nid' => '169',
         'node_data_field_image_field_image_fid' => '27',
         'node_data_field_image_field_image_list' => '1',
         'node_data_field_image_field_image_data' => 'a:3:{s:11:"description";s:6:"TV";s:3:"alt";s:0:"";s:5:"title";s:0:"";}',
         'node_data_field_image_nid' => '169',
         'node_revisions_body' => '
IMAGE REQUIRED APPEARS HERE

      TEXT Removed but appears here as entered
      ',
         'node_revisions_format' => '1',
         'node_status' => '1',
      ))

I have cleared the site cache but still the same. The functions seem to work but the images are not displayed.

ppblaauw’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for sending the information.

You have to change:

node_data_field_pager_item_text_field_image_fid

into

node_data_field_image_field_image_fid

in both preproces functions 2 times.

change

node_data_field_pager_item_text_field_slide_text_value

into

node_data_field_slide_text_field_slide_text_value

In the content preprocess function.

Maybe you also have to make .a change in the pager preprocess function for the pager_text_value

The values in the if statements in the preprocess functions have to be the same as your view-field-names.

Hope this helps you further.

Please let me know

pbrough’s picture

Status: Postponed (maintainer needs more info) » Fixed

Yes this is great and has fixed my problem. Thanks for the quick help.

Cheers
Phil

Status: Fixed » Closed (fixed)

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

ppblaauw’s picture

add tags