Hi All,

  I'm new to cakephp and working through my first cake app.  I'm
chugging along and am now stumped as to where to put a function I've
written to help decide if a navigation tab should have the
id="selected" assigned to the anchor tag.

Basically the gist is I have a <ul> Navigation bar with various links:
(Home, Contact, ect..) and depending on the current controller or
action or whatever I pass in; I want the id of that <a> tag to be
"selected".

So I've written a little function:

function is_selected($controller_or_action, $link_text){
  if (strpos($controller_or_action,$link_text) !== false) return true;
  else return false;
}

And I'm calling it like so in the default.ctp layout:

<?php
 if(is_selected($this->params['controller'], "pages")) echo $html->link
('Contact', array('controller' => 'pages', 'action' => 'contactus'),
array('id' => 'selected'));
else echo $html->link('Contact', array('controller' => 'pages',
'action' => 'contactus'));
 ?>

But that's really tedious and quite ugly, plus I have that function
just written at the top of the layout which is a big no-no.  So I'm
looking for some help/advice.  How do you specify a tab type layout in
your cake app?

Thank you for your advice and/or help.
Nick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to