HI

i got the nodecarousel setup and it circles my node titles as advertised. As many others i'd like to have it show cck filefield image instead of the title. The cck filefield image is resized by imagecache. I've tried all the codesnippets for simalar image carousel requests but it all ends up just showing me the clickable title. My cck filefield image is stored in field_cover, my imagecache preset is called "cover".

I changed a snippet i found and tried adding the following to template.php of my theme internet_studio:

function internet_studio_nodecarousel_node($node, $name='') {
$content = '<div class="node-carousel-item">';
$node = node_build_content($node, TRUE, FALSE);
$content .= '<div class="hidden nid">'. $node->nid .'</div>';
$content .= '<div class="carousel-image">'. theme('imagecache', 'cover', $node->field_cover[0]['filepath']) .'</div>';
$content .= ''. l($node->field_intro[0]['value'], 'node/'. $node->nid) .'';
$content .= '</div>';
return $content;
}

but to no avail. I tried pasting the code from the handbook page (without changing anything but my theme name after the funtion) : http://drupal.org/node/275747 but that didnt help either. I have no idea weither it has to do with filefield image, with putting stuff in the wrong place or just not knowing enough php so my modifications to the snippets just arent correct. Thats why i tried adding as much info about imagecache presets, themename etc.

I hope someone can point me in the right direction because this is the final thing i need to get fixed before i can put my site live :)

Kind regards

Yoda99

Comments

gthing’s picture

I can't get this snippet to work either. The only thing I am changing is the spot where you have "cover" to the imagefield I have defined. Should I also be changing "filepath?' If so is there an example of what it should look like?

Steve Dondley’s picture

Did you clear your cache?

gthing’s picture

I got it working by updating to the dev version of nodecarousel. Thanks, Steve.

georgedamonkey’s picture

I'm also trying to get this working, and have the latest dev version of the module. Here's what I have for my code:

function deco_nodecarousel_node($node, $name='') {
$content = '<div class="node-carousel-item">';
$node = node_build_content($node, TRUE, FALSE);
$content .= '<div class="hidden nid">'. $node->nid .'</div>';
$content .= '<div class="carousel-image">'. theme('imagecache', 'featured', $node->field_cover[0]['filepath']) .'</div>';
$content .= ''. l($node->field_intro[0]['value'], 'node/'. $node->nid) .'';
$content .= '</div>';
return $content;
}

I'm using the 'deco' theme, and my imagecache is called 'featured'. What ends up showing is broken images with this as the path for them: http://beta.menashalibrary.org/sites/beta.menashalibrary.org/files/image... so, it's not pulling the image from the nodes to display in that box.

Previously, I had this code which did work fine:

function deco_nodecarousel_node($node, $name='') {
  $content = '<div class="node-carousel-item">';
  $image_node = node_load($node->iid);
  $content .= '<div class="node-carousel-title node-carousel-label">'. l(image_display($image_node, IMAGE_ORIGINAL), 'node/'. $node->nid, array('html' => TRUE)) .'</div>';
  $content .= '<div class="hidden nid">'. $node->nid .'</div>';
  $node_words = explode(' ', $node->title);
  $content .= '<div class="teaser"><div class="node-carousel-index">'. $node_words[0] .'</div></div>';
  $content .= '</div>';
  return $content;
}

But, that pulled the image from the image module. I'd much rather use the imagecache module instead.

I'd really appreciate any help you can provide.

bgilday’s picture

Title: Filefield image / imagecach » Filefield image / imagecache / link to full node

Your first code snippet worked ok for me, with the exception that the image did not link to the full node. I made a slight tweak to the code to fix the image link issue and it works just great. I'm using nodecarousel version 1.0, my theme name is cwl, my imagecache preset name is headline and my image field name is field_image_attachment. Here's the template.php code snippet:

function cwl_nodecarousel_node($node, $name='') {
	$content = '<div class="node-carousel-item">';
	$node = node_build_content($node, TRUE, FALSE);
	$content .= '<div class="hidden nid">'. $node->nid .'</div>';
	$carousel_image = '<div class="carousel-image">'. theme('imagecache', 'headline', $node->field_image_attachment[0]['filepath']) .'</div>';
	$content .= l($carousel_image, 'node/'. $node->nid, NULL , NULL,  NULL,  FALSE, TRUE);
	$content .= '</div>';
	return $content;
}

I hope this helps.

georgedamonkey’s picture

I tried your snippet, replacing with my information, and when I view the page I get this error message:

Fatal error: Unsupported operand types in /var/clients/client0/web2/web/includes/common.inc on line 1445

georgedamonkey’s picture

Nevermind. Spent a bit more time with it and I was able to tweak the code to get it to work:

function deco_nodecarousel_node($node, $name='') {
  $content = '<div class="node-carousel-item">';
  $image_node = node_load($node->iid);
$content .= '<div class="carousel-image">'. theme('imagecache', 'featured', $node->field_image[0]['filepath']) .'</div>';
  $content .= '<div class="hidden nid">'. $node->nid .'</div>';
  $content .= '<div class="teaser"><div class="featured-title">'.l($node->title, 'node/' .$node->nid) .'</div><div class="node-carousel-index">'. $node->teaser .' <div id="read-more"> '.l('[Read More]', 'node/'. $node->nid).' </div></div></div>';
  $content .= '</div>';
  return $content;
}

But, that doesn't link the image to the node. I 'think' I need to add in this: 'node/'. $node->nid, array('html' => TRUE)) .

But, any combination I try I end up with an error and it doesn't load. What am I missing?

Thank you so much for your help.

bgilday’s picture

Try this - I added one line of code for the image link...

function deco_nodecarousel_node($node, $name='') {
    $content = '<div class="node-carousel-item">';
    $image_node = node_load($node->iid);
    $content .= '<div class="carousel-image">'. theme('imagecache', 'featured', $node->field_image[0]['filepath']) .'</div>';
    $content .= l($carousel_image, 'node/'. $node->nid, NULL , NULL,  NULL,  FALSE, TRUE);
    $content .= '<div class="hidden nid">'. $node->nid .'</div>';
    $content .= '<div class="teaser"><div class="featured-title">'.l($node->title, 'node/' .$node->nid) .'</div><div class="node-carousel-index">'. $node->teaser .' <div id="read-more"> '.l('[Read More]', 'node/'. $node->nid).' </div></div></div>';
    $content .= '</div>';
    return $content;
}
georgedamonkey’s picture

I replaced my code with yours, and now I get this error when loading the page:

Fatal error: Unsupported operand types in /var/clients/client0/web2/web/includes/common.inc on line 1445

bgilday’s picture

Perhaps it is a D5 versus D6 issue - maybe changes within common.imc? I am running in Drupal Version 5.10. I did notice this common.inc error similar to yours.

georgedamonkey’s picture

Ah, yes. I'm running Drupal 6.4.

jessicakoh’s picture

I use this method.

For imagecache, got to your content type, edit content type, go to "Display field", change display field as "imagecache as link" in your teaser. You should be able to get a link.

Does this work for you?

jessicakoh’s picture

http://drupal.org/node/228291

Try the snippet for template.php

georgedamonkey’s picture

That didn't work for me, unfortunately. When I looked in there, I noticed it was all ready set to do that. But, alas, it doesn't work at all.

georgedamonkey’s picture

I tried that snippet as well, but unfortunately that didn't cause the image to be a link either.

jessicakoh’s picture

function abc_feature_1() {
	//$form = array();
  $image = variable_get('featured_imagecache_1','');
	$pid = _imagecache_preset_load_by_name($image);
	$preset = _imagecache_actions_get_by_presetid($pid);
	//usort($preset, '_menu_sort');
	$weight = -700;
	$width = 641;
	$height = 229;
	foreach ($preset as $pr) {
		if ($pr['weight'] >= $weight) {
			$width = $pr['data']['width'];
			$height = $pr['data']['height'];
			$weight = $pr['weight'];
		}
	}
	$_height = $height-5;
	$_width = $width-5;
	$corners = '<div class="corners" id="c_left_top"></div>
	  <div class="corners" id="c_right_top" style="left: '.$_width.'px;"></div>
	  <div class="corners" id="c_left_bottom" style="top: '.$_height.'px;"></div>
	  <div class="corners" id="c_right_bottom" style="top: '.$_height.'px; left: '.$_width.'px"></div>';

	$output = '<div class="teaser"><div class="inner" style="height: '.$height.'px; width: '.$width.'px;">';
  $ul = '<ul class="primary tabs anchors">';
  $image_field = variable_get('featured_imagefield_1','');
  $divs = '';
  $first = 1;
  for ($i = 1; $i <= 5; $i++) {
    $nid = variable_get('featured_block_1_'.$i, '0');
    if ($nid) {
			//<ul>
      $ul .= '<li';
      if ($first) {
        $ul .= ' class="tabs-selected"';
        $first = 0;
      }
      $ul .= '><a href="#" id="tabs-'.$i.'">'.$i.'</a>';
      //<div> - 5
      $node = node_load($nid);
      $height_background = $height;
      $teaser = abc_node_teaser($node, NULL, 180);
      $image = $node->$image_field;

      $divs .= '<div id="tabs-'.$i.'" class="fragment" style="display:none">'.theme('imagecache', variable_get('featured_imagecache_1',''), $image[0]['filepath'], $image[0]['alt'], $image[0]['title']).'<div class="panel-background" style="height: '.$height_background.'px"></div><div class="description"><p class="title"><strong>'.l($node->title, 'node/'.$node->nid).'</strong></p>'.$teaser.'</div>'.$corners.'</div>';
    }
  }
  $ul .= '</ul>';
	$output = ($i > 1) ? $output.$ul.$divs.'</div></div>' : '';
	
	
  return $output;
}

This is a snippet from the template.php of a theme that has similar function. Does the code make any sense to you?
I am still a newbie. Hope this help.

ultimateboy’s picture

Status: Active » Closed (duplicate)