Welcome Guest, Not a member yet? Register   Sign In
[resolved] Using flashdata on the same page
#1

[eluser]FinalFrag[/eluser]
Let me start of with a snippet of my view:

Code:
<? if ($this->session->flashdata('message') != '') { ?>
    <div id="feedback" class="&lt;?=$this->session->flashdata('class')?&gt;">
        <p>&lt;?=$this->session->flashdata('message')?&gt;</p>
    </div>
&lt;? } ?&gt;

What that does is pretty easy. When the 'message' is set in flashdata, it creates a div to show that message.

What I need is this message to show on the first page the visitor visits. So I've made my home controller (the first one the visitor sees when getting to my site). It looks like this:

Code:
class Home extends Controller {
    function index() {
        // Generate feedback
        $this->session->set_flashdata('class', 'notice');
        $this->session->set_flashdata('message', 'This website is a <abbr title="Work In Progress">WIP</abbr>.');
        
        redirect('home/showme', 'location');
    }
    
    function showme() {
        $data['header_pagetitle'] = 'Home';
        $data['header_menu'] = ul(array(anchor('', 'Home', array('id' => 'current-tab')), anchor('about', 'About me'), anchor('portfolio', 'Portfolio'), anchor('contact', 'Contact'), anchor('agenda', '_Agenda'), anchor('photos', '_Photos')));
        $data['header_title'] = 'Home';
        //$data['header_javascript'] = '';
        
        $this->load->view('home', $data);
    }
}

What this SHOULD do:
- generate the flashdata and save it in the session
- redirect to mysite.com/home/show
- create all the needed variables in the $data array
- show the home view

It does all that but there's just 1 problem. It shows the home view without a stylesheet Confused
Although, when I take a look at the source of that page it has included my style.css file.

When I try to change the redirect line to: redirect('otherpage', 'location'); it works. So I'm assuming this happens because I redirect to a function in the same controller. Could this be true?




Now you might say: 'just use $this->showme'. I could, but then the flashdata would not be shown on the view (because flashdata only shows on the next request).

Anyone got something on this issue?


Messages In This Thread
[resolved] Using flashdata on the same page - by El Forum - 09-05-2008, 11:10 AM
[resolved] Using flashdata on the same page - by El Forum - 09-05-2008, 01:02 PM
[resolved] Using flashdata on the same page - by El Forum - 09-05-2008, 02:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB