We
might face a requirement where we need to place the meta data for a
page dynamically based on user activity. For eg., search pages.
We can use drupal_add_html_head to add meta data for a page.
$pageKeywords = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'keywords',
'content' => 'custom meta keywords',
)
);
$pageDescription = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'description',
'content' => 'custom meta description',
)
);
$pageTitle = 'page title';
drupal_add_html_head($pageKeywords, 'page_keywords');
drupal_add_html_head($pageDescription, 'page_description');
drupal_set_title($pageTitle);
No comments:
Post a Comment
Your comment is so valuable as it would help me in my growth of knowledge.