CodeIgniter Forums
load different URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: load different URL (/thread-22845.html)



load different URL - El Forum - 09-22-2009

[eluser]Unknown[/eluser]
Hi everyone, just getting started with CI and really liking it so far.

I have a really n00b question:

I've made a custom error handler so I can call an action before a 404 page is shown.

the action at the moment looks something like this.

Code:
function error_404()
{
        echo "<h1>404</h1>";
        
}

would it be possible to call a page based on a url in this function such as

/page/view/1231

without actually doing a redirect to /page/view/1231 ?

so that when the 404 error action is called, it actually shows /page/view/1231


load different URL - El Forum - 09-22-2009

[eluser]wabu[/eluser]
Hello, how about just loading the view you want?


load different URL - El Forum - 09-22-2009

[eluser]designfellow[/eluser]
Hi,

You can do this in two ways.
1. just simply inlcude the view there
Eg. $this->load->view('page');

2. If you want to do some code processing, you can create a custom helper & put the code in a function & call it

I think i'm confusing you a bit.

Option 1 will be easier for you.


Happy Coding,
DesignFellow


load different URL - El Forum - 09-22-2009

[eluser]sophistry[/eluser]
[quote author="ch33ky" date="1253626427"]
would it be possible to call a page based on a url in this function such as

/page/view/1231

without actually doing a redirect to /page/view/1231 ?

so that when the 404 error action is called, it actually shows /page/view/1231[/quote]

then it isn't a 404 is it? it's a 301 or 302 header status code which implies a redirect.

when you send a 404, that means page not found, when you send a default page, that's a default page.

HTH.

cheers.