I would like to display a "view gallery" link in my view which triggers a colorbox popup.
As far as I know there's no way to do that for the moment.

If you use the colorbox image formatter, the only available option is to use all the images with an image style. That's fine if you want to use thumbnails. But there's no option to use a simple link to trigger the popup gallery.

I also tried the views colorbox trigger, with that I can choose any field to trigger the colorbox which is fine, but the if I put my image field with multiple values in the same row, I get a popup with all the images on the same page, and if I choose to let one image/row and exclude them from display I have a duplicate entry of the trigger field, which is normal in views.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jerome F’s picture

I tried to make a custom formatter, but didn't manage to get a single entry of the view gallery link nor to make a gallery in the popup, with the following I just get one image for each link which is useless.

/* 
 * colorbox gallery triggered by a "view gallery" link with a large image style
 */

// Set this value to the desire style.
$style = "large";

$output = '';
foreach ($variables['#items'] as $item) {
  if ($item) {
    $output .= '<a href="'.image_style_url($style, $item['uri']).'" title="'.$item['title'].'" alt="'.$item['alt'].'" class="colorbox" rel="gallery-'.$item['fid'].'-field_photos">view gallery</a>';
  }
}
return $output;

I also tried to rewrite an image field in views (see attached screenshot) that nearly worked, the popup displays a gallery, but I still get duplicate entries for the view gallery link.

So as a workaround I'm going to try to embed a views slideshow in the colorbox, and I guess I will have to use views field view module to get this done.

Jerome F’s picture

although it might look like and overkill it works:
So you need views slideshow + colorbox + views field view

1) create a view (A) with the slideshow and a contextual filter based on the nid
2) create the view (B) where you need a "view gallery link" + exclude from display
3) create a nid field + exclude from display
4) embed view A in view B with views field view (C) and add the nid as contextual filter + exclude from display
5) create an image field (D) with rewrite active (type: view gallery) and strip HTML tags + exclude from display
6) create a colorbox triggered by D with C (replacement pattern is [view]) in the popup

you're done

Yet it would be nice if someone can share an easier step by step or if a new feature would be added to colorbox.
So I leave it active but down to minor as I found a workaround.

Rhodungeon’s picture

Priority: Normal » Minor

Jerome could you post some images? I'm stuck at point number 5 -- the second 4) --

Thanks!

Jerome F’s picture

FileSize
139.24 KB
121.77 KB

Oh sorry for the typo (fixed it). Here are the attached screens

Rhodungeon’s picture

Thanks Jerome!! Now it's more clear!

Rhodungeon’s picture

Has someone already tried to use a view-slideshow as a trigger for colorbox?

atiba’s picture

Hi Rhodungeon and Jerome F.
I tried to follow Jerome's steps but i'm stuck at the first 4 steps.
I'm aware that this is an old post, but the description matches actually for what I want.
Can you please provide some more screenshots?

Thank you.

mmncs’s picture

I'm having the same problem, but the solution presented by Jerome seems to be way overhead for such a simple task. Is this really the only way to get a text link in a view which links to Colorbox?

Does anybody know of any other modules which has the ability to show a text link instead of an image or any easier solution for this issue?

Thanks, Chris

mmncs’s picture

I made another solution which I have posted here:

http://drupal.org/node/1397852#comment-5505600

lsolesen’s picture

Status: Active » Fixed

Marking as fixed. Also see the solution here: #1397852: Open existing Colorbox gallery with a link

Status: Fixed » Closed (fixed)

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

bellagio’s picture

Jerome F:

I followed your instructions, but my link is duplicated. (if my images are 3, i get 3 links of "veiw gallery link")

i don't understand this part 2).
2) create the view (B) where you need a "view gallery link" + exclude from display
Is this the summary of view (B) or do i add a field in this step 2?

i did 1,3,4,5,6 but no luck.

bellagio’s picture

oh, figure it out.
image field: check "group multiple values". to show only one "view gallery" link.

TravisJohnston’s picture

I was able to make this happen easily in D6 but I too am running into the same issue as you with D7. Though using Views Slideshow is not the best option if you have multiple galleries on a page. It tends to get confused and shows you all the images in the slide show, regardless on which "view gallery" link you would click on. I can come close to creating it like I used to in D6, but each slide has all the images on them which obviously isn't right.