Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to Pop-Up a window with an action in CakePHP

Tags:

cakephp

Well I am trying to convert an image into an button on a page of application done in CakePHP.This is the first issue.I can not use the image as a button.After that I want a Javascript which pops up a window of the action in it...!!!How can I do this thing...can any1 tell me how to do that..!!!

like image 243
Nishant Shrivastava Avatar asked Aug 29 '09 11:08

Nishant Shrivastava


3 Answers

For the image button I suggest you use this code:

<input type="image" src="<?php echo $html->image('image.gif'); ?> name="image" width="60" height="60">

To open the window with action inside, something like that:

<?php echo $html->link('yourlinkdescription', '#', array('onclick'=>"var openWin = window.open('".$html->url(array('action'=>'youraction')."', '_blank', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=500,height=500');  return false;")); ?>
like image 183
riotera Avatar answered Oct 11 '22 20:10

riotera


Actually, the undocumented technique for using an image as a button is this:

<?php echo $form->end('image.gif'); ?>

Instead of the typical $form->end parameter which is the text for the button:

<?php echo $form->end('Submit'); ?>

Assuming image.gif is located at /app/webroot/img/image.gif, this will automatically create the button with that image.

like image 22
adam Avatar answered Oct 11 '22 19:10

adam


For cakephp 2.7 use

 <?php echo $this->Html->link(__('<button type="button" class="btn btn-icon command-delete"><span class="md md-photo-library"></span></button>'), "javascript:void(0)", array("escape" => false,"onclick"=>"window.open('".$this->Html->url(array('controller' => 'galleries', 'action' => 'index', $page['Page']['id']))."','photo','height=650,width=1000,scrollbars=yes,resizable=yes')")); ?>

or simply

 <?php echo $this->Html->link(__('Photos'), "javascript:void(0)", array("onclick"=>"window.open('".$this->Html->url(array('controller' => 'galleries', 'action' => 'index', $page['Page']['id']))."','photo','height=650,width=1000')")); ?>
like image 30
RN Kushwaha Avatar answered Oct 11 '22 21:10

RN Kushwaha