I installed and configured Get Directions (7.x-3.1) on an existing site and it works great with one exception. On the content types I have used the Get Directions Field, the link does not appear unless I edit the content and resave it. I don't need to make any real edits, just open it and save it. I have tried updating all the content using Views Bulk Operations to save the content again, but that does not do anything. Each node has to be saved manually. I have hundreds of nodes that need this field so am wondering if there is a way to trigger the Get Directions field to populate without manually updating each node.

CommentFileSizeAuthor
#2 getdirections_fields_vbo_2248269_1.patch8.31 KBhutch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DSquaredB’s picture

Component: Code » Miscellaneous
hutch’s picture

Please try the attached patch, on current dev of Getdirections version 7.x-3.x

This patch adds "VBO awareness" to Getdirections_fields.

Once the patch is in you should go to the field settings of the content type you are using and check the 'Use a textfield' checkbox.
Then create a new view and include a field Bulk operations: Content, then configure this field to use "Modify entity values" and select "Directions" (or whatever you named it) from the list of the content type you are using under Selected Bulk Operations > Operation settings > Display Values.
You should also add the Field "Getlocations Fields: Field name" so that you will know what to paste into the textfield(s) when you run the vbo page which you created in the view. I could not get tokens to work at all.

Make sure you backup your work first!

This method may still not meet your needs though as it still requires you to add the field but does speed the process up.

To completely automate the update process would require a bespoke module which loaded each node, added the required field and saved the node, thus creating the entry in the table for getdirections_fields, doable but requires PHP coding skills. Written as a CLI script would avoid PHP timeouts, otherwise you would have to use Drupal batch methods.

DSquaredB’s picture

Thanks for the quick response. I've been tied up on a couple of other issues and haven't had a chance to test the patch, yet, but will try to do it in the next day or two so I can get this pushed to my live site. Really appreciate your help.

hutch’s picture

I retested the patch on a fresh install, the version I initially tried it on already had fields entered and I had apparently not removed them properly. On the fresh install the location field was picked from the default settings and was applied to all the listed nodes using vbo, I did not have to copy-and-paste at all, it just worked!
When done remember to untick the "Use textfield" option.

DSquaredB’s picture

Thanks for the patch. It worked great to update all my content. No problems I can see.

hutch’s picture

Thanks for testing this, I'll be adding this in the next round of commits, also to getlocations_map and getlocations_leaflet, both part of the Getlocations module.

DSquaredB’s picture

Not sure if this is a result of updating content with the patch or another issue:

My content has an adressfield adress with a geofileld. But because I have a number of rural locations, I have added an alt_geofield for manual input of lat/long. The Addressfield is geocoded into the geofield and if the alt_geofield is empty, a Rule copies the geo lat/long into alt_geo. I added the getlocations_field to my content types and set the location input to alt_geofield. Then I ran the vbo update with the patch. Now, if you click on the GetDirections link from the content, the marker on the map looks correct with the alt_geo coordinates even in cases where the Addressfield geofield is incorrect and has been overridden. In other words, the map seems to display the marker based on alt_geofield as I want it to. But when you click to get directions, the directions use the Addressfield or the geofield for Addressfield instead - which is not what I need and is definitely confusing. Any ideas why the module is using one geofield for the marker and the other in the directions?

hutch’s picture

You appear to have made some bespoke arrangements to provide the lat/lon which Geofield won't let you edit and if you want Getdirections to use those bespoke arrangements you will have to tell it about them, or rearrange how you alter Geofield so other modules can find things.
The Geofield module's inability to allow users to override geocoded addresses which tend to be inaccurate in rural areas is one of the reasons I developed the Getlocations_fields submodule, which does let you modify the location, either by dragging a marker on a map or by typing in the decimal degrees or by using geocoding (or gps geolocation if relevant and enabled) and does so before it is submitted so you get what you asked for.