Routing using lang file |
[eluser]Ngulo[/eluser]
Hi all guys, i'm newbie and i would like to route my urls according to a session param which load in my controllers main lang file, how can i retrieve this lang file in route.php ? is it possible? then i'm trying to route this url: http://localhost/asd/index.php/products/category/85 taking examples from CI ufficial guide but i'm not able to make them works do i need to remove index.php from urls? thanks guys
[eluser]pickupman[/eluser]
Can you give an example of what to are trying route from and to? ie. /85/my-shoe-product to products/category/85
[eluser]Ngulo[/eluser]
thanks man for helping me... so first of all i can't route this link for example: http://localhost/asd/index.php/products/category/85 to http://localhost/asd/index.php/asd/asd/85 can you give me an example to how to do in main route.php file to route this link? then i'm using multilanguage site so i would like to route my urls according to site language but i can't find any how to work on i created my personal language class which is switching into ,my controllers, main lang file to load inside them according to user session param somenthing like this: Settings.php (system/application/libraries) Code: class Settings { Code: class User extends Controller { so as you can see i switch a user lang session param to load correct lang file so, in the end, i can't understand how to route my urls according to site lang (which in my case into session array) hoping you understand my bad english thanks
[eluser]Ngulo[/eluser]
i was planning to check $_SESSION param into route.php then do somenthing like this (into route.php): Code: if( $_SESSION['lang'] == en){ but i'm thinking is not the right solution!? :/ thanks again
[eluser]pickupman[/eluser]
I think you may be making this harder than it is. You should have the same url regardless of language for SEO purposes. The language class will always load the english file if a invalid language is specified. I would load the language file using MY_Controller. If you don't have application/libraries/MY_Controller.php create the file with. Code: class MY_Controller extends Controller{ This will execute for every controller, and you will need to set filename to match a language file. If the language key is not found in the user's session, it will load the English file by default.
[eluser]Ngulo[/eluser]
right man i think it too(i make more difficult then it is) and in the end what about to route this url: http://localhost/asd/index.php/products/category/85 to http://localhost/asd/index.php/asd/asd/85 ? i'm trying using this in route.php: $route['products/category'] = "asd/asd"; but it doesn't works for me
[eluser]pickupman[/eluser]
Quote:i’m trying using this in route.php:Should be: Code: $route['products/category/(:num)'] = 'asd/asd/$1'; //this would be invalid to have a controller and method with same name
[eluser]Ngulo[/eluser]
so i've tryed both: $route['products/category/(:num)'] = 'controller/function/$1'; or $route['controller/function/(:num)'] = 'products/category/$1'; but they doesn't works don't know why maybe need i to set some config parameter? thanks again man |
Welcome Guest, Not a member yet? Register Sign In |