Welcome Guest, Not a member yet? Register   Sign In
vars in config / route.php
#1

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:

$route['(women|men|shoes|kids|bodywear|eyewear)']='maingroups';

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:

$maingroups=array();
foreach ($tree as $node) {
          $maingroups[]=$node->cat_name;
  }

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

Can someone help? Thanks and kind regards.
Reply
#2

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?
Reply
#3

Try:
Code:
$route['(women|men|shoes|kids|bodywear|eyewear)']='maingroups/index/$1';

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




Theme © iAndrew 2016 - Forum software by © MyBB