Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Links to Controller methods: CodeIgniter

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://example.com/codeigniter/index.php/news/create

to

http://example.com/codeigniter/index.php/news/

How are dynamic URLs like that made on CodeIgniter?

like image 936
Zigu Avatar asked Feb 22 '23 21:02

Zigu


1 Answers

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');?>
like image 178
Seth Avatar answered Mar 02 '23 00:03

Seth