CodeIgniter Forums
Anyway to set $config['url_suffix'] during runtime? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Anyway to set $config['url_suffix'] during runtime? (/thread-43285.html)



Anyway to set $config['url_suffix'] during runtime? - El Forum - 07-06-2011

[eluser]gunnarflax[/eluser]
Hi everybody!

I'm looking for a way to set the url suffix during runtime. In my CMS the user gets the option to use "Pretty URLs" and the setting is stored in a database.

I can't use hooks since they can't be defined when the controller is reached in the execution order. If I set:
Code:
$this->config->set_item('url_suffix', 'html');

It doesn't show up in the URL since the controller has already been executed. Any suggestions? Will it be enough to change the value in the URI-class object or must I change the value in a whole bunch of instances?


Anyway to set $config['url_suffix'] during runtime? - El Forum - 07-06-2011

[eluser]toopay[/eluser]
Your option is limited and its not a easy job. If you want to use hook, you need to "edit"/access the config file at pre-system checkpoint. Its on route section flow, suffix inspection happened. Or if access/edit file its not flexible enough for you, you can hack the URI-class to receive some defined constant from your pre-system hook.


Anyway to set $config['url_suffix'] during runtime? - El Forum - 07-07-2011

[eluser]gunnarflax[/eluser]
mm, it seems like I have to skip that part of my application, it would have been nice though Smile