Need help with some structure problems. |
[eluser]Unknown[/eluser]
Hi! Im pretty new to both codeigniter and the mvc concept so be gentle. I will try to explain my problem as detailed as i can. Let say i im building a blog, and my admin part of the site is controlled by my controller named admin. In my admin controller i have a function called posts, so my url to posts would be www.example.com/admin/posts/. Here comes my problem, when i are editing or adding a post i would like url to be www.example.com/admin/posts/edit/"id number". I could just fix it bye creating a new function in my admin controller called "edit_posts" and url would be www.example.com/admin/edit_posts/"id number", but that is not what i want. And i cant create a function called posts/edit() and i cant create a function called edit() in my posts() controller. How can i solve this problem?
[eluser]rogierb[/eluser]
Hi and welcome, read up on Routes in the userguide. With routes you can do all of the above and more...
[eluser]Unknown[/eluser]
[quote author="rogierb" date="1264102868"]Hi and welcome, read up on Routes in the userguide. With routes you can do all of the above and more...[/quote] Thnx that did the trick ! But now i ran in to another problem. I have two menus a topmenu and a sub menu, and i have an if statement that looks like this. Code: <li<?php if($this->uri->segment(2) == $link_name) {echo class='selected'} ?>><?php echo $link_name; ?></li> It works just fine as long as i have pressed my links so the uri segemnt is set, but for example on my index page the uri segment issent set. I thougt i just could do something like this but i dident work. Code: <?php if (!isset($this->uri->segment(2))) {$this->uri->sgement(2) = "start"} ?> Any idea how i can fix this ?
[eluser]rogierb[/eluser]
I think isset($this->uri->segment(2)) is always true, even if it is empty if you go with empty($this->uri->segment(2)) you will get the right value Code: <?php if( (!empty($this->uri->segment(2))?$this->uri->segment(2):'start') == $link_name) {echo class='selected'} ?> |
Welcome Guest, Not a member yet? Register Sign In |