Welcome Guest, Not a member yet? Register   Sign In
RegEx driving me mad
#1

[eluser]Y0shi[/eluser]
Hello guys,

I have some problems with the RegEx from the routes files. I think it should be simple but I cant manage to get it working...

I've a table called _seo where everything belonging to uris is stored. For example my user can edit a page like /article/showarticle/1 to /homesite and it will be displayed. But now, since a new feature should be, I need a regex which still proceeds the parameters to the controllers. In other words:

I want to implement a feature which allows multible sites like:

/article/showarticle/1/1
/article/showarticle/1/2
/article/showarticle/1/3
... and so on

That should be:

/homesite/1
/homesite/2
/homesite/3

Is there a very general RegEx a solution for this problem?

Thanks for your help in advance.

Regards.
#2

[eluser]Seb[/eluser]
Hello,

Take a look at http://ellislab.com/codeigniter/user-gui...uting.html.

You can try something like

Code:
$route['homesite/(\d+)'] = "article/showarticle/1/$1";
#3

[eluser]Y0shi[/eluser]
Thanks! Yeah that's what I know too, but my routes are dynamicly loaded. So I need a general term for anything/attributes -> controller/attributes
#4

[eluser]Seb[/eluser]
Well what about

Code:
$route['([a-z]+)/(\d+)'] = "article/showarticle/$1/$2";

But do you mean you load and populate your routes from a database for every request ?
#5

[eluser]Y0shi[/eluser]
I'll give it a try Wink

Yeah I do so ... needed to make user routes happen :/




Theme © iAndrew 2016 - Forum software by © MyBB