I'm not sure how proper this is, but this _should_ work for what I
think you're talking about:

Instead of using a component, I would define a beforeFilter() method
in the AppController that would request the states and set them for
the view.  So in essence that set() method would be run for every time
the page is loaded.  Throw in an if statement to avoid loading it for
anything using ajax updates or flashes (and to be picky about
overhead) and you're gold...I think.  Not tested.

<?
Class AppController extends Controller
{
    public $uses = array('City'); //change to whatever this is for you


    /*
        Your stuff...   */

    public function beforeFilter()
    {
        if ($this->layout == 'default')
        {
            $this->set('cities', $this->City->findAll());
        }
    }
}
?>

On Apr 3, 7:34 pm, "Bootstrapper" <[EMAIL PROTECTED]>
wrote:
> I'm not 100% sure, but I think you want to do the following:
>
> I think you need to access the database in your action to get a list
> of all the cities in the database. That means you'll do it right
> before every search, but at least then it will be up to date on the
> latest additions to the database. You might also be able to use
> caching to make it faster.
>
> Use:
>
> (Quoted from the cake manual)
> <b>
>
> Cities->generateList()
>     * string $conditions
>     * string $order
>     * int $limit
>     * string $keyPath
>     * string $valuePath
>
> This function is a shortcut to getting a list of key value pairs -
> especially handy for creating a html select tag from a list of your
> models. Use the $conditions, $order, and $limit parameters just as you
> would for a findAll() request. The $keyPath and $valuePath are where
> you tell the model where to find the keys and values for your
> generated list. For example, if you wanted to generate a list of roles
> based on your Role model, keyed by their integer ids, the full call
> might look something like:
> $this->set(
>     'Roles',
>     $this->Role->generateList(null, 'role_name ASC', null,
> '{n}.Role.id', '{n}.Role.role_name')
> );
>
> //This would return something like:
> array(
>     '1' => 'Account Manager',
>     '2' => 'Account Viewer',
>     '3' => 'System Manager',
>     '4' => 'Site Visitor'
> );
> </b>
>
> You might need to put cities in their own table with an ID number that
> is used in any other tables that might need to be linked to a city
> (like address for example).
> So when you get a new property, you check the city to see if it's
> unique, and if it is you add it to the cities table. If you already
> have the city in the cities table, you just refer to it by ID.


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

Reply via email to