Skip to content
AtlanticBT Monogram

Followup – How to Bulk Anything in Drupal without a Module

Following up on my previous post about bulk deleting filtered aliases, I found that I needed to force all the taxonomy terms to check the “automatically generate url” checkbox.

Therefore, I modified the previous script to a more generic format so we can reuse the same method for just about any bulk update process in Drupal.  Supply your own callbacks for any two-step form:

drupalBulkDo = function(options){
var defaults = {
selector: ‘#selector’
, context: ‘#content’
, secondStep: ‘#the-second-step’
, onSecondStep: function($theform, $theaction){
// now "submit" the form
$.post( $theform.attr(‘action’), $theform.serialize(), function(){
console.log( ‘performed ‘ + $theaction.attr(‘href’) );
}); // submit (post)
options = $.extend({}, defaults, options);

$items = $(options.selector, options.context);

// loop delete links
// jquery
var $theaction = $(o);

// "click" action link (i.e. "delete")
$.get( $theaction.attr(‘href’), function(data){
// get form for second step
var $theform = $(data).find( options.secondStep );

// do stuff for second step (i.e. fire delete link)
options.onSecondStep($theform, $theaction, defaults.onSecondStep); // pass the original callback, in case we want to reuse it
}); // click (get)
}); // each

};//– fn drupalBulkDo

Now, from /admin/structure/taxonomy/MYVOCABULARY, we can bulk update multiple terms to use the “autogenerate url” checkbox. Note how the callback not only updates the checkbox in the form, but also reuses the default callback to post the form.
[javascript highlight=”7,8,9″]
// update url path alias settings to "automatic" for taxonomy
selector: ‘a[id$=-edit]’
, context: ‘#taxonomy’
, secondStep: ‘#taxonomy-form-term’
, onSecondStep: function($theform, $theaction, originalCb){
$theform.find(‘#edit-path-pathauto’).attr(‘checked’, ‘checked’);
originalCb($theform, $theaction);

For reference, the original method for bulk deleting filtered aliases becomes:
selector: ‘li.delete a’
, secondStep: ‘#path-admin-delete-confirm’

capabilities covered
Amazon Web Services

The Atlantic BT Manifesto

The Ultimate Guide To Planning A Complex Web Project


Atlantic BT's Insights

We’re sharing the latest concepts in tech, design, and software development. Learn more about our findings.

Questions & Answers

Are there differences in application architecture that are important for the cloud?
It is important to build applications and workloads specifically for the cloud. You will want to carefully consider what services the cloud provider of your choice has to offer and how your application leverages those services.
Learn More
Are there any drawbacks to cloud hosting?
Yes, there will always be some risks associated with any hosting option. You are relying on the resiliency and engineering of infrastructure that has scaled at an astounding rate.
Learn More
What’s the benefit of hosting in the cloud vs. traditional options?
Reasons not to host in the cloud are few and far between. If you don't host in the cloud, you will spend more in both CapEx and OpEx to manage your applications or websites in a traditional environment.
Learn More
How can I improve the performance of my application?
There are several primary reasons that applications perform poorly, and in some cases it’s a combination of several. 1) Data latency: If your application is making calls to a data source (whether it’s an API or a direct call) and there is latency at the data provider, your application performance will suffer.
Learn More
Should I move my application to the cloud?
The answer is ‘probably yes’. There aren’t many reasons for an application to be hosted elsewhere, aside from occasional compliance standards, or requirements to integrate with local services that would require large amounts of data to move from on-premise to cloud.
Learn More
Where should my application be hosted?
There are many different options for hosting, but most applications would do well with one of the cloud providers -- Amazon Web Services, Google Cloud Platform, Microsoft Azure.
Learn More