Open a view with Codeigniter on a different page

Asked

Viewed 1,420 times

2

I would like to open a view in another browser tab using Codeigniter, someone knows how to do?

In the tag "a href" use the property target=_blank to get.

How do I get this property on $this->load->view('nome_view')?

2 answers

3

The way to do this is how you’ve done it, using target=_blank on the link.

If you look at documentation the only overload you’ll find of the method view() is one to pass a data object. There is nothing to be done at the Controller level to open in a new tab or popup. If you provide more details of why you needed it, I can give you some other suggestion, probably with Ajax and Javascript.

Link:

<a href="index.php/clientes/inserir" target="_blank">Inserir</a>

Controller:

class Clientes extends CI_Controller {
   public function inserir() {
      $this->load->view("inserir");
   }
 }
  • Murilo is right. The php code runs on the server. Any interaction with the browser, such as opening certain content in a new tab, is usually done using javascript, which runs in the client.

  • Thanks Murilo for the support, what I’m doing is creating a report that will be shown in a pdf, and when I run the code to generate the pdf report it ends up clicking in the same tab in the browser and the user ends up leaving the system, And what I was looking for is to generate this pdf in another tab. But eventually I found a solution, which solved for now my need.

0

is possible as follows: example:

     $atts=array(
      'window_name'=>'_blank'
     );               

     echo anchor_popup('SeuControler/SuaFuncaoQueEncaminhaAPaginaView', 'Pagina de Impressão',array('class'=>'btn btn-primary'), $atts );

     ? >

Browser other questions tagged

You are not signed in. Login or sign up in order to post.