I would recommend another way. gwoo's solution means a request to the db every time(!) the navigation is shown. IMHO too much db-action. I would create a function in the controls controller like
function updateNavigation() { $entries = $this->Control->findAll(); $string = '<ul>'; foreach ($entries as $key => $value) { $string .= "<li><?php echo \$html->link('Link text', '/url/to/ page/') ?></li>\r\n"; } $string = '</ul>'; // rewriting the thtml-file of the navigation-element. $fp = fopen(ROOT.DS.APP_DIR.DS.'views'.DS.'elements'.DS.'navigation.thtml', 'r+'); ftruncate($fp, 0); fputs($fp, $string); fclose($fp); } Call this function with every create and update (e.g. in add(), edit()) and it rewrites your navigation element with the newest data. so most of the request on the navigation do not need a db request. I use this in several apps and it works pretty good and saves ressources of your db. On 20 Mrz., 01:19, "gwoo" <[EMAIL PROTECTED]> wrote: > This has come up a lot lately for some reason. I guess because there > are not enough examples. > > Personally, I would setup and element. Lets calll it /app/views/ > elements/menu.thtml > add to this: > > $controls = $this->requestAction('controls/index'); > foreach($controls as $control) { > //do whatever} > > very simply this asks the controls controller to return the index > method so you can display the data however you want > > <?php > class ContolsController extends AppController { > > function index() { > > $contols = $this->Control->findAll(); > > //here is where the requesAction is handled so only the data is > returned > if(isset($this->params['requested'])) { > return $controls; > } > > $this->set('controls', $controls); > > } > } > > ?> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---