Skip to content

Instantly share code, notes, and snippets.

@jrbeeman
Created March 24, 2012 17:20
Show Gist options
  • Save jrbeeman/2185270 to your computer and use it in GitHub Desktop.
Save jrbeeman/2185270 to your computer and use it in GitHub Desktop.
Don't allow token reference with metatag module to destroy node/add pages
<?php
/**
* Implements hook_form_alter().
*/
function hook_form_alter(&$form, &$form_state, $form_id) {
// Deny access to view Metatag tokens if token memory consumption is out of
// control. In one site build, this trimmed ~40mb off of memory required to
// render the node/add page for a custom article page and took the total HTML
// payload on another content type's node/add page from 7.18mb to 43.68kb.
if (!empty($form['#node_edit_form']) && !empty($form['metatags'])) {
$form['metatags']['tokens']['#access'] = FALSE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment