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>*/
?>
精彩评论