Question

Good morning guys, I'm new to CodeIgniter, I want to create a horizontal menu, I've done this with HTML + CSS3, and when I click on the menu it goes to that page indicated, of course, using html, but I want to do in CodeIgniter. I've found the documentation, but it was not clear to me https://www.codeigniter.com/user_guide/helpers/url_helper.html can someone help me?

Was it helpful?

Solution

Creating a horizontal menu in CodeIgniter is a lot like creating it with plan HTML, only you're using CI helpers to create the anchors. A simple menu would be created like this:

<ul id="menu">
    <li><?php echo anchor('controller/action', 'Link Text'); ?></li>
    <li><?php echo anchor('controller/action', 'Link Two'); ?></li>
    <li><?php echo anchor('controller/action', 'Link Three'); ?></li>
</ul>

The anchor helper will produce a link, so your menu items will output like this:

<li><a href="controller/action">Link Text</a></li>

Once you create the menu you can style it with CSS like any other menu. In place of the anchor helper you can use any of the other URL helpers like current_url or index_page.

You're not required to use the URL helpers when creating a menu, so if you have a static menu you could use plain HTML to create it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top