CodeIgniter Forums
vars in config / route.php - Printable Version

+- CodeIgniter Forums (
+-- Forum: Development (
+--- Forum: CodeIgniter 2.x (
+--- Thread: vars in config / route.php (/thread-62695.html)

vars in config / route.php - dem80 - 08-16-2015

Hi I am creating a website in more languages. I have 9 maingroups in 4 languages.

I want to create (if possible) something like this:


But I want to put the string 'women|men|shoes|kids|bodywear|eyewear' as a varibele. But I cannot find if it is possible to do something like so:

foreach ($tree as $node) {

$pages = implode('|' , $maingroups)
$route[$pages] = 'maingroups';

Can someone help? Thanks and kind regards.

RE: vars in config / route.php - kilishan - 08-16-2015

Yes, you can use variables, etc in your routes file to build your routes.

I don't know where you're getting $tree from. When the routes file has been read in, you don't have access to much of the CodeIgniter code so it would all depend on where that variable was coming from. Without that info I can't say if that exact code is possible.

Have you tried it?

RE: vars in config / route.php - CroNiX - 08-17-2015


Then the index method of the maingroups controller would look like:
public function index($type = null)
  echo $type; //$type will be women, or men, or shoes, etc.