Welcome Guest, Not a member yet? Register   Sign In
Multiple URL suffixes?
#1

[eluser]mikepuerto[/eluser]
Is it possible to use multiple url suffixes? I'm trying to serv content in different formats based on the this. Any help would be appreciated.

Thanks,
Mike
#2

[eluser]bretticus[/eluser]
"multiple url suffixes"? You mean folders/directories? Can you give an example?
#3

[eluser]mikepuerto[/eluser]
Basically, I want to be able to use a few different url suffixes.($config['url_suffix'] = ""Wink examples:

"http://example.com/controller/segment.html"
"http://example.com/controller/segment.json"

etc...


I can't for the life of me figure out how to set different suffixes. Would this have to take place outside of the controller?
#4

[eluser]bretticus[/eluser]
Ah, yes, URL Suffixes, as coined in the manual. Smile

That feature does nothing that I'm aware of, other than what it says in the manual:

Quote:In your config/config.php file you can specify a suffix that will be added to all URLs generated by CodeIgniter.

This just tacks on a suffix (or fake file extension) to the end of your links when using anchor() functions, etc. Furthermore, routing ignores the fake extension and routes you to the appropriate controller method.

I would suggest that this is taking you in the wrong direction. In other words, it's not what you really need. You want, for example, to display something different depending on the fake file extension. Right?

It should be trivial to use URI Routing to pass an argument to your controller methods depending on the extension.

For example:

Code:
$route[':any\.json'] = "$1/json";

Note: This is a very raw example off the top of my head. Might not work but it's more of an example of what I'm talking about than working code. Smile




Theme © iAndrew 2016 - Forum software by © MyBB