开发者

CakePHP: Display view in Lightbox?

开发者 https://www.devze.com 2023-03-16 20:00 出处:网络
I am looking for a way to display a view in a lightbox or thickbox in Cakephp. 开发者_开发技巧Is there a way how I could do this?

I am looking for a way to display a view in a lightbox or thickbox in Cakephp.

开发者_开发技巧Is there a way how I could do this?

Thanks in advance


Something like this should do it ~

You'll want to create a new layout, that only includes the CSS and formatting required for the lightbox view.

function show_lightbox($id) {
    $this->layout = 'lightbox';
    $this->set('page_content', $this->Model->read(null, $id));
}

and create links to this content, as you normally would in another view with the appropriate lightbox rel or class, not forgetting to include the JS/CSS for the lightbox.

<?php echo $this->Html->link('View in lightbox', 
                               array('action'=>'show_lightbox', 1),     
                               array('class'=>'lightbox-link', 'rel'=>'lightbox')
                             );  
/* <a href="controller/show_lightbox/1" 
    class="lightbox-link" rel="lightbox">View in lightbox</a>*/
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消