Hi, and thanks for your great module. I know this is not your issue but I really need support here.
I need to customize my H1 in some pages that generated by Views module. I found out that meta abstract is not really useful with current search engine and I decide to use it on page.
I put those code in template.php:
function mytheme_preprocess_page(&$variables) {
// Get the abstract meta tag to use in mytheme_preprocess_region and transfer it to region--preface_first.tpl.php to use as h1 title
if (array_key_exists('global', $variables['page']['content']['content']['content']['metatags'])){
if (array_key_exists('abstract', $variables['page']['content']['content']['content']['metatags']['global'])){
global $my_h1;
$my_h1 = $variables['page']['content']['content']['content']['metatags']['global']['abstract']['#attached']['drupal_add_html_head'][0][0]['#value'];
}
}
}
function mytheme_preprocess_region(&$variables) {
global $my_h1;
if (isset($my_h1)){
$variables['metatag_abstract'] = $my_h1;
}
}
and in my region--preface_first.tpl.php file:
if (isset($metatag_abstract)){
echo '<h1 class="title" id="page-title">'.$metatag_abstract.'</h1>';
}
Shame on me. I'm a designer, not a developer so my code looks very ugly. And it not work all the times. Sometime, the ['abstract'] isn't in ['global'], it's in [taxonomy_term:my_taxonomy_term_name] and I just don't know how to make it work in all cases.
Help me please.
(And I think use Abstract for the H1 tag is a good idea!)
Comments
Comment #1
DamienMcKennaWhat types of pages are these? Taxonomy term pages or custom Views pages? Where is the abstract value being set?
Comment #2
nlhnam CreditAttribution: nlhnam commentedThis is a view for taxonomy term. And the abstract was set by the Metatag module, with "By path" method.
Sorry if not provide enough information.