Posted by atiba on January 8, 2012 at 4:06pm
8 followers
Jump to:
| Project: | Colorbox |
| Version: | 7.x-1.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
On a field I have a thumbnail that when you click on it, opens an image gallery.
But now I also want to add a link that points to the same gallery.
Is there a way to do this by adding a php snippet in the .tpl.php file?
Or is there a way to accomplish this using Views?
Thanks!
Comments
#1
Subscribing
#2
Here is a solution for views:
Add a link to the header:
<a href="#" id="show-gallery">view gallery</a>Make a JQuery function like this:
(function ($) {Drupal.behaviors.OpenColorbox = {
attach: function(context, settings){
$('#show-gallery', context).click(function () {
$('.colorbox').colorbox({open:true});
})
}
}
}(jQuery));
If you want to a link for each item you can make a contextual filter on the image, add the file uri to the display and rewrite it for colorbox:
<a class="colorbox colorbox-inline" rel="gallery-all" href="[uri]">View gallery </a>#3
Ok I'm a bit of a noob when it comes to colorbox and Drupal coding - what header do you add that first code line to? In the html of the page with the gallery or the page that you want to link the gallery from?
I would love to link THIS gallery from THIS page's photos and a direct link at the bottom.
Thanks in advance!!
-Jess
#4
Jess, it's also possible to add markup text to a Views header.
Simply make a new 'View' and there you'll find the Header option in section Block/Page settings.
I think you need to add the line of code up there.
I will check it out myself, i'll let you know if it works.
- Cesar
#5
#6
Automatically closed -- issue fixed for 2 weeks with no activity.
#7
I'm changing the status here because the solution explanation is incomplete.
@mmncs: I fully understand where and how to implement the Views header code, however, can you please explain where and how the jQuery function is to be implemented?
Thank you for your time.
#8
Here is an explanation: http://drupal.org/node/171213
#9
Does your view has 'field Content: Image (field_image_cache)' and
header <a href="#" id="show-gallery">view gallery</a>in the same view ?When you click on 'view gallery', it adds js to open image in the colorbox.
but where is your gallery?
i set up my view with 'field Content: Image (field_image_cache)' exclude from display and add header.
Then i call the view in node template, but when i click on the text link, nothing happens.
<?php$view = views_get_view('view-name');
print $view->execute_display('default');
?>
can you share screenshot of your view, or explain little bit further? thank you.