Remove the single quotes. $category['Category']['name'] is already a string so you don't need them. What you'd done is passed the literal string, '$category['Category']['name']'.
As for creating a menu, once you have something working, you might want to look at caching the result so you're not hitting the database on every page view. On Thu, Sep 24, 2009 at 10:20 PM, Barney <[email protected]> wrote: > > first, I am very new to cakephp. > > I have 2 tables "categories" and "products" > > I want to make a menu like category->product tree > > in the view, i use those code to display the categories: > > <ul> > <?php foreach($categories as $category): ?> > <li> > <?php echo $category['Category']['name']; ?> > </li> > > <?php endforeach; ?> > </ul> > > But if I want to add links to these categories > > how can I use $html->link to achieve it? > > > $html->link('$category['Category']['name']',array > ('controller'=>'Products','action'=>'view', $category['Products'] > ['id'])); > > > but this line code goes error, > > I know $html->link first parameter should be a string value, how can I > assign a variable ? > > > please help,thank you > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
