diff --git metatags_quick/known_tags.inc metatags_quick/known_tags.inc index 8d8dbee..e83c918 100644 --- metatags_quick/known_tags.inc +++ metatags_quick/known_tags.inc @@ -54,5 +54,13 @@ function _metatags_quick_known_fields() { 'title' => t('Robots'), 'options' => 'noarchive,nofollow,noindex,noodp,nosnippet,noydir', ), - ); -} \ No newline at end of file + // Using 'title' as the key messes up the admin. + 'meta_title' => array( + 'meta_name' => 'title', + 'type' => 'meta_contents', + 'widget' => 'metatags_quick_textfield', + 'title' => t('Title'), + 'description' => t('Custom title.'), + ), + ); +} diff --git metatags_quick/metatags_quick.module metatags_quick/metatags_quick.module index 54d5621..58880fa 100644 --- metatags_quick/metatags_quick.module +++ metatags_quick/metatags_quick.module @@ -316,6 +316,10 @@ function metatags_quick_field_formatter_info() { 'description' => t('Provide the content as plain text.'), 'field types' => array('metatags_quick'), ), + 'metatags_quick_title' => array( + 'label' => t('Set page title'), + 'field types' => array('metatags_quick'), + ), 'metatags_quick_default' => array( 'label' => t('Default metatags_quick formatter'), 'description' => t('Add meta to html head.'), @@ -347,6 +351,19 @@ function metatags_quick_field_formatter_view($object_type, $object, $field, $ins $element[$delta] = array('#markup' => $item['metatags_quick']); } break; + case 'metatags_quick_title': + // In case we get a multiple field, we concat the values with ' - ', just + // to have some sane handling. + $title = array(); + foreach ($items as $delta => $item) { + $title[] = $item['metatags_quick']; + } + if (!empty($title)) { + drupal_set_title(join(' - ', $title)); + } + // Hide element. + $element = array('#markup' => '', '#printed' => TRUE); + break; case 'metatags_quick_default': foreach ($items as $delta => $item) { _metatags_quick_add_head(array( @@ -531,6 +548,13 @@ function _metatags_quick_add_head($item = FALSE) { 'content' => $item['content'])); drupal_add_html_head($element, 'metatags_quick_' . $item['name']); } + if ($item['name'] == 'title') { + $element = array( + '#tag' => 'title', + '#value' => $item['content'], + ); + drupal_add_html_head($element, 'metatags_quick_' . $item['name']); + } } $added_meta[$item['name']] = TRUE; }