Yii Framework Forum: renderPartial for lightbox - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

renderPartial for lightbox Rate Topic: -----

#1 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,060
  • Joined: 30-October 09

Posted 23 December 2010 - 12:12 PM

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.
0

#2 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 23 December 2010 - 12:18 PM

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
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#3 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,060
  • Joined: 30-October 09

Posted 23 December 2010 - 12:36 PM

How can I do that? Does FancyBox have any options to pass a GET variable?
0

#4 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 23 December 2010 - 12:41 PM

$(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
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#5 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,060
  • Joined: 30-October 09

Posted 23 December 2010 - 12:44 PM

I see, but that will append the variable to my URL - will not look nice! Can we send the variable in the background, onclick?
0

#6 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 23 December 2010 - 12:46 PM

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
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#7 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,060
  • Joined: 30-October 09

Posted 23 December 2010 - 01:05 PM

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.
0

#8 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,060
  • Joined: 30-October 09

Posted 23 December 2010 - 01:38 PM

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>

0

#9 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 23 December 2010 - 01:45 PM

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
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#10 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,060
  • Joined: 30-October 09

Posted 23 December 2010 - 01:48 PM

It does append it to the URL:

/mysite/gallery/photos/view/4086021?nolay=true
0

#11 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 23 December 2010 - 01:52 PM

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 ...
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users