Hi,

this is a follow-up to

Since 'Views Gallery' 6.x-1.3, there is a node-based view "view of all Galleries"; this is not very flexible, and it's pretty ugly since the raster view includes $links etc. I'd like to access the image node's fields and put them into tables (as it is possible with Image module's 'Image Gallery').

So the question is: How do we build a tabular or other field-based listing of galleries which includes at least one image from the views gallery?

Poieo suggested to use a Reverse Node Reference; I can not try this approach since this module requires MySQL 5.1, but Debian/Lenny ("stable") comes with MySQL 5.0.51a. So hopefully there are other ways to expose 'views gallery's fields to views.

Is this even possible, and has anyone solved this issue already?

Thanks & greetings, -asb

CommentFileSizeAuthor
#4 views-gallery-latest-galleries.txt12.44 KBasb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Poieo’s picture

I haven't tried this yet, but you may be able to use Corresponding Node Reference to create a two-way reference between the gallery node and the attached image nodes.

By having a reference from the gallery to the images, you should be able to pull the fields from the image nodes into your view.

Another option I used was to add an image field to your gallery content type to be used as the gallery thumbnail. Obviously, this is not necessarily ideal as you would probably rather pull an image from your gallery. But it is a simple solution for those looking for a quick fix.

asb’s picture

Thanks for the pointer, I was usually using the 'Node referrer' module (similar functionality), and played a bit with CNR. However, as far as I have seen, it doesn't play well together with 'Views Gallery' (maybe the Nodereference from URL widget?), but I'll continue trying.

zarudnyi’s picture

I override teaser view of gallery node type with contemlate module to show only
print $node->content['gallery_node_content_2']['#value'] (in my case).
That's all. Than I setting up my views for raw style node/teaser and filter for show only gallery node type.

asb’s picture

@aluminium: That's a workaround which might work for you, but I need something different - full-featured fields and non-node-based view styles.

@Poieo: Your idea was quite helpful for me, even without being able to use CNR: The mentioned NodeReferrer module offers a robust views integration and can be used to "bridge" between back-referencing nodes as well (simply add a required relationship to your view and set it to "distinct"). After having remembered this, it was a walk in the park to access some image from the 'Gallery' nodetype from within views. So the problem is solved at least partially. Two problems remain:

  1. The view "selects" the one image to display by itself; that's caused by the "distinct"operator, otherways I'd get a listing of all images of the referenced gallery. Which image is "selected" I can not control, and I'm not sure yet if it's consistently the first or the last image of the gallery (I've seen both - of course the question is by what criteria the 'gallery' view is sorted and what you consider to be the "first" or the "lst" image). However, this is a minor issue, but some control would be nice
  2. A bigger problem is that the one displayed image links to it's image node, not to the gallery ("link this field to it's node"). "Rewrite the output of this field" won't work since the image is the first column in the view ("Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.")

Maybe someone has an idea with those two issues?

In case that someone wants to try this out, I'm attaching a stripped-down export of my view (it's extremely trivial). Additional modules required: NodeReferrer. The relevant view is called "latest galleries (block)", it contains some fields you might wish to remove. The crucial elements are:

  • Use a field-based view style like 'table'
  • Filter down to content type 'gallery'
  • Define a required relationship on 'field_gallery'
  • Make the view 'distinct'
  • Add a field for the node title (= of the gallery) and make the image use the relationship

The rest is IMHO irrelevant. Well, this is far from perfect but a whole lot better than nothing ;)

Thanks for your ideas & greetings, -asb

Poieo’s picture

For #2, you should be able to add a field for 'path to node' (for the gallery node) before the image thumb and 'exclude it from display'. Then, you can use this URL to link the image to the gallery by re-writing the display. So you'd have something like this:

<a href="[token for path to node]">[token for image thumb]</a>
asb’s picture

@Poieo:

Thanks, this recipe does also work for the 'NodeReferrer' approach (#4) - it sounds a bit hackish, but it's cool!

Now just selecting a certain image as "gallery thumbnail" remains on the wishlist. Maybe I'll try to set a flag and filter the view down to the one flagged node. Hmm...

Greetings, -asb

asb’s picture

Title: How to expose fields to views? » How to build a field-based gallery of 'Views Gallery' galleries with views?

better (?) title...

Hunkah’s picture

OK I'm still sorta new to PHP coding, so I am a bit lost as to where you guys are adding this code. Can you be a sweetheart and dumb this down a little?

Thanks.

asb’s picture

So far this appreach has nothing to do with PHP, it's purely Views.

If some of the remaining issues are sorted out, I'll write a handbook page and/or provide an exported sample view. But it's really simple if you follow the instcructions from #4 and #5. However, maybe it makes sense to offer this as an contributed addition to the module if people are really having trouble to reproduce it. Any thoughts, Karen?

Hunkah’s picture

My issue isn't really with the code, if it works... it works.

My issue is where do I insert the information within views-gallery-latest-galleries.txt and where do I put [token for image thumb]. It's a little vague to me.

Thanks for your reply, I know us Newbies can be a little trying at times.

-Edit-
Wait, figured out the views-gallery-latest-galleries.txt, it goes into import views... yet I get this error:

* Field handler node_counter.daycount is not available.
* Field handler node_counter.totalcount is not available.
* Relationship handler node.nodereferer_referers is not available.
* Unable to import view.

asb’s picture

Something which provides the View with backlinks is required; I'm using 'NodeReferrer' (#4), 'Corresponding Node Reference' (#1) should work as well or even better, at least if you're running MySQL 5.1. However, you'll need these backlinks to build a relationship. The other field handlers can be discarded (#4).

If you don't know what I'm talking about, please wait until we've figured out #6 and the promised tutorial.

Hunkah’s picture

Yeah, I'm lost. I will wait. Thanks a lot for being so cool :)

Poieo’s picture

The problem with a field in the node content type that determines the gallery thumb is deselecting one before selecting another. If you want to change the current thumb, you have to make sure any previous thumbs are no longer selected... Seems like the simplest approach, but could be a UI nightmare down the road.

To muddy the waters a bit more, I'm using Draggable Views to determine the order of my image gallery. Do this, and you can simply allow the first image in the list to be the gallery thumb because you can control which image is first buy other means than the upload order.

But, this means the first (or last) image in the gallery must be the gallery thumb. I can see how many users would not want the first image to be the thumb for one reason or another.

Not sure that helps...

madlee’s picture

subscribe

asb’s picture

The approach from #4 doesn't work anymore in Views3, maybe because the "distinct" operator works differently. However, except a list of one record per gallery I get a list of all images in the gallery with Views3 :-(

holeepassion’s picture

I have created a new content type with image field. I have done the views to display the field as grid, as below:

http://earthsmate.com/downloadfreeimage

I have created a field with type in the content type. How do I group the images under each type and list them on the page with links to the gallery types, which then are then linked to all the images. I want the images to be thumbnail with links also.

thank you

cheers