Background:  i am trying to build a little database-driven 2-level
menu system that checks authorization to access menu pages and actions
*before* they are displayed.  If you are not authorized to use the
"budgets" table in any way, you won't be presented with a "budgets"
menus option (I am using Authake for the auth function)

To stick with MVC convention, I figured I should put as much of the DB
access and auth in my "menus" controller.  I would use find() with
some complex conditions to extract only the set of menus that I wanted
a user to get.  I had problems with my conditions in find() and I
concluded I didn't understand it well enough -- maybe a fundamental
misunderstanding about variable scope and what could be sent in to a
query via find().

So I backed up and  added

   echo "<pre>"; print_r($this->viewVars);echo "</pre>";?>

to my default.ctp so I could see what vars were being set in my
controller:

I am using routes and using URL comparison to select menu records from
the database.  I can set this in the controller:

  $this->set('current_uri', $_SERVER[REQUEST_URI]);

The idea is to use URL to set parent menu and then query all parent
+child menu records.

But when I went to use $current_uri it in a find(all, [conditions])
the find simply failed  So I did another test.  I can set:

  $this->set('menu_link', "/budgets" );

but when I subsequently try to do this set in the next line in the
controller:

  $this->set('menu_name', $menu_link );

I see menu_name in viewVars, but it has no value.  I get the same no-
value result if I use:

  $this->set('menu_name', $this->menu_link );

All this tells me that there is something really basic this perpetual
n00b doesn't understand  about scope of vars in viewVars and/or how
they can be compared or set in the controller.

Any thumps with the clue stick appreciated.

Jim









--~--~---------~--~----~------------~-------~--~----~
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