For various forms within the Aegir system, it would be nice to provide autocomplete text fields so users can select site names. Let's place this functionality within Sites, as that's where it should go.

In order to work with these values, we need to be able to figure out the node ID of the selected site from the selected name so that we can do something with it.

I'll have a patch for this in a minute.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

colan created an issue. See original summary.

colan’s picture

Status: Active » Needs review
FileSize
2.71 KB
colan’s picture

gboudrias’s picture

Status: Needs review » Needs work

hosting_get_site_by_url() is used in a few places: http://api.aegirproject.org/api/Hosting/site!hosting_site.module/functio...

Your version uses the DB API, which is of course better, so as long as you already wrote the code we could swap it in. The original function returns the whole node though, it would be important not to change this if we go that way.

colan’s picture

Title: Add ability to get Site/node ID from name & add autocompletion » Add site autocompletion & ID retrieval without loading nodes
Status: Needs work » Needs review
FileSize
5.19 KB

Hopefully this patch gives us what we want.

I made the following changes:

  1. Made sure only active (non-deleted) sites are returned in both cases.
  2. Moved the EntityFieldQuery to hosting_get_site_by_url(), and removed the new function.
  3. Added the $loaded_object parameter to it (which defaults to TRUE). This will improve performance by not loading the site nodes when not necessary.
  4. Added the DB query tag site_not_deleted to account for the lack of native JOIN support in D7 EntityFieldQueries. We can start using this method everywhere.

  • gboudrias committed e4d16d6 on 7.x-3.x authored by colan
    Issue #2720439 by colan: Add site autocompletion...
gboudrias’s picture

Status: Needs review » Fixed

Works great, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.