Reputation: 27321
I believe Smarty templates has functionality built in that allows you to manage your site URLs from a config file so if something gets moved, you only have to update the URL in one place. Does this sort of functionality exist in CodeIgniter? If not, any pointers or examples on how/where to add it?
For example:
Instead of hard-coding the link it would be: <a href="<?=$links->settings ?>">Settings</a>
But where would you want to set $links so that it was available everywhere? Or is it really best to just hard code them?
Upvotes: 0
Views: 650
Reputation: 1907
Take a look at the config class. It allows you to make custom config files. It's not entirely made for URL's but you sure can use them.
Upvotes: 1
Reputation: 12207
Yes, it's called Routes
, configuration located at config/routes.php
. Documentation
If you ask about the rendered html of the links, then your best bet would be using site_url()
in conjunction with constants, for example site_url(URL_SETTINGS);
, there is no built in functionality for that, but I can say I don't think that is necessary as it would be used too rarely, but it would influence performance every single load.
Upvotes: 1
Reputation: 17598
The base url should be basically right at the start of /app/config/config.php, where app is the name of your codeigniter application folder. You access it through calls to the base_url()
function.
Upvotes: 1