Welcome Guest, Not a member yet? Register   Sign In
Get Vars directly to the view (Cleaning Controller)
#1

[eluser]Dewos[/eluser]
Hi all.
For clean my Controller, i want to pass all $_GET vars from URI controller to view directly.

From:

Code:
function index($vars, $id, $name, $abracadaba)
    {        
        $data['vars'] = $vars;
        $data['id'] = $id;
        $data['name'] = $name;
        $data['abracadaba'] = $abracadaba;
        $this->load->view('news/news_view', $data);
    }

To something like this:

Code:
function index($vars, $id, $name, $abracadaba)
    {        
        $this->load->vars($_GET); //for example
        $this->load->view('news/news_view', $data);
    }

In View

Code:
<html>
   <?=$vars?>  
   <?=$id?>  
   <?=$name?>
   <?=$abracadaba?>  
</html>

Any ideas? Smile

Ps. No, $this->input->get() is the same, i think. $this->uri->uri_string() maybe. But it loose the vars name, so it's a wrong way....
#2

[eluser]Dewos[/eluser]
Ops... wrong section. Sorry :|
#3

[eluser]xwero[/eluser]
You have to enable query string in the config and set the uri protocol to PATH_INFO. But the query string pairs will not be attached to the controller method. That is only for url segments.
#4

[eluser]Dewos[/eluser]
[quote author="xwero" date="1224244543"]You have to enable query string in the config and set the uri protocol to PATH_INFO. But the query string pairs will not be attached to the controller method. That is only for url segments.[/quote]

I know... But if vars are aviable in controller, why force to rebind all of them to use in view??. It should be set native by codeigniter controller... will be a real time-saving.

Update:
-func_get_args() useless :|
#5

[eluser]xwero[/eluser]
There is nothing that stops you from doing this
Code:
<html>
   <?=$_GET['vars']?>  
   <?=$_GET['id']?>  
   <?=$_GET['name']?>
   <?=$_GET['abracadaba']?>  
</html>
but i think you prefer the shorter variable name.

But i think you want to go back to the times where all REQUEST keys where reachable via a variable. This way of programming is insecure and error prone.
#6

[eluser]Dewos[/eluser]
[quote author="xwero" date="1224255167"]
There is nothing that stops you from doing this
But i think you want to go back to the times where all REQUEST keys where reachable via a variable. This way of programming is insecure and error prone.[/quote]

Ehmm... not and not Smile Only write less.
So, no realistic way... so this is the end, my only friend, the end.




Theme © iAndrew 2016 - Forum software by © MyBB