Welcome Guest, Not a member yet? Register   Sign In
Refreshing the current site
#1

[eluser]grobald[/eluser]
Hello

Is there a function for refreshing the same view/page/site?

Code:
if(!$this->auth->is_logged_in()) {
        $this->session->set_userdata('message', $this->lang->line('error_not_logged_in'));
            //$this->refresh(); ?????*/

            //exit;
        }
i tried the search but i didn't find anything
thx for help
#2

[eluser]xwero[/eluser]
In the url helper there is the redirect function which is what you need
#3

[eluser]grobald[/eluser]
thx for the fast reply. i know this function, but what if i dont know where to redirect? for instance i have a site which is called like <?=baseurl?>user/antonio and i just want to reload this page. At the time i want to reload the page i do not have antonio set.

thx
#4

[eluser]xwero[/eluser]
you can do
Code:
redirect(substr($this->uri->uri_string(),1));
#5

[eluser]grobald[/eluser]
i found a solution:
Code:
function add_rating($redirect)
    {
        // Check for auth
        if(!$this->auth->is_logged_in()) {
            $this->session->set_userdata('message', $this->lang->line('error_not_logged_in'));
            redirect('/user/'.substr($redirect, 0));
        }
i had to pass the actual username to the add function and than add to the redirect url

thx for help
#6

[eluser]grobald[/eluser]
But there is still a problem with refreshing the page. Its weird that there is no function which you can use just for refreshing the same page. For instance i have a error messag with a clos link. After clicking on that link it should just reload the same page without passing the current position in the application.
Code:
function reset_message()
    {
        $this->session->unset_userdata('message');
        redirect(to the current page...);
    }
Or do you have some clues for that.?
#7

[eluser]xwero[/eluser]
uri_string gives you the the page that is going the be loaded so if you don't go to some other controller for the authentication process you can use that function.
If you do the authentication in another controller and you want to go back to the page you filled in the authentication form you need to fetch the page before sending the post data to the authentication controller.
The 1.7 url helper has a uri_string function you can use to populate a hidden field named current_page for example. But you can add the function yourself.
Code:
function uri_string()
    {
        $CI =& get_instance();
        return $CI->uri->uri_string();
    }
#8

[eluser]Dready[/eluser]
Hello

Perhaps :
Code:
redirect(__CLASS__.'/'.__FUNCTION__);

? (valid for any PHP >= 4.3
#9

[eluser]Sarre[/eluser]
Code:
function add_rating()
    {
        // Check for auth
        if(!$this->auth->is_logged_in()) {
            $this->session->set_userdata('message', $this->lang->line('error_not_logged_in'));
            $this->add_rating();
        }
?




Theme © iAndrew 2016 - Forum software by © MyBB