Mapping With Drupal - Alan Palazzolo [50]
The Feature is now complete. At the bottom of the page, click the “Download feature” button. Extract the downloaded file to your site. This downloaded Feature is a special sort of module, and it is usually placed in a separate directory, such as in sites/all/modules/features or sites/default/modules/features, as shown in Figure 7-1.
Figure 7-1. Folder structure for features
The new Feature is disabled by default. At admin/structure/features on the Manage Features page, tick the checkbox next to the “User groups and events” Feature and click the “Save settings” button to enable the Feature.
All of the configuration for the Content Types, Views, and Maps for User Groups and Events are now stored in code. This code can be added to version control and moved between development and production sites. For more details on managing Features, see the Features handbook page.
Exporting GMap and Location with Features
As in the previous tutorial, some of the names or configurations might be different from what is shown below, depending on which of the tutorials you completed throughout the book. This Feature will contain the configuration for the Content Types and Views that we created to demonstrate GMap and Location in earlier chapters. This was based around Drupal Companies.
From the Manage features page, create a new Feature at admin/structure/features/create.
In the “Name” field, enter Drupal companies.
In the “Description” field, enter Configuration for Drupal companies.
In the “Edit components” drop-down, select “Content types: node”. In the list of content types, select “Drupal Company.”
In the “Edit components” drop-down, select “Permissions: user_permission.” In the very long list of permissions, find any that relate to the modules that are part of this feature:
GMap Macro Builder: Create gmap macro
Location: Submit latitude/longitude
Node: Drupal Company: Create new content
Node: Drupal Company: Edit own content
Node: Drupal Company: Edit any content
Node: Drupal Company: Delete own content
Node: Drupal Company: Delete any content
In the “Edit components” drop-down, select “Strongarm: variable.” In the very long list of variables, find any that relate to this feature. This is rather difficult for the Location module, because it creates a variable for every country in the world. Try to find the ones that relate to the countries you care about, though only the two-letter country codes tell you which is which:
gmap_default
gmap_marker_file
gmap_markermanager
gmap_mm_type
location_default_country
location_defaultnum_drupal_company
location_display_location
location_general_geocoders_in_use
location_geocode_google_minimum_accuracy
location_geocode_google_apikey
WARNING
Be careful about exporting the Google Maps API key to code. It only works for domains with the same URL. So if you have a development site at exampletest.com and a production environment at example.com, you will need a different API key for each.
location_geocode_au
location_geocode_ca
location_geocode_dk
location_geocode_es
location_geocode_fr
location_geocode_gb
location_geocode_jp
location_geocode_us
In the “Edit components” drop-down, select “Views: views_view.” In the list of Views, select “Drupal companies.” This is the View that was used to make the map for Location and GMap in Chapter 4.
The Feature is now complete. At the bottom of the page, click the “Download feature” button. Extract the downloaded file to your site and put it in the location where you put the Feature from the previous exercise.
The new Feature is disabled by default, so enable it on the Features page at admin/structure/features.
Exporting your map configuration to code may take a little time, but it will save time and effort in the long term. If you are new to web development, it is worth learning to use a version control system to