Closed (fixed)
Project:
ImageField
Version:
5.x-2.0-rc2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Dec 2007 at 14:03 UTC
Updated:
4 Feb 2008 at 09:43 UTC
I'm using the imagefield module to place the images in a block with the views module. I created a block with images of recent nodes. I want to make the images in this views block hyperlinks that link to the attached node.
I don't know if this is a views issue or an imagefield issue.. Is there any way to hardcode every image as an hyperlink to its node.
Cheers
View block
$view = new stdClass();
$view->name = 'website_latest_thumb';
$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 = 'table';
$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 (
array (
'tablename' => 'node_data_field_date_year',
'field' => 'field_date_year_value',
'sortorder' => 'DESC',
'options' => '',
),
array (
'tablename' => 'node_data_field_date_month',
'field' => 'field_date_month_value',
'sortorder' => 'DESC',
'options' => '',
),
array (
'tablename' => 'node_data_field_date_day',
'field' => 'field_date_day_value',
'sortorder' => 'DESC',
'options' => '',
),
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'node_data_field_thumbnail',
'field' => 'field_thumbnail_fid',
'label' => '',
'handler' => 'content_views_field_handler_group',
'options' => 'default',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'website',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(node_data_field_date_year, node_data_field_date_month, node_data_field_date_day, node_data_field_thumbnail, node);
$views[$view->name] = $view;
Comments
Comment #1
dopry commentedYou can theme it, or use image cache and one of the formatters that support linking.
Comment #2
moshe weitzman commentedIt is a bit silly to introduce imagecache just for its link feature. Perhaps we should ship with a 'node link' option in our Views definition.
Comment #3
chuyskywalker commentedI agree with the above and would love to have it :D
For such a small chunk of functionality, I'd rather not install yet another module. Especially since this is the only feature I'd want from it.
Comment #4
chrisfab commentedhow did you do it?
I tried installing imagecache but don't see how it enables me to create a 'node link' when I create a new view and add an imagefield to "Fields".
It could probably be solved with making a views.inc file in my imagefield module - but I haven't a clue on how to get started or how to do this. I'll gladly give it a go if someone could push me in the right direction?
How else can I make imagefields link to nodes?
Comment #5
apotek commentedTo fill this out a little bit. Here's how I did it, out of my own ignorance and blind confusion stumbling around in cck, and views code. This is probably wrong, but it works.
In my custom module, which I use just so I can easily override default behavior through the use of hooks, I created the following two functions:
Obviously, you'll want to replace "mymodule" with the actual name of the module you use for this sort of thing.
Comment #6
chrisfab commentedHi again. I'm attempting to extend the Imagefield module with additional 'handler' functionalities for Views.
But I'm a bit stuck, as my code renders the wrong images.
I have created a field called 'logo_img' and added it as a field to my Stories.
Thus I reference the table 'content_type_story' as well as the field 'logo_img_fid' in my code.
From my code below I manage to display an image in the browser window with correct a-tag information. But the image is the wrong one, and I'm not sure why.
Can anybody help me out here?
(I would also appreciate comments on how to make my code generic, so others may benefit.)
I have added this code to my local imagefield.module file: