Welcome Guest, Not a member yet? Register   Sign In
How to load a view for the error page?
#11

[eluser]Pascal Kriete[/eluser]
It sure would be - and it would get rid of the ugly session hack as well. In the particular case that I derived the code from, I wanted to keep the url the same.

Redirecting is the way to go if you don't have that requirement.
#12

[eluser]Aquillyne[/eluser]
I've actually tried using your code now - and it doesn't seem to work!

I get a redirection loop, which suggests there must be an error in the code for the error controller. But it'll never be able to tell me what that error is, because it's trying to display the error through itself!

I'll fiddle with the code for now.
#13

[eluser]Pascal Kriete[/eluser]
Yes, the looping thing is a problem. I'll take a look.
#14

[eluser]Aquillyne[/eluser]
[quote author="inparo" date="1216589030"]Yes, the looping thing is a problem. I'll take a look.[/quote]

Aha.

I tried not to use your router extension, so I changed the code to redirect to an error controller instead.

But the problem seems now to be the use of the $_SESSION variable in the error controller. This is probably because I haven't begun a session anywhere, I suppose?
#15

[eluser]Pascal Kriete[/eluser]
Yes, if you redirect you no longer need any of the session stuff. Instead, you'll need to remove the _remap and redirect to the corresponding function right away.
#16

[eluser]Aquillyne[/eluser]
[quote author="inparo" date="1216514906"]Whenever CI encounters an error it calls the proper function in the Exceptions class.[/quote]

How early on is this? Is CI itself instantiated at the time?

In the MY_Exceptions class, can I, for instance, use, "$this->session->set_userdata()"? Or if not (as I imagine is true), how might this be possible? I suppose I might have to get_instance() CI?
#17

[eluser]Aquillyne[/eluser]
[quote author="inparo" date="1216589410"]Yes, if you redirect you no longer need any of the session stuff.[/quote]

Surely I do still need some of the session stuff, so as to pass along the error messages?
#18

[eluser]Pascal Kriete[/eluser]
Hmm, you're right of course. So where to start the session....
The best place I can think of is the top of index.php.

Alternatively, you could urlencode the message and pass it along as another segment
#19

[eluser]Aquillyne[/eluser]
Well I've been fiddling around trying to store the error message in flashdata from the Session class.

I figure trying to use the Session class in the MY_Exceptions class is too early. Is there a way of doing this?

EDIT:

I've been trying the following:

Code:
function _redirect($error)
{
    if (isset($this->session->userdata("error")))
    {
    ...

And this is returning a fatal error: "Can't use method return value in write context." What's wrong with that bit of code?
#20

[eluser]Rick Jolly[/eluser]
From php.net:
Quote:isset() only works with variables as passing anything else will result in a parse error.




Theme © iAndrew 2016 - Forum software by © MyBB