This howto will help you create a simple method for your clients to add locative information to a travelogue. I've been fiddling with a lot of options for doing this, including using feeds with gmap macros. Though gmap macro feeds have the advantage of offering specific marker types for the different feeds, I ended up using a method which does away with that feature, but gains tremendously in usability, due to the fact that the writer doesn't need to know the exact feed syntax and gmap macro syntax to make it work.
For this howto you will need the following modules:
- The module needed for adding a location to a node.
- The gmap module includes the "Gmap location" module which lets you select the location used by the location module via a map.
- Gmap addons
- A module which contains the Gmap CCK field. The gmap_cck_field can use a nodereference field in the same node type as the gmap_cck_field itself is part of.
- Content Creation Toolkit
- A module which lets you create your own node types, very versatile, there are lots of tutorials on most aspects of this module available. Do a few searches.
- Node Relativity
- You will need this to create parent child relationships between nodes.
- A module which lets you reference a view from a field in a CCK node
After downloading, installing, setting up permissions, configuring default settings and otherwise following the instructions included in the above modules you do the following. Some of the modules above might depend on other modules. You will have to download them if there are any listed as
If I anywhere skip any parts of an input form it means I don't care about those settings and it is up to you to decide what fits best for your site.
First you create a new node type (/admin/content/types/add) "Point". A point will be the nodes which can contain a latitude longitude for use in location. Almost at the top of the page, just under page title, you will find a collapsed field called "Locative information". Click on that field and change both the "Maximum number of locations allowed for this type.:" and "Default number of location forms:" to 1. Then select "Do not collect..." in all of the radio groups below, they are labeled "Location names:", "Street locations:", "City names:", "State/Province names:" and "Postal codes:". These fields will just clutter your input form and for most locations around the world they wont work out of the box. Leave the "Country names:" as is.
Give the datatype a "Name" (Point) and a "Type" (point_via).
Save the node type by pressing "Save content type".
Now you need to create two more node types, they will use exactly the same settings as the above, except the names will be "Start Point" and "End Point", and their type names will be "point_start" and "point_end".
Creating these three different node types will allow you to set different markers in the gmap_addons module for the different node types. Thus we can have a green marker for the start node, a blue marker for the end node and all the point in between can have the route marker.
To configure this go to "/admin/settings/gmap_location" and scroll down to the "Markers per content type" group at the bottom. Select the correct markers for each of the three recently created data types.
Then make a new node type. We will call this "Travelogue". In this node you do not change anything in the "Locative information" field set. Give it its name and type. Then press "Save content type".
The next step is to create the node relationships in the "Node Relativity" module. Go to "/admin/settings/relativity" and into the "Global Options" group. Select the four data types we've created and "Save Configuration".
When the page reloads you will have four collapsed groups, for the points select "Any" for the "Parental Ordinality" and "none" for the "Allowable Child Node types".
For Travelogue you select the three point types for "Allowable Child Node types".
Now you need to set the advanced settings of the "Node relativity"-module (http://samipath.kulturarkitektene.no/admin/settings/relativity/advanced). In the "Options for Travelogue (travelogue) nodes" group you set the following:
End Point Child Ordinality for Travelogue Parents:
Point Child Ordinality for Travelogue Parents:
Start point Child Ordinality for Travelogue Parents:
Thus every Travelogue will be allowed to have one start point, one end point, and as many points as you would like inbetween.
Now you can create a new Travelogue (/node/add/travelogue). Just fill it out with some random content. After posting it the "Node Relativity" module will have added a group called "Link Operations". You will be able to exist existing points, or create new ones.
Go ahead and create a "Stat point" by clicking "Create new Start Point".
Select a location and name for that point, and return to the Travelogue after saving the node.
Notice that you no longer have the option to create a new Start Point, only Point and End Point is available. You will also see that you can Remove Start Point, if you want to.
Add an End Point and a few Points.
Take a note of the Travelogue node id. In my system it is 1, since it is the first node I made on a blank system.
Next step is to create a view for showing the points on a map. Go to /admin/build/views/add to start creating the relevant view.
I called mine "children_locations" Then I opened the "Page"-group and checked the "Provide Page View" check box.
The "URL" I called "children/$arg". Arg will be used to select the parent node id of whoose children we're interested in.
Select "Gmap View" from the "View Type:". Give the view a "Title", I called mine "View all children of a node".
Uncheck the "Use Pager"-checkbox. Set "Nodes per Page" to "0".
Go to the "Fields"-group and add at least "Node: Title", "Location: Latitude" and "Location: Longitude". I also added "Node: Body" and "Node: Link to node".
That's the data which will be shown when popping up info about the markers on the map.
The final step is to add an argument. Open the "Arguments"-group and add an argument of the type "Relativity: Parent Node ID".
Save the view and go to "/children/1" (use the Node ID number of the travelogue item you made earlier) to verify that you get up a map with the node types you made. You will see three different marker types, the green, the blue and the route, which is green with a "play" icon.
The next step is to add the view into the travelogue node. We need to add the "viewfield" to the data type. Go to "/admin/content/types/travelogue/add_field" to start adding a field.
Select "View field->Select List" and give the field a "Name". I called mine "map_view".
Give the field a "Label". I called mine "Map". Select the "Force default" checkbox in order to stop users from being able to change the argument, which we will input at the bottom of the page. In the "Data settings"-group, select Required. Choose our view "children_locations" from the select list at the bottom of the page and enter "%nid" as the argument, then press "Save field settings".
Now we need to set the display settings, so go to the "Display fields" tab "/admin/content/types/travelogue/display". Select "Label"="", "Teaser"="" and "Full"="Gmap view".
Go to the travelogue we made earlier and see that there is a map inside the node.
More work is needed, first and foremost the popups when clicking the markers needs to have a better layout, but that's just icing on the cake.
Apart from that I think this is the easiest way for non-drupal experts to enter the nodes, as the "Node relativity" functionality will create almost a "step-by-step"-process.