Firstly, apologies if I use some incorrect terminology - I'm still very much a Drupal newbie!
I'm creating a band website using Drupal 6 with CCK, Views, Date, Calendar, Link, Location and GMap. It has two content types of concern here - Gig and Venue.
The "Venue" content type has a Location field, which stores all the address information. It also has some other fields, for example "Venue Website" (field_venue_website).
I want an autocomplete field on the "Create Gig" page to look up an existing venue from the "Venue" content type and display the venues in an autocomplete drop-down list in the following format:
[Location name], [City], [Country]
However, I want to extract more information to be available on the Gig page, preferably like this:
[Location name] <-- preferably as a link to the venue's page [Street] [Additional] [City] [State/Province] [Postal code] [Country] [Venue Website] <-- remember this is a separate field, not from the location field.
I have partially reached my goal, by doing the following:
- Created a "Venue" field (field_gig_venue) of type Node reference.
- Set up the field as follows:
- Autocomplete matching: Contains
- Size of textfield: 100
- Required: Off (may change this later)
- Number of values: 1
- View used to select the nodes: venue_search
- Created a View (venue_search) with the following settings:
- Row style: Fields
- Inline fields:
- Location: Name
- Location: City
- Location: Country
- Separator: ,
- Hide empty fields: Yes
- Relationships:
- Content: Venue
- Fields:
- Location: Name
- Location: City
- Location: Country
- Node: Title (Exclude from display: Yes)
- Filters:
- Node: Type = Venue
This results in the autocomplete drop-down list displaying as I required. When submitted, the result is [Location name] as a link to the Venue's page.
However, I find that the only part of the venue recognised by the autocomplete is [Location name]. For example, if I have two venues as follows:
Kentish Town Forum, London, UK
Tunbridge Wells Forum, Kent, UK
When I start typing "forum", I'll get a drop-down suggestion list that looks like the above. Great! However, if I type "UK" or "London", I get nothing.
If it helps, here is the query generated when I preview the View:
SELECT node.nid AS nid,
location.name AS location_name,
location.city AS location_city,
location.country AS location_country,
node.title AS node_title
FROM drupal_node node
LEFT JOIN drupal_content_type_gig node_data_field_gig_venue ON node.vid = node_data_field_gig_venue.vid
LEFT JOIN drupal_node node_node_data_field_gig_venue ON node_data_field_gig_venue.field_gig_venue_nid = node_node_data_field_gig_venue.nid
LEFT JOIN drupal_location_instance location_instance ON node.vid = location_instance.vid
LEFT JOIN drupal_location location ON location_instance.lid = location.lid
WHERE node.type in ('venue')
Here are my questions:
- How do it get it so that the autocomplete will work for the City or Country, too?
- What is the best way to get the output that I require on the final page (i.e. an address block)? I assume that I can add the other relevant fields and exclude them from display in the View, and they'll be available to use. How should I best use them, though? A single field with the data pre-formatted? A field for each value?
- How do I then get the data collected from the View into the field(s)?
Any help would be greatly appreciated! Thanks in advance!
[EDIT]
As mentioned below, I have discovered that what is happening is this:
The autocomplete field takes the text entered and looks to see what node titles in the "Venue" content type match this text. It then displays the results using my View to format them. Here is a picture to illustrate:
Why is it ignoring my view when checking the entered text, instead checking against node titles?