How to render a popup in YII controller action?
i want to open new window for some actions...please help me with this...
(i want this when i call a action not when i click a link)
Ex. when i go to view action in invoice controller it should open in a new window...
is there any way to render a popup...
This is my action which generate pdf using MPDF... It should open in a new window.
public function actionReport() {
$date=Yii::app()->Date->onlyNow();
$name="ITEM Reprt(".$date.")";
$mPDF1 = Yii::app()->ePdf->mpdf('L', 'A5');
$mPDF1->WriteHTML($this->renderPartial('test', array(), true));
$mPDF1->Output($name,'I');
}
THANKS...!
Why popups? Simply create link with target="_blank", browser will open new window or new tab - per user preferences.
Print PDF!
You can even embed pdf or use pdfobject etc.
Related
I am working in cakephp application.
Here all the calls happening with Ajax. So user wants to keep one button or link, when user click on the link it will show one with contains help info of that page. I'm able load div with right content. But dynamically I'm not able to display one link (Show Help) on the page dynamically.
The reason for the "Show Help" link dynamic is based on which page loads I have to pass value to JavaScript function.
Plz help me how to add this link in $content_for_layout so that it will display dynamically in all the pages.
Step1: This is the code to create helper. Put the following code in app/views/helpers/LinkHelper.php
class LinkHelper extends AppHelper {
var $helpers = array('Html');
function showHelp() {
$url = '';//create your url dynamically here
$title = 'Show Help';
return $this->Html->link($title, $url, array('class' => 'help'));
}
}
Step2: Load the Link Helper in layout
$HelpLink = $this->Helpers->load('Link');
Step3: Call showHelp method of LinkHelper where Show Help link to be shown.
echo $HelpLink->showHelp();
I am using javascript for showing a link in php Codeigniter. But I want
toredirect to a new php page with new tab when click the link . my
controller is loginController and my function is downloadPdf().
how to do this.
my java script is
contentRow += '<div>click here</div>';
and this javascript code will append to div in php code
my need is when i click this link ,i have to pass a parameter to the redirecting page for some process.but with codeignitor
use the HTML a target='_blank' attribute to link.
I know that there are at least two other similar questions, but they do not help me.
I have textarea with tinymce where user writes his text. Then there is a button "PDF" that should create pdf and open it in new tab. The content of pdf is the content in tinymce.
When user click on button, the form is submitted to index.php action. Then index.php gathers information from $_POST variable and creates pdf.
I cannot get it to open in new tab as a normal link.
I tried it in different ways.
1) I can open PDF in the same tab, but this is not what I need. This line opens my pdf on the same tab:
$dompdf->stream('document.pdf',array('Attachment'=>0));
2) I can open it in new window, but then browser warns that this is pop-up. Client doesn't want it. Also another problem with this is that pdf is stored on server. I do not want it (pop-up warning is more important). Here is my code:
$output = $dompdf->output();
file_put_contents('document.pdf', $output); //save pdf on server
//opens generated pdf in new window, but this creates warning for popup
echo '<script type="text/javascript" language="javascript">
window.open("http://modeles-de-lettres.org/test/saved_pdf.pdf", "_blank");
</script>';
I have read those:
1) Open PDF in a new tab using dompdf
This suggests: "As far as opening in a new tab. That depends on how you are generating the PDF. But the simplest way it to provide a link with a target attribute." I think this means that I have
<a href="my.pdf" target="blank"
or
<a href="my.php" target="blank"
But this does not work for me, because I should POST my form to get data from pdf.
2) generate the pdf on newtab in dompdf
This is something that I have implemented before (I did it without sessions), but it creats warning about popups.
You can simply do the following:
<button type="submit" formtarget="_blank">Submit to a new window</button>
formtarget="_blank" attribute will open new tab.
Hope it will help you!
The problem is the order in which you're doing things. You should be opening the new window from a user event, like clicking a button. If a script on a page load event tries to open a window, the browser will presume it's an unwanted popup, since the user hasn't done anything besides navigating to the page.
What could work for you, is adding a target="somewhere_new" attribute to your form tag. This way, the browser would open a new tab since there's no frame/iframe with a name="somewhere_new" attribute, and you wouldn't have to do anything special in the server side, just process the data as you did before using $dompdf->stream('document.pdf',array('Attachment'=>0)); at the end
I would like to create popup contact form with validation like i did here http://89.212.111.174/delovtujini.si and click “VPIS V BAZO”.
You will get popup where you can fill contact form. How can i do this with CI? Here on this example i do everything in the same html page. In CI i try to create new controller for contat form but i dno’t know how to open the window. I also try to use http://fancyapps.com/fancybox/ I try. but none solution works.
Can someone explain me how to do? Maybe is better to use https://github.com/EllisLab/CodeIgniter/wiki/Ajax-Framework-For-CodeIgniter
Thx
there are 3 ways to trackle your issue.
1) Use custom inline lightbox like what is done on
http://89.212.111.174/delovtujini.si
First post the form back to the same page like below:
public function sign_up()
{
// Setup form validation
$this->form_validation->set_rules(array(
//...do stuff...
));
// Run form validation
if ($this->form_validation->run())
{
//...do stuff...
redirect('');
}
// Load view
$this->load->view('my_form');
}
In the view when you detect a POST you must have javascript
to "open" the lightbox on page load since it won't be display by default (i.e. when you load the page normally the lightbox is "closed" and it is "opened" only when the button is clicked.)
2) Use a iframe lightbox
create the form on a separate CI controller/view and display in within an iframe when the button is clicked.
when the form is submitted you can then call javascript to close the lightbox.
3) Use ajax
both inline and iframe lightbox can work with an ajax form
the idea the same as using an iframe lightbox. Once the form is submitted via ajax, use javascript to close the lightbox.
I need your quick help.
In my web site I have a list of clients with links to their user details.
I used
window.open();return false;
and this opens each profile in new window.
now in the new opening window I have link, which I want to open in another new window/
I tried
window.opener.open();return false;
but it opened in this same window.
How can it be opened in another new window(FF,explorer)??.
I want also to use the above code with Ajax, in my search page.
The problem is, that it also not opening the new window because the link located in the Ajax. how can i open links from Ajax in new window??
Any ideas?
Thanks!!!
Well you can access window.parent from your window object and call a function that will open another window
Use Window.open() in the opened window.
So you have : (1) Page with a link -> (2) opens a popup with a link -> (3) opens another popup
Every link which has to open a popup will call the javascript function window.open. As #Sushil pointed out, if the new window has to look like a regular popup, set width and height to it.
If you want to implement the popups using AJax, use jQuery. Here is a very good example for a simple popup implementation.
Providing height and width to open. this will make sure that new window always open as popup.
window.open(url, 'name', "height=500,width=700"); return false;