From 6a5e7aed6a546f5bd9aafbfa66f128dee8e76426 Mon Sep 17 00:00:00 2001 From: Anuprita Kulkarni <a5kulkar@uwaterloo.ca> Date: Wed, 24 Aug 2022 14:20:40 -0400 Subject: [PATCH] ISTWCMS-5705 Prevent webforms themselves from being indexed --- uw_cfg_common.module | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/uw_cfg_common.module b/uw_cfg_common.module index 987b0384..fb1c0f1b 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -1309,3 +1309,21 @@ function uw_cfg_common_fillpdf_form_form_pre_form_build_alter(FillPdfFormForm $f $fillpdf_form->set('default_entity_type', 'webform')->save(); } } + +/** + * Implements template_preprocess_html(). + */ +function uw_cfg_common_preprocess_html(&$variables): void { + // Setting the meta tag for web forms getting indexed + // if not used any content. + if (!isset($variables['node_type']) || $variables['node_type'] == NULL) { + $noindex = [ + '#tag' => 'meta', + '#attributes' => [ + 'name' => 'robots', + 'content' => 'noindex', + ], + ]; + $variables['page']['#attached']['html_head'][] = [$noindex, 'noindex']; + } +} -- GitLab