Can someone point a way to represent title, description and alt fields in views 2 as those fields are not exposed to the views cck field recognition system?
Possibly there is a way through views themes views-...tpl.php code, or somewhere else. I know there are ways through node-yournode.tpl.php like:

<?php if ($field_yourimagefield[0] != '' && ($teaser != 1) ): ?>
<div id="yourgallery">
<h2>mygallery</h2>
<?php
   
foreach((array)$node->field_yourimagefield as $item) {
       
$item['lightbox_preset'] = 'lightbox';
       
//$title = check_plain($item['title']);
       
if (is_string($item['data'])) {
   
$item['data'] = unserialize($item['data']);
  }
       
$alt = empty($item['data']['alt']) ? '' : $item['data']['alt'];
       
$title = empty($item['data']['title']) ? '' : $item['data']['title'];
       
$your_gallerycck = theme('imagefield_image_imagecache_lightbox2', 'imagecache_thubnailpreset', 'field_yourimagefield', $item, $node, $rel = 'lightbox');
        print
"<div class='myphoto'>". $your_gallerycck . "<p>" . $title . "</p>" . "</div>" ;
        }
?>

WHAT ABOUT VIEWS 2.x (drupal 6.x)? Has anyone implemented that, any help appreciated.. :)

Files: 
CommentFileSizeAuthor
#15 filefield_views_integration.patch5.71 KBquicksketch

Comments

For me updating FileField to the latest version fixed the problem. Have a look if that does it for you.

Category:support» feature

if you have a code solution or idea please type it here, FileField is in the latest version already, thanks for pointing that.

Implementation of hook_views_api() is not implemented in either filefield or imagefield. Also using "filefield image" instead of "imagefield" (seems the same at first place) does not point a documented near method to theme those fields.

Changing to feature request for Views2 support Implementation of hook_views_api()

if there is an other way NOW, without views support please share it with us
(lightbox can show the title, mouseover shows the title too...) but we need to put titles in an other div inside the view

I was trying to do something similar and found that $fields->handler->field_values was the key. Try using this instead of $fields->content to retrieve your images. This is inside of my views-view-fields.tpl.php file.

<?php
// get the vid from your view
$vid = $fields['vid']->content;
// use $fields->handler->field_values to get the images
$images = $fields['field_my_image_fid']->handler->field_values[$vid];
// now you can loop through each image
foreach($images as $image) {
 
// get the file id so you can rebuild the image
 
$file = field_file_load($image['fid']);
  print 
theme('imagecache', 'my-thumbnail', $file['filepath']);
 
// and then you can pull out the description
 
$data = unserialize($image['data']);
  print
$data['description'];
}
?>

I've discovered that the technique I posted above only seems to work when I allow more than one image to be uploaded to the content type, in which case the images are stored in a separate database table. I'm now trying to theme a view for a single image for the page content type and am unable to pull out the description.

If I do a print_r($fields), I can see the description buried under node_data_field_side_image_field_side_image_list but I'm not sure how to dig this out.

Note that there's a similar discussion here: http://drupal.org/node/324591

Unfortunately the technique posted there doesn't work for me, since views doesn't seem to recognize my content-field.tpl.php file. But thats a different problem.

At least the description is available throw the $row variable in the views-view-field....tpl.php.

<?php
print $row->node_data_fieldname_fieldname_data;
?>

prints the following string for me:
a:1:{s:11:"description";s:21:"This is the image description";}

You can make a proper datastructure from that via the unserialize command:

<?php
$data
= unserialize($row->node_data_field_image_field_image_data);
?>

There should be a better way to do this though.

Title:ways to represent imagefield title, description or alt fields in views 2Represent title, description or alt fields in Views 2
Project:ImageField» FileField
Version:6.x-3.0-alpha4» 6.x-3.x-dev

Moving to FileField, since it provides the actual "field" type and Views integration (though we don't yet have any specific to FileField). Marked #369563: Description not available in Views as a Field as duplicate.

Version:6.x-3.x-dev» 6.x-3.0-beta1

updated to beta1 (imagefield/filefield)
thanks for the tips, I was searching around.. and for me, even in beta1, unserializing cck (2.1) fields doesn't work as expected in code

<?php
$data
= unserialize($row->node_data_field_image_field_image_data);
print
$row->node_data_field_image_field_image_data;
?>

I can only print the serialised array: a:3:{s:11:"description";s:0:"";s:3:"alt";s:0:"";s:5:"title";s:35:"xyz-phototitle";}
and after this:
<?php
$data
= unserialize($row->node_data_field_image_field_image_data);
print
$row->node_data_field_image_field_image_data['title'];
?>

I can print only the well known "a" as seen in:
http://drupal.org/node/363960 Data array not unserialized on the sanitize call
http://drupal.org/node/350297 Title and Alt fields display "a" when editing form

tried uninstalling/installing (beta1), same results
any ideas? It seems like http://drupal.org/node/397578 "Uncouple ImageField from FileField Custom Hooks" doen't solve this, or some how there are still existent problems with serialised cck fields..

jannalexx, after unserializing, you need to actually use the returned data, it doesn't affect the original variable:

<?php
$data
= unserialize($row->node_data_field_image_field_image_data);
print
$data['title'];
?>

Status:Active» Fixed

this is it.. and it's cool... it doesn't affect the original variable
nice1 ... You are right, thanks.. .. fixed

Status:Fixed» Active

Thanks for marking as fixed jannalexx; I'm going to leave this open as a feature request as it certainly would be handy if we could get at this data directly from Views with a special handler so such custom theming weren't necessary.

Version:6.x-3.0-beta1» 6.x-3.x-dev

I just installed 3.x-dev released today in expectation this would be fixed because of comments from January at #363960. This doesn't seem to be the case. I think I'm a bit confused by the scattered info on this issue. Are those not related?

Could I get some clarification on how to resolve this?
With the 6.x-3.x-dev and 6.x-3.0-beta2 versions should I be putting #8 in the module code somewhere or is that supposed to go in a custom views template?

you have to make a custom views template file for this -> views-view-fields--yourview.tpl.php in your theme's root directory.
you can place the code there, (e.g before endforeach), with css specific divs the code is:

<?php
$data
= unserialize($row->node_data_field_yourfilefield_field_yourfilefield_data);
print
"<div class='photo-title'>". $data['title'] . "</div>";
print
"<div class='photo-description'>". $data['description'] . "</div>";
?>

for further css tweaks:
if grid views style is the one for your gallery, you could also make an other one views-view-grid--yourview.tpl.php file
and replace

<?php
print $item;
?>
with

<?php
print "<div class='photo-image'>". $item . "</div>";
?>

then code css in your custom css theme file

an other point of... views
take a look at this Views Custom Field module http://drupal.org/project/views_customfield

Thanks jannalexx!

Status:Active» Fixed
StatusFileSize
new5.71 KB

This patch adds a custom Views handler for the FileField "data" column. Right now it's hard-coded to support description, alt, and title but could be extended to support other information that is stored in the data column (probably though some kind of hook).

To use, add the field "Content: [Name of field] - data". Then choose which information you want to pull out of the column. You can add the same field multiple times to pull out both the alt and title data (it's only selected once from the database).

Status:Fixed» Closed (fixed)

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

Wow, none of this is working for me, no matter what I try. #3 did give me a result but not until I manually created a 'vid' field for the View. #3 implies that the vid field is default to your view, but apparently not. Still it doesn't help me, because I need access to my image's alt text in the field template, not the 'fields' template.

Trying the same code within the field template produces blank output. print_r($fields) produces nothing in the template for the image field.

So, then I tried #5, #7, #8 ... and maybe someone can throw me a bone here. My field name is 'field_images' in nodes. In views, the field gets called 'field_images_fid'.

I've tried the following:

<?php
$data
= unserialize($row->node_data_field_images_field_images_data);
$data = unserialize($row->node_data_field_images_fid_field_images_fid_data);
$data = unserialize($row->node_data_field_image_field_image_data);
?>

None of those produce a damn thing. I passed $row to dpm() (devel.module) and there is NO node_data_field_image* of ANY kind.

Are you guys doing something special to make this happen? I'm using 6.x-3.0 for both imagefield/filefield. Is this only for filefield 6.x-3.x-dev?

When I tried to use the checkbox option in Views UI 'Content: field_images (data) it caused my View to spit out the same node over and over again. So I had to disable that.

If I can see the data from the fields template, I guess I could rewrite the templates to do all the image handling in the fields template instead, but what am I doing wrong here?

Okay, I figured out more.

Just for those reading the thread, my content nodes (as opposed to my term/section nodes) have an imagefield/filefield with 'Unlimited' setting. I call this field 'field_images' because there can be more than one (as opposed to 'The Highlander', where there can be ONLY one - but I digress.)

I have 3 Views that return the same layout of nodes, but they work slightly differently as to how they filter content.

I had these Views just right when the client said they wanted to be able to enter ALT text for each image.

I setup the imagefield/filefield to have ALT text entries.

In Views, I had Content: Images for my Imagefield and grouped multiple values, displaying the first image of the array. Later I found out I had to apply overlays for my Video nodes as opposed to my Story nodes, so I output the field as 'Path to file', so I could further theme the images conditionally in my Views field template for field_images_fid.

I added the field 'Content: Images (data)' and selected 'alt'. I thought I was home free.

But adding this item caused my View to spit out the same node over and over, which I _think_ is a bad JOIN clause, and if the node has 10 images, the View spits that node 10 times. I'm not positive, so don't quote me.

Anyway, I turned that option off. I tried the solutions in this thread but got nowhere fast.

I tried a new approach. I removed my Content: Images field (not the data one, the first one, field_images_fid). I added a Relationship to Content: Images (fid) to the View. This gives me a bunch of File fields in Fields section.

Under Fields, I added File: Path and re-added Content: Images (data).

NOW I have $row->node_data_field_images_field_images_data available to me in my Views templates.

This worked perfectly for two of my three Views. The third, it is still having problems with repeating node output - even with reduce duplicates activated, but at least now I see the serialized data field they're talking about. Cheers!

Ah, fixed it! The repeating image WAS in fact because I'm using a multi-field for my image field. In the Relationship field I added, there is a setting for 'Delta'. Setting it to '1' (meaning choose the first image and ignore the others) fixed the problemo. Yaaaaaay.

Version:6.x-3.x-dev» 6.x-3.1
Status:Closed (fixed)» Active

Did we reach a conlusion on this one? I would like to make a view of files for download, with the description as link title. This works with the ulpoad module, but not with file field.

Status:Active» Fixed

Yes, we added this functionality as described in #15:

To use, add the field "Content: [Name of field] - data". Then choose which information you want to pull out of the column. You can add the same field multiple times to pull out both the alt and title data (it's only selected once from the database).

I wasn't clear; I was thinking for a view for files (not nodes).

I wasn't clear; I was thinking for a view for files (not nodes).

This isn't possible for a listing of files, since the same file may be in use between multiple nodes, each having a different title, alt, description, etc. Basically these fields are node-level data, not file-level data. So if you want to have a listing of files, actually start with a node-based view, then make a relationship to the files table.

Ah! Thanks for clearing that up.

I tried that and get the following error message:
warning: Invalid argument supplied for foreach() in /var/www/vhosts/www.ar-mcguire.com/sites/all/themes/armcguire/views-view-fields--homepag... on line 8.

I only had just the above code in the template file for testing. I'm still trying to get used to php and templating for views. Could you embellish on your full code for the template?

What is the line $vid = $fields['vid']->content; about? I'm guessing that line 8 is bugging out because $fields['vid'] is empty. However, I'm not sure how to see what all of the available fields are for output :(

Status:Fixed» Closed (fixed)

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

Status:Closed (fixed)» Active

Apologies for re-opening an old issue but I suspect it is a good idea to keep my problem in this very relevant thread.

I have a multi-value Imagefield I want to output in a View with titles below. I have added my Imagefield to the View and I have also added the "Content: [Name of field] - data" field Quicksketch mentions in #15 and which I have set to output the Title. I then found that in order to get Views to sequence an image then the title, then the next image with it's title etc. etc. I needed to deselect the "Group multiple values" attribute on the Imagefield.

Unfortunately if there are any other fields output by the View they all get output for every image uploaded to the Imagefield ( which in my case is set to hold "unlimited" values ).

Is there any way to work around this ?

Thanks

Status:Active» Closed (fixed)

@El Bandito: Please open a support request. This feature issue is closed.