CodeIgniter Forums
How do you add a link for the homepage? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How do you add a link for the homepage? (/showthread.php?tid=20882)



How do you add a link for the homepage? - El Forum - 07-24-2009

[eluser]johnnyForums[/eluser]
I have this:
Code:
<div id="menu">
        <ul>
            <li class="current_page_item"><a href="">Homepage</a></li>
            <li><a href="">Add</a></li>
            <li><a href="">Search</a></li>
            <li><a href="">About</a></li>
            <li class="last"><a href="">Contact</a></li>
        </ul>
    </div>

The href="" is replaced by whatever was my last view call. What I want is for homepage to go back to the main website page. How do I do that? I don't know what to put there other than index to call the /mycontroller/index function. I didn't know if that was "the way" it was done.


How do you add a link for the homepage? - El Forum - 07-24-2009

[eluser]garymardell[/eluser]
Code:
<li class="current_page_item"><a href="&lt;?=base_url();?&gt;">Homepage</a></li>

or

Code:
<li class="current_page_item">&lt;?=anchor("", "Homepage");?&gt;</li>



How do you add a link for the homepage? - El Forum - 07-24-2009

[eluser]johnnyForums[/eluser]
[quote author="garymardell" date="1248465670"]
Code:
<li class="current_page_item"><a href="&lt;?=base_url();?&gt;">Homepage</a></li>

or

Code:
<li class="current_page_item">&lt;?=anchor("", "Homepage");?&gt;</li>
[/quote]

The first one put me too far back. It did not put be at the default controller so I must not have something set right. It is http://127.0.0.1/myvirtualdirectory instead of http://127.0.0.1/myvirtualdirectory/mydefaultcontroller.

The second one put me at http://127.0.0.1/myvirtualdirectory/index.php but did not put me at the default controller. I got 404 on both. I put in a simple "index" but I would like to make your way work.


How do you add a link for the homepage? - El Forum - 07-24-2009

[eluser]garymardell[/eluser]
Well you obviously have not setup codeigniter quite right. In the routes.php file have you set the right default controller. and also is your base_url in configs file right.