Is there a way to count the number of images in an unlimited imagefield? I'd like to get that count, assign it to a variable available to views templates, and then use it to apply a custom class depending on what that count may be.

Any help getting the count would be appreciated, thanks!

Comments

RobW’s picture

Status: Active » Fixed

Solved with a minimum amount of php knowledge. Oh, learning.

Status: Fixed » Closed (fixed)

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

hampshire’s picture

Status: Closed (fixed) » Active

What was your solution?

hampshire’s picture

Status: Active » Closed (fixed)

Here is a link to a solution for this problem http://drupal.org/node/879652 using the computed fields module.

I used the following to store the value in the database and had to resave my current nodes.

Data Type: Int
Data Length: 10
[ ] Not NULL
[x] Sorable

Calling it into a custome template required

<?php print $node->field_computedname[0]['value']; ?>

Hope that helps.

giorgosk’s picture

$node_field[0]['value'] = count($node->field_images);

where field_images is the field to count the images of

RobW’s picture