jmccartie
jmccartie

Reputation: 4976

Link to unless current -- is it possible in CodeIgniter?

In Ruby (forgive me for mentioning it's name) I noticed you could do a anchor link with "link to unless current", which would remove the link if it was the current page.

I know there's nothing built into CodeIgniter to do something similar, but I'm trying to come up with the best way to do this. I've got a few options, but they're all too long and cumbersome. Does anyone have any ideas (maybe using the URI segment)?

Upvotes: 0

Views: 453

Answers (2)

David
David

Reputation: 18281

Why not write your own helper that follows the html helper link_tag checker... put one more condition inside there to check if your in the current controller. Looking at codeIgniter with xdebug, the object returned by get_instance provides access to pretty much everything the controller had. so ci->router->uri->rsegments could be used to check for your controller action.

Edit: Sorry forgot the "uri" part in that chain above.

Upvotes: 1

epochwolf
epochwolf

Reputation: 12782

You can

A. Use an if statement around the link

or

B. Make your own function

CodeIgniter is a significantly smaller framework than ruby on rails as far as features go. I doubt they have a copy of every useful function rails has.

Upvotes: 0

Related Questions