I'm following this tutorial on CodeIgniter:
http://ie.mirror.twsweb-int.com/codeigniter/user_guide/tutorial/index.html
4th page of tutorial:
http://ie.mirror.twsweb-int.com/codeigniter/user_guide/tutorial/create_news_items.html
In the 4th page of the tutorial, he mentions that you should create your own successful entry page.
I want to create a link on the success.php that links back to the index page (calls news_index). IE in terms of URLs, I want a link that goes from
http://examp开发者_C百科le.com/codeigniter/index.php/news/create
to
http://example.com/codeigniter/index.php/news/
How are dynamic URLs like that made on CodeIgniter?
First load the URL helper in your controller or Autoload file.
Then use the site_url()
function and just pass news.
<?php echo site_url('news');?>
If you take a look at this page - http://ie.mirror.twsweb-int.com/codeigniter/user_guide/helpers/url_helper.html you can see how the site_url()
function works.
You just echo site_url('controller/method/segment1/segment2/etc'); so if you wanted to link to the http://example.com/codeigniter/index.php/news/
page you can do
<?php echo site_url('news'); ?>
and if you wanted to link to the http://example.com/codeigniter/index.php/news/create
you can do
<?php echo site_url('news/create'); ?>
you configure them on the routes.php on your codeigniter files.
You can set site_url/base_url
in config.php
and load the URL helper in autoload.php
file.
精彩评论