Hello,
..
I created a CCK node type "GalleryImage"... I use this with imagecache and a few other modules to create an image gallery...

Now, I would like to have a block on the sidebar with the Latest "GalleryImage" node and the corresponding thumbnail..

I am trying to do this with views.. following comes the export... The image is just not showing up, rather just a grey block a few pixel high and as wide as the sidebar...

I also tried with Recent Blocks, but I can only get it display the node's title and not the imagefield as thumb...

I also thought that the block may be coded in PHP, but I did not find a great deal of code googling around... if anyone has a snippet it would b great.. strange I wuold have thought to find heaps of this kind of stuff

view export

  $view = new stdClass();
  $view->name = 'Recent_Image';
  $view->description = '';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = FALSE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'node';
  $view->url = '';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = '';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'node';
  $view->nodes_per_block = '2';
  $view->block_more = FALSE;
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'galleryimage',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node);
  $views[$view->name] = $view;

Comments

nevets’s picture

Your export only gets the title field, it needs to get the field with the image.

nyumbani_yangu’s picture

I had tried without the image field and only the node title...
But even the node title itself is not showing up.

This is the export of the view with the image field in it... it does not work... like I explained in my previous post..

  $view = new stdClass();
  $view->name = 'Recent_Image';
  $view->description = '';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = FALSE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'node';
  $view->url = '';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = '';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'node';
  $view->nodes_per_block = '2';
  $view->block_more = FALSE;
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
    array (
      'tablename' => 'node_data_field_image',
      'field' => 'field_image_fid',
      'label' => '',
      'handler' => 'content_views_field_handler_group',
      'options' => 'display',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'galleryimage',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, node_data_field_image);
  $views[$view->name] = $view;

Simplicity is the ultimate sophistication, Leonardo da Vinci

newbstah’s picture

Was having a similar issue and solved it by styling the block in the node-nodetype.tpl.php in the theme.

You can have a conditional that displays teaser view, block view and node view for the specific content type.

<?php
<!-- if straight teaser on a page -->
<?php if ($node->view->block == 0 && $teaser) { ?>

<!-- if teaser's in a block -->
<?php } else if ($node->view->block == 1 && $teaser){  ?>


<!-- and here's the code I'm using for imagecache for the block -->
<?php
$folder = 'sites/all/files/uploaded_images/';
$imagename = $node->field_image_filename[0]['value'];
$imagepath = $folder.$imagename;
?>
<a href="<?php print url("node/$node->nid"); ?>"><?php print theme('imagecache', 'image_preset', $imagepath); ?></a>

  <!-- or looking at the full node -->
<?php } else { ?>

<?php } ?>
?>

The example above isn't using imagefield, but uses a filename that gets bulk uploaded. Imagefield is more straightforward, from what I recall.

You can also check the display settings on your node type - and check the size for imagecache in different situations so that the image gets called.

Also be sure that you're using GD php library. Not using GD made it so that the image didn't get created the first time it was called - thus creating the gray line of the appropriate width on the first call.

nyumbani_yangu’s picture

The following is what I placed into the node-galleryimage.tpl.php

I just had to remove the teaser condition for what I need.


<!-- if straight teaser on a page -->
<?php if ($node->view->block == 0 && $teaser) { ?>

<!-- if teaser's in a block -->
<?php } else if ($node->view->block == 1){  ?>


<!-- and here's the code I'm using for imagecache for the block -->
<?php

?>


  <!-- or looking at the full node -->
<?php } else { 

    $imagepath =  $node->field_image[0]['filepath']; 

    print theme('imagecache', 'squarethumbnail', $imagepath); 

 } ?>

Simplicity is the ultimate sophistication, Leonardo da Vinci