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

[eluser]cinewbie81[/eluser]
Hi all,

I want my system to display a message after certain action been executed.
For eg: 'System user has been deleted' - This is so user knows that the action was executed

Can I do it something like CI Form Validation error message ? IF so then how can i do it ?
#2

[eluser]Phil Sturgeon[/eluser]
Just make a REALLY simple view called message.php. Then have two variables inside it, like this:

Code:
<p>&lt;?=$message;?&gt;</p>

<p>&lt;?=anchor($goto_link, 'Click here');?&gt; to continue.</p>

These variables can be defined each time you want to show a message. For example in your controller if something works, redirect it to a success page.

Code:
function success(){
    $data['message'] = 'The user has now been un-banned.';
    $data['goto_link'] = 'users/user_list';
    $this->load->view('message', $data);
}

You will of course need to include your layout (header and footer) however you handle that. Use YATS or whatever.

There are many more complex methods of doing it but this is a nice quick one.
#3

[eluser]cinewbie81[/eluser]
Hi thepyromaniac, your methos will definitely works..
Anyway, what i want is something like Form Validation Error Message.
When an action is performed, the message will display somewhere on top of the page of the form, instead of load another view file (if you get what i mean)
#4

[eluser]wemago[/eluser]
if i get what you want, you can do it using
sessions flash messages, see latest updates on svn for CI.

Code:
if ( action fail )
       set flash msg
       redirect any where you want
   endif

on the location you want/redirect, you just need

Code:
if ( isset( flashmsg ) )
       print your message
    endif

and if you want it a bit more good looking just add a bit of javascript
fade out effect Wink
#5

[eluser]cinewbie81[/eluser]
wemago,

I check on this url:
http://bleakview.orgfree.com/obsession/

Yes, that's exactly what i want ..
but, my current application doesnt use session ...
instead i use cookie for login etc ...

what should i do now ? and i dont know where to get the latest code for Codeigniter SVN
#6

[eluser]Derek Allard[/eluser]
Hey cinewbie81. I got just what the doctor ordered Wink

http://www.derekallard.com/blog/post/che...epository/

Flash vars definately sound like what you want.
#7

[eluser]cinewbie81[/eluser]
Having some problem to get those files using SVN... it prompt me for username and password ..

anyway, I manage to found the file from http://svn.kohanaphp.com/trunk/system/libraries/

I suppose it's only the session file that's needed to be replace in this case right ??
#8

[eluser]wemago[/eluser]
yes its only the session file you need.
if you use tortoisesvn in windows, should work out the box.

follow master Dereks steps and should just work fine Wink
#9

[eluser]xwero[/eluser]
You find the solution for connecting to the svn in the comments of the blogpost.
#10

[eluser]Derek Allard[/eluser]
cinewbie81, I'd strongly encourage you to use the CI session files - I'm not sure about compatibility with other libraries.




Theme © iAndrew 2016 - Forum software by © MyBB