Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
38bec013
Commit
38bec013
authored
4 years ago
by
Eric Bremner
Committed by
Kevin Paxman
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-4104: adding form alter to hide elements in metatags
parent
b9af3745
No related branches found
No related tags found
1 merge request
!56
ISTWCMS-4104: adding defaults for metatags
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_cfg_common.module
+30
-0
30 additions, 0 deletions
uw_cfg_common.module
with
30 additions
and
0 deletions
uw_cfg_common.module
+
30
−
0
View file @
38bec013
...
...
@@ -370,3 +370,33 @@ function uw_cfg_common_form_menu_link_edit_alter(array &$form, FormStateInterfac
// Do not allow the home page to be parent of any item.
unset
(
$form
[
'menu_parent'
][
'#options'
][
'main:uw_base_profile.front_page'
]);
}
/**
* Implements hook_form_alter().
*
* Hide/disable metatag information on our nodes.
*/
function
uw_cfg_common_form_alter
(
array
&
$form
,
FormStateInterface
$form_state
,
string
$form_id
):
void
{
// Ensure that we are on a UW content type node.
if
(
preg_match
(
'/node_uw.*add_form/'
,
$form_id
)
||
preg_match
(
'/node_uw.*edit_form/'
,
$form_id
))
{
// Ensure that the node has metatag information.
if
(
isset
(
$form
[
'field_uw_meta_tags'
]))
{
// Hide elements under advanced settings.
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'advanced'
][
'canonical_url'
][
'#access'
]
=
FALSE
;
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'advanced'
][
'shortlink_url'
][
'#access'
]
=
FALSE
;
// Hide elements under open graph.
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'open_graph'
][
'og_type'
][
'#access'
]
=
FALSE
;
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'open_graph'
][
'og_url'
][
'#access'
]
=
FALSE
;
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'open_graph'
][
'og_updated_time'
][
'#access'
]
=
FALSE
;
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'open_graph'
][
'og_locale'
][
'#access'
]
=
FALSE
;
// Hide elements under Twitter settings.
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'twitter_cards'
][
'twitter_cards_page_url'
][
'#access'
]
=
FALSE
;
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'twitter_cards'
][
'twitter_cards_page_url'
][
'#access'
]
=
FALSE
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment