Drupal

Drupal 8 Workflow Notifications with Rules Part 3

March 6, 2018
Web Development
Drupal, drupal8, Rules, Workflow

In previous posts I’ve covered enabling and editing a Workflow and then sending an email when a new content moderation state has been saved. In this post we will complete the loop by sending emails when a content moderation state has been updated. In this example an editor will publish the node and the rule will email the node creator to tell them it has been published. Head to the Rules admin page /admin/config/workflow/rules and click Add reaction rule ...

Changing the Default Content Moderation State in Drupal 8

February 27, 2018
Web Development
Drupal, drupal8

I have been working with the Content Moderation module in Drupal 8 and one slight niggle we came across was the default option for the Moderation state. If the current state was In Review we would like the Change to option to also be In Review rather than Draft. This means the default is to keep the entity in it’s current state rather than switching to a new state. ...

Drupal 8 Workflow Notifications with Rules Part 2

February 20, 2018
Web Development
Drupal, drupal8, Rules, Workflow

In my previous post I talked through setting up Content Moderation with a review state. In this post we will complete the process by sending email notifications via the Rules module when the moderation state is changed. Install Rules # To enable the Rules module we first need to require it via Composer. Run the following from the command line in the root of your project composer require drupal/rules ...

Drupal 8 Workflow Notifications with Rules Part 1

February 13, 2018
Web Development
Drupal, drupal8, Rules, Workflow

For Drupal projects I’ve always used the comprehensive suite of tools provided by Workbench. But when I started a new project and saw that Workflow is hopefully making it’s way into core it felt like a good time to try it out. One part of the project was the addition of notifications when Workflow states were changed. With the Rules module also receiving lots of attention I decided combining the two modules was the best approach. ...

Drupal 7 Views Sort by Two Date Fields

October 31, 2017
Web Development
Drupal

To achieve this you will need to implement hook_views_query_alter() in a custom module. I did not do this in Views UI. A recent project at Headscape required me to build view listing two different content types that would use two different date fields to sort by. For examples I’ll use the default basic page and article content types. The Problem # Some content types need to be sorted on the node created date and others on the display date field. ...

Stepping back to move forward with ReactJS

October 20, 2017
Web Development
decoupled drupal, Drupal, ReactJS

I’ve been using ReactJS as I have been exploring Headless / Decoupled Drupal and have so far found it to be very nice to work with. However, as I am not overly familar with it I’ve found myself looking up lots of things to ensure I’m doing it “the React way”. This has meant I’ve been doing more React learning than I have Drupal learning. My solution is to go back to an existing Drupal 7 project where I have a custom piece of search functionality and replicate it using JSON feeds provided by Drupal and a ReactJS frontend. ...

Drupal 6 num_rows

March 7, 2010
Uncategorized
Database, Drupal, Web Development

I’ve been working on a site powered by Drupal and needed to find the number of rows a database query returned. Simple enough and quite common procedure. But, the Drupal database API no longer offers the db_num_rows() function. I had a quick Google around and the answered seemed to be to run the query twice but the second time using a count query. Two calls to the database when only one is necessary? ...