3

Product zoom code php 5.3 warning

http://drupal.org

Hi!

I'm trying to implement this piece of code below (from http://www.wardontheweb.com/how-to-enable-ubercart-product-image-zoom-wi...) to enable product zoom for my übercart site, but I'm getting this error message

warning: strlen() expects parameter 1 to be string, array given in sites/all/themes/zen_sub/templates/node-product.tpl.php on line 5.

I'm running php 5.3 and after doing some google searching I came across this thread http://www.php.net/manual/en/function.strlen.php#98315.

in PHP 5.3, strlen($attributes) returns NULL, while in PHP 5.2, strlen($attributes) returns the integer 5.

I'm not sure but I'm guessing this is what causes this problem.

Are there any suggestions how I could remedy this issue? I have posted a message to the original author of the code but I'm still waiting for a reply. Any help is really appreciated! First post on here so I apologize if this is in the wrong section!

<?php
drupal_add_js(drupal_get_path('module', 'cloud_zoom') . '/cloud-zoom/cloud-zoom.1.0.2.min.js');
drupal_add_css(drupal_get_path('module', 'cloud_zoom') . '/cloud-zoom/cloud-zoom.css');
if (is_array($node->field_image_cache) && count($node->field_image_cache) > 0 && strlen($node->field_image_cache[0]) > 0){

    // Display the primary image.
    echo l(theme('imagecache', 'product_full', $node->field_image_cache[0]['filepath'], $node->field_image_cache[0]['data']['alt'], $node->field_image_cache[0]['data']['title']), imagecache_create_path('product_zoom', $node->field_image_cache[0]['filepath']), array('attributes' => array('class' => 'cloud-zoom', 'id' => 'zoom1'), 'html' => TRUE));

    // Display the gallery thumbnails.
    $num_images = count($node->field_image_cache);
    if ($num_images > 1){
        for ($i = 0; $i < $num_images; $i++){
            echo '<a class="cloud-zoom-gallery" href="' . base_path() . imagecache_create_path('product_zoom', $node->field_image_cache[$i]['filepath']) . '" rel="useZoom:\'zoom1\', smallImage:\'' . base_path() . imagecache_create_path('product_full', base_path() . $node->field_image_cache[$i]['filepath']) . '\'">' . theme('imagecache', 'product_thumbnail', $node->field_image_cache[$i]['filepath']) . '</a>';
        }
    }
}
?>

Read »
Created by drupalmodules 38 weeks 6 days ago
Category: News   Tags:

PSD to Drupal Theme

Drupal Development

Module Development

Get an Estimate

Recent comments