uri routing problem |
[eluser]dhananjay[/eluser]
my client wants this type of url structure in codeigniter i am unable to find out solution on this, this is possible to achieve or not - Freight Search pages: www.freightmatch.com.au/freight/ - Internal Freight pages: www.freightmatch.com.au/freight/transport-[origin]-to-[destination]/[Freight-ID] now first url will show listing of freight jobs and second url will be for each single job but because both have 'freight' in url so i am unable to understand how can i route them to different methods.... now if for this i create index method www.freightmatch.com.au/freight/ this will work on index so route will be $route['freight/(:any)'] = 'freight/index/$1'; it can also have www.freightmatch.com.au/freight/10 with pagination links now about second Internal Freight pages: www.freightmatch.com.au/freight/transport-[origin]-to-[destination]/[Freight-ID] how would i know that with same url it is different page now ? that's my problem any help would be appreciated....
[eluser]InsiteFX[/eluser]
And where are they getting the [origin] and [destination] from ? If the freight-id is numeric then you could check for that, otherwise you would need to break it down using the uri_segment
[eluser]dhananjay[/eluser]
origin and destination will be strings and they will be different for each url , yes frightid will be numeric... also so breaking my uri segment mean i will need to handle both in same index function...they can't be handled by other controller or method by defining route[] Thanks
[eluser]CroNiX[/eluser]
You can't do everything you are asking using only one method. However, using routes, the methods are invisible to the user, so it shouldn't be a problem. Code: // http://www.freightmatch.com.au/freight/transport-[origin]-to-[destination]/[Freight-ID] Code: function view_transport($origin, $destination, $freight_id = null)
[eluser]dhananjay[/eluser]
Thanks a lot this worked seamlessly , Thank You i have another question too if you can help with that too i have a custom 404 page now when some pages do not exists in database i am redirecting user to that 404 page now i want to make sure that robots will also see this as 404 page but i didn't found what i will need to for that ....so the page i have, is dealt by bots as 404 error page....
[eluser]CroNiX[/eluser]
instead of redirecting, which changes the url, use show_404(); which will show the 404 page with the 404 header and keep the non-existing url intact so spiders will see that.
[eluser]dhananjay[/eluser]
Now the problem is after doing this that it shows default 404 page of codeigniter but not the one i have defined in route file i.e. $route['404_override'] = 'error404';
[eluser]Tpojka[/eluser]
Maybe to change the code in application/errors/error_404.php?
[eluser]dhananjay[/eluser]
$route['404_override'] = 'error404'; error404 is a controller which shows a page that contain header and footer of my website and shows that page is not found in that file application/errors/error_404.php? i will not be able to call view file..would i? |
Welcome Guest, Not a member yet? Register Sign In |