GSTAR
(Omzy83)
December 23, 2010, 5:12pm
1
Controller action:
public function actionPhotos($view)
{
$model=Photo::model()->find('name=:name', array(':name'=>$view));
$user=$model->user;
$this->render('photos', array(
'user'=>$user,
'model'=>$model,
));
}
photos.php:
<h1>Photo</h1>
<div class="photo">
<?php echo $this->renderPartial('_photo', array('user'=>$user, 'model'=>$model), true); ?>
</div>
In my gallery the URL for the images is:
/mysite/gallery/photos/view/4086021
When clicking on this link it brings up the image in the lightbox, but within a layout. I want to set it up so that when viewing images in the lightbox it only loads the partial view "_photo". But when directly accessing the URL it should load the image within the layout as normal.
gusnips
(Gustavo)
December 23, 2010, 5:18pm
2
use some kind of get parameter dinamically created using js when lightbox call the image, something like "?nolay=true"
and then use it to define if the image will or not use a layout
GSTAR
(Omzy83)
December 23, 2010, 5:36pm
3
How can I do that? Does FancyBox have any options to pass a GET variable?
gusnips
(Gustavo)
December 23, 2010, 5:41pm
4
$(document).ready(function(){
$('div.my-images img').each(function(){
$(this).attr('src',$(this).attr('src')+"?nolay=true");
});
$('div.my-images').fancybox(options);///or whatever
});
this way it will work even if js is disable, exactly like you want
GSTAR
(Omzy83)
December 23, 2010, 5:44pm
5
I see, but that will append the variable to my URL - will not look nice! Can we send the variable in the background, onclick?
gusnips
(Gustavo)
December 23, 2010, 5:46pm
6
you sure can, but that will require a little hack in the plugin’s function
anyway, it wont appear in the url because it will only be used if lightbox is active, this way loading it in a layer instead of realoding the page
if JS is disabled the image’s url will remain the same
GSTAR
(Omzy83)
December 23, 2010, 6:05pm
7
I have no idea how to do this. The problem is that it is a lightbox gallery, so I can’t check for clicks on the anchor link either.
There must be another solution.
GSTAR
(Omzy83)
December 23, 2010, 6:38pm
8
OK sorry my mistake, I was applying your code to A elements rather than IMG elements.
So now the image URLs have the GET parameter, but how do I check for this in my code? The image URL is just pointing to the actual file on the server, eg:
<div class="photo">
<a rel="gallery" href="/mysite/gallery/photos/view/4086021">
<img src="/mysite/images/member/4698568/4086021_thumb.jpg?nolay=true" alt=""></a>
</div>
gusnips
(Gustavo)
December 23, 2010, 6:45pm
9
My bad also
It should be added to the link, a tag, itself, but it wont mess up your url’s
If JS is disabled it wont add any parameter, since the parameter is created via javascript
If JS is enabled, then lightbox will render its image therefore url’s wont be displayed to the user
GSTAR
(Omzy83)
December 23, 2010, 6:48pm
10
It does append it to the URL:
/mysite/gallery/photos/view/4086021?nolay=true
gusnips
(Gustavo)
December 23, 2010, 6:52pm
11
not the browser’s url
only if some1 look at the source code , or if you put mouseover it will show in left bottom corner in firefox.
anyway, i cant think in any other solution for your problem …