sorry I do not speak good English, use translator. How can I create links in codeigniter?
What if I want to use permalinks after?
I would have to change the whole system code every time you make a change in permalinks?
Is there a library that manufactures the links from these arguments and behave as configured dynamically?
For example if I want to change the system directory from:
http://testing/webapp/index.php
to:
http://production/index.php
Do I need to change all the code? What is the best practice for this?
You can use codeingiter's methods base_url() and site_url().
At first, you need to load the URL helper in your controller:
See their definitions below (According to CI documentation, http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html)
site_url()
base_url()
This is precisely what the Base URL is for in the config file. The only thing you need to worry about after that are your relative URL's, you can even set up different environments by making new folders inside of the config folder
for example if I set in my config.php directly inside of the config folder
Then the base url is always http:// localhost/hello now let's say I have my home development environment and a production environment. If I copy the config.php to a folder inside config called production so application/config/production/config.php set the base URL to:
Then in my index.php I set:
Everywhere I need the environment to change Codeigniter will change it for me. So on the live site I use the production environment, at home I change that environment to development and CI does the work for me.
Then in your code use the base_url() to make your links.
For example:
Will produce:
Make sense?