Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

start a gallery (LightBox) by klicking an image on a 'normal' silverstripe page


Go to End


5 Posts   3262 Views

Avatar
joninjas

Community Member, 32 Posts

9 January 2010 at 3:58am

Hi,

I'd also like to start (for example) LightBox directly from a link on a picture somewhere on a silverstripe website (not just from the supported gallery page).

Could someone please give me a hint?

Cheers
Jonas

Avatar
pinkp

Community Member, 182 Posts

19 January 2010 at 5:19am

Edited: 19/01/2010 5:34am

I am also trying this, so far I've been able to get it to work by using the following lines in my new 'MyPage.ss', whilst having the image_gallery mod installed:

<script type="text/javascript" src="jsparty/jquery/jquery.js"></script>
<script type="text/javascript" src="image_gallery/gallery_ui/lightbox/javascript/jquery.lightbox-0.5.js"</script>
<script type="text/javascript" src="image_gallery/gallery_ui/lightbox/javascript/lightbox_init.js"></script>

<link rel="stylesheet" type="text/css" href="image_gallery/gallery_ui/lightbox/css/jquery.lightbox-0.5.css" />
<link rel="stylesheet" type="text/css" href="image_gallery/css/ImageGallery.css" />

And this in my .ss

  <% if Photo %>
<a rel="lightbox" class="lightbox" title="$Title"  href="$Photo.URL"><% control Photo.SetWidth(130) %><img src="$URL"<% end_control %>alt="$Title"/><% end_if %>

This is presuming you have the $Photo and $Title fields in your PHP and the above is to create a custom alt whilst also setting the Photo width.

But it seems to have an issue and is showing multiple images in the count even when there is only 1... but this may be my .ss file not sure yet.

Avatar
web2works

Community Member, 50 Posts

11 June 2010 at 7:48am

If only it used a more advanced template language this could be done in one line. Such a good framework let down by the template.

Avatar
web2works

Community Member, 50 Posts

11 June 2010 at 9:24am

Yeah I am giving it a go. I have been used to working with Smarty I think I am just finding such a difference but I love the framework and whole MVC logic.

The first thing I came across was using the 2 IF statements that I couldnt do in the template (maybe its not supposed to go in the template) but I was trying to wrap a simple IF statement round a subnav where in smarty I would of done:
I ended up with this:
<% if LinkingMode == current %> mainNav-Sub_Always<% end_if %><% if LinkingMode == section %> mainNav-Sub_Always<% end_if %>
{if $LinkingMode eq 'current' || $LinkingMode == 'section'}

I have bought the book so when that arrives will hopefully that gets me going.

Avatar
_Vince

Community Member, 165 Posts

22 June 2010 at 8:10am

I had a similar question some time ago. I wanted to open a lightbox by clicking on a photo in the actual page content.

It was suggested, at the time, that I do a string replace in the PHP. Create a function called Content() and then do a bit of string manipulation, putting the link around the "<img>" tag.

That's always possible, too.