Curl - Your friend for Rest APIs/Calls - Basic Commands
Curl is a wonderful tool for initiate REST APIs or calls. Or, you can literally…
March 08, 2018
I have a custom content type, and there are around 2000 number of nodes in my website. In all the nodes, there was no alt attribute in the images. And, it was one of the major SEO disaster that I was facing.
I started updating them one by one. I updated around 10, and I thought of automating that. And, I did it.
$done=0; foreach ($result as $obj) { // I wanted to update 10 articles at once, just to avoid php timeout // Specially, when you have many nodes if ($done >= 10) { break; } $nd = node_load($obj->nid); if ( //field_image_of_drawing is the name of field in the content type $nd->field_image_of_drawing[‘und’][0][‘alt’] === null || $nd-> field_image_of_drawing[‘und’][0][‘alt’] === ” || !isset($nd-> field_image_of_drawing[‘und’][0][‘alt’]) ) { ++ $done;
//just printing node id
print $obj->nid . ', ';
$nd-> field_image_of_drawing['und'][0]['alt'] = $nd->title;
$nd-> field_image_of_drawing['und'][0]['title'] = $nd->title;
//updating the node
node_save($nd);
}
}
Curl is a wonderful tool for initiate REST APIs or calls. Or, you can literally…
Introduction In Azure, assuming you are having a storage container. And, you…
Introduction Assume you have a drupal website and using cloudflare. You are…
Introduction This post has the complete code to send email through smtp server…
Problem Statement I developed a simple ReactJS application where I have used…
Introduction You already have a content type with one or more fields in it…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…