Multi-lingual Content Moderation

I am facing issue with Multi-lingual Content Moderation.

Problem Statement
I have two languages (say, English(default) and French(secondary)). I want to

  • Explore options to create / review / approve / publish English content(/en/test) as it’s own workflow
  • Explore options to create / review / approve /publish French content(/en/test) as it’s own workflow
  • There should be no dependency between English moderation flow and French moderation flow.

  • After published If there’s any modification needed in the content, The content can be again send back. But the Anonymous users will be seeing the last published version of the page until the modified page is again published.

Points to consider:

Reviewer has the permission to only view a page if it is in Review state. And this is an important step.

Things that I have tried:

1. Workflow condition: When only Published is set as Default Revision

  • Any one language is working properly. But when there is a translation and one of the language(say en) is published, even though when we change the moderation state of the other node(fr), the current revision status is still sitting on the last published revision of the node regardless of the language and the moderation state of the latter(fr) is staying on draft as database isn’t getting updated (even though we changed it to review or approved). As a result the Reviewer is not able to view the translated page(fr/test).(Since the fr is still in draft).But since a revision is available , the reviewer has to go the particular revision and view the page(/fr/node/$node_id/latest) . This is not desired .Reviewer should not be bothered with the node id.

2. Workflow condition: When only Review and Approved both are set as Default Revision

  • Both the languages are now independent. Both can be published individually. But changing the any of the revision back to Review or Approved to modify the existing page content is making the page completely unpublished. As a result Anonymous User isn’t anymore able to see the page.

3. Tried to write a hook_entity_update that shall update the content_moderation_state_field_data

function sync_revision_node_update(EntityInterface $entity) {   $entity_type = $entity->getEntityTypeId();   dpm("entity type=" . $entity_type);    if ($entity_type == "node") {      $entity_id = $entity->id();      $vid = Drupal::entityTypeManager()       ->getStorage('node')       ->getLatestRevisionId($entity_id);         $langcode = $entity->get('langcode')->value;      $moderationState = $entity->moderation_state->value;     if ($moderationState != "published") {        $table = 'content_moderation_state_field_data';       $query = Drupal::database()->update($table)->fields(array(         'moderation_state' => $moderationState,         'content_entity_revision_id' => $vid,       ))->condition('content_entity_id', $entity_id)         ->condition('langcode', $langcode)->execute();     }   } } 

This is updating the ‘content_moderation_state_field_data’ table but the /fr/test page is still not in review. It is still staying in draft. The reviewer has to go the latest revision and view the page(/fr/node/$node_id/latest) . But this isn’t desired. The reviewer shouldn’t bother about the node id.

4. Tried to write a preprocess hook that shall redirect to the latest revision

function sync_revision_preprocess_page(&$variables) {   $node = Drupal::routeMatch()->getParameter('node');   if ($node instanceof DrupalnodeNodeInterface) {     $nid = $node->id();     $vid = Drupal::entityTypeManager()     ->getStorage('node')     ->getLatestRevisionId($nid);           $moderationState = $node->moderation_state->value;          $langcode = $node->get('langcode')->value;             $url = $_SERVER['REQUEST_URI'];       if ($moderationState != "published" && strpos($url,'latest') == false) {        $path = "/" . $langcode . "/" . "node/" . $nid . "/" . "latest" ;         $response = new RedirectResponse($path);        $response->send();       }   } } 

This not working properly as expected. The /fr/test is first getting a 403 Access Denied and hence the redirect is not working.

Please suggest a better working approach to fit in all these criteria .I will be grateful.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Multi-lingual Content Moderation

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.