The image_count field handler at views2inc/node_gallery_views_handler_image_count.inc works fine when the field is added on a gallery, but not when it's added on an image with a relationship to the parent gallery defined. Original post follows:

Hi,

I am currently using "view cover image" in my gallery node teaser mode, and am wondering if there is a way to modify the display so that :

1) the cover image will be linked to gallery node, not the gallery image node;
2) show gallery image count

I tried something as shown in attachment without success:
1) have no idea how to link cover image to gallery node
2) in my setup, the image count is always 0, and the query is obvious incorrect:

SELECT COUNT(*) FROM node_gallery_images ng JOIN node n on ng.nid = n.nid WHERE n.status = 1 AND ng.gid = node.nid

Any ideas how to accomplish this?

Thanks.

Comments

foredoc’s picture

Just figured out how to link cover image to gallery node by following the example:

views: node_gallery_gallery_summaries
display: galleries cover grid

Thanks.

foredoc’s picture

Tried different relationships ( for field Node Gallery: Gallery: Image Count ):

1) gallery cover image
2) parent gallery
3) no relationship

None of them get the correct number of images in the gallery, because all of them are based on the same query:

SELECT COUNT(*) FROM node_gallery_images ng JOIN node n on ng.nid = n.nid WHERE n.status = 1 AND ng.gid = node.nid

I thought relationship: "parent gallery" will do the job. No idea why it fails.

justintime’s picture

Title: How to modify "view cover image" display to: 1) link cover image to gallery; 2) show gallery image count ? » image count views field returns 0 when used from an image node with a relationship to the parent gallery
Category: support » bug

Updating title and marking as a bug report

justintime’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

Sorry, have to run and don't have time to test, but can you give this a shot?

justintime’s picture

Good thing you waited, that patch didn't work :)

I had time to actually test this one, and it works for me in both cases, plus it uses our cache instead of hitting the DB so it should perform better.

foredoc’s picture

Thanks, I applied this patch, and it pulls the correct number out. However, for some reason the SUFFIX disappears.

In views setup, I have suffix: " Photos". So it should looks like:

50 photos

After applying, it looks like:

50

Any ideas?

Thanks.

justintime’s picture

Status: Needs review » Needs work

Yeah, that's a bug in the patch. I'll have to refactor that a bit.

justintime’s picture

Status: Needs work » Needs review
StatusFileSize
new3.41 KB

give this one a shot, it should work for you.

foredoc’s picture

Thanks. Problem solved.

justintime’s picture

Status: Needs review » Fixed

Thanks for reporting and testing! Merged into 3.x-dev.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

updating summary for specific bug