cakephp - Best way to populate a dropdown sitewide that is -
i using cakephp 1.3 , layout includes dropdown of organizations user has access administer, i'm trying populate dropdown organizations contain userid logged in, want populate before user sees can use in header. dropdown needs appear on every page once logged in. tried adding query pull these organizations in appcontroller, userid not yet available use in before filter. or how should this? should in session or there better construct use? element?
in app it's no problem use user_id within beforerender (if using auth-component).
you can use $this->auth->user('id')
.
i this: check in appcontroller if user logged in. if is, pull wanted information database (or whereever information from) , store in variable called $dropdown
example.
if user not logged in, $dropdown
false
.
make variable available view $this->set(compact('dropdown'))
now in layout (this important have on every page) can check if $dropdown
false or not. if not, can work variable , show user wanted dropdown.
Comments
Post a Comment