Welcome Guest, Not a member yet? Register   Sign In
Displaying a message on the page after certain action
#11

[eluser]cinewbie81[/eluser]
Hi,

I download the updated session library from

http://bleakview.orgfree.com/dl/Version_...ssion.phps

when i load the library from my controller it generate me the error :

The session timeout configuration is invalid.

I've never use session b4, and i dont really know how it works ... did I miss something ?
#12

[eluser]Derek Allard[/eluser]
I can't help you with obsession, but I actually wrote a whole blog post about the new CI session library, including how to get it, and what you need to do to make it work.

http://www.derekallard.com/blog/post/enh...n-library/
#13

[eluser]cinewbie81[/eluser]
Hi Derek, thoughts obsession is the same with the session library !!
I'll have a look at your blog post .. Will keep u updated ..
and thanks for that !!
#14

[eluser]cinewbie81[/eluser]
Ok this is what i did :

1) replace the session.php file - get the modified one from http://dev.ellislab.com/svn/CodeIgniter/...ession.php

2) in my controller file, i load the session library

3) After certain action performed, i has something like:
Code:
$this->session->set_flashdata('msg', 'Record Added Successfully');

4) In my view file i have something like :

Code:
<div id="actionMessage">
  &lt;?php echo $this->session->flashdata('msg'); ?&gt;
</div>

There's no error... but then it didn't generate me any flash data as well ?
What did I missed ??

Do I need to set anything in config file ?
#15

[eluser]Derek Allard[/eluser]
if you're settin git and then displaying it in the same load, the flash var doesn't really consider it a new page.

try
Code:
&lt;?php

class Test extends Controller {

    function Test ()
    {
        parent::Controller();    
        $this->load->library('session');
        $this->load->helper('url');
    }
    
    function index()
    {
        $this->session->set_flashdata('msg', 'Record Added Successfully');
        echo 'flash data set.<br>';
        echo anchor('test/page_two', 'next page');
    }
    
    
    function page_two()
    {
        echo '<div id="actionMessage">';
        echo 'the message is ' . $this->session->flashdata('msg');
        echo '</div>';
    }
}
?&gt;
#16

[eluser]Lone[/eluser]
Ill just confirm that we just replaced the Sessions Class file to a 1.5.4 install with no problemos at all.


cinewbie81: I think you perception of how flashdata works might be wrong. As far as I can tell it is best used for a page redirect - here is a quick sample:

1. You have a blog comment form that a user fills out and is submitted and run through a controller function which is then redirected to the viewComments controller function.

Code:
function addComment()
  {
      // save comment to database code here
      $this->session->set_flashdata('msg', 'Comment added');
      redirect('/blog/viewComments/');
  }


2. The viewComments page is then loaded with all of the comments and the message at top

Code:
function viewComments()
  {
      // code to output comments here
      $data['msg'] = $this->session->flashdata('msg');
      $this->load->view('viewComments',$data);
  }

In the View you would then output the message using $msg


Hope this makes sense as its hard to explain without a full code sample :-S
#17

[eluser]cinewbie81[/eluser]
Ok guys, it's working now .. Thanks a lot ..

just another question , is that possible for me to make the flash msg animated ?? If so where should i start ??
#18

[eluser]wemago[/eluser]
jquery, scriptaculous or mootools choose one of them.

i'm used to scriptaculous and if you see their examples, you'll see that
there's an perfect effect for this and very easy to use -> fade out Wink
#19

[eluser]cinewbie81[/eluser]
Sorry One more question,

Is that possible for us to pass a parameter of the message type in set_flashdata function ?
for example : $this->session->flashdata('msg', 'error') or $this->session->flashdata('msg', 'info')

I need to display different message type with different color ..
#20

[eluser]Derek Allard[/eluser]
No, you'll need to detect values for that.




Theme © iAndrew 2016 - Forum software by © MyBB