10448 Posts in 2223 Topics by 1719 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2157 Views |
-
start a gallery (LightBox) by klicking an image on a 'normal' silverstripe page

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 -
Re: start a gallery (LightBox) by klicking an image on a 'normal' silverstripe page

19 January 2010 at 5:19am Last edited: 19 January 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.
-
Re: start a gallery (LightBox) by klicking an image on a 'normal' silverstripe page

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.
-
Re: start a gallery (LightBox) by klicking an image on a 'normal' silverstripe page

11 June 2010 at 9:11am
You'd want to have something like this in your Page_Controller:
public function init() {
parent::init();
Requirements::javascript('jsparty/jquery/jquery.js');
Requirements::javascript('image_gallery/gallery_ui/lightbox/javascript/jquery.lightbox-0.5.js');
Requirements::javascript('image_gallery/gallery_ui/lightbox/javascript/lightbox_init.js');
Requirements::css('image_gallery/gallery_ui/lightbox/css/jquery.lightbox-0.5.css');
Requirements::css('image_gallery/gallery_ui/lightbox/css/ImageGallery.css');
}Then in your .ss:
<% if Photo %>
<a rel="lightbox" class="lightbox" title="$Title" href="$Photo.URL">$Photo.SetWidth(130)</a>
<% end_if %>$Photo.SetWidth will output the whole <img> tag for you.
That should work. Generally I find it best to put requirements into the PHP, but if you prefer to do so within the template, have a look at the require tag, (see here: http://doc.silverstripe.org/requirements).
Also, @web2works, the template language is kept deliberately simplistic, in order to ensure that logic is handled by the Controller as much as possible. It may take a change of thinking vs. some other frameworks but we find it very effective, I hope you will too.
Cheers,
- Luke -
Re: start a gallery (LightBox) by klicking an image on a 'normal' silverstripe page

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.
-
Re: start a gallery (LightBox) by klicking an image on a 'normal' silverstripe page

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.
| 2157 Views | ||
|
Page:
1
|
Go to Top |





