drupal 7 设置SEO函数
drupal 7 设置SEO主要利用drupal_add_html_head和drupal_set_title两个函数
/**
* set seo
* $data = array('title' => ,'keywords' =>, 'description' => );
*
*/
function set_seo($data = array()) {
if($data['description']) {
$meta_description = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'description',
'content' => $data['description'],
)
);
drupal_add_html_head($meta_description,'meta_description');
}
if($data['keywords']) {
$meta_keywords = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'keywords',
'content' => $data['keywords'],
)
);
drupal_add_html_head($meta_keywords,'meta_keywords');
}
if($data['title']) {
drupal_set_title($data['title']);
}
}
* set seo
* $data = array('title' => ,'keywords' =>, 'description' => );
*
*/
function set_seo($data = array()) {
if($data['description']) {
$meta_description = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'description',
'content' => $data['description'],
)
);
drupal_add_html_head($meta_description,'meta_description');
}
if($data['keywords']) {
$meta_keywords = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'keywords',
'content' => $data['keywords'],
)
);
drupal_add_html_head($meta_keywords,'meta_keywords');
}
if($data['title']) {
drupal_set_title($data['title']);
}
}