🇫🇷France @JulienVey

Account created on 25 February 2020, over 4 years ago
  • Developer at Gaya 
#

Recent comments

🇫🇷France JulienVey

I adapted the patch to match the latest version.

I have then made an hook_updb to initiate the string translations so that my client could find the strings by just searching 'Read more' and 'Show less'.

🇫🇷France JulienVey

The issue described in #11 is due to the module simple_sitemap overwritting the variant with the value of the form_state. Basically the node gets excluded in your hook_entity_presave() and then gets included again in the EntityFormHandler.php of the module.

#14 does the trick, but it means your node will be excluded two times : one in the EntityFormHandler.php and one in your hook_entity_presave().

One solution is to unset the value :)
The function of @phjou then becomes :

/**
 * Exclude from sitemap when there is a redirection.
 */
function mymodule_redirect_form_validate(&$form, FormStateInterface $form_state) {
    $entity = $form_state->getFormObject()->getEntity();

    if ($entity instanceof ContentEntityInterface && !$entity->isNew() && $entity->hasField('field_enable_redirect')) {
        // Exclusion will be processed in precreate function.
        // Clear the value so that it does not get overwritten by simple_sitemap module.
        if ($form_state->getValue('field_enable_redirect')['value']) {
            $form_state->unsetValue('field_enable_redirect')
        }
    }
}
🇫🇷France JulienVey

Indeed the #106 patch is already based on the one you linked @drupalevangelist.

Here's the one that does not need any pre-patch :)

Production build 0.71.5 2024