Drupal SEO页面标题


Drupal SEO page titles

我试图在各个页面上列出一些游戏。当游戏页面被打开到新窗口中时,页面(< title>)的标题被设置为游戏页面标题(< h1> My game)。同时列出我正在使用的所有游戏类型的快速标签。

从12种类型的游戏中,只有2种游戏的冠军是正确的,我的问题是我不知道它是从哪里来的。我试着var_dump()所有的标题,所有的标题都返回了相同的东西"游戏",而不是数据库的标题/标题。

我应该去哪里看,或者下一步该怎么做?

$metaTitle = $page['content']['metatags']['global']['title']['#attached']['metatag_set_preprocess_variable'][0][2];
$metaTitle = str_replace(' | SuperCasino.com', '', $metaTitle); 

我应该去哪里看,或者下一步该怎么做?

这是我的预处理页面代码

function desktop_preprocess_page(&$vars, $hook) {
    if (isset($vars['node_title'])) {
        $vars['title'] = $vars['node_title'];
    }
    // Adding a class to #page in wireframe mode
    if (theme_get_setting('wireframe_mode')) {
        $vars['classes_array'][] = 'wireframe-mode';
    }
    // Adding classes wether #navigation is here or not
    if (!empty($vars['main_menu']) or !empty($vars['sub_menu'])) {
        $vars['classes_array'][] = 'with-navigation';
    }
    if (!empty($vars['secondary_menu'])) {
        $vars['classes_array'][] = 'with-subnav';
    }
    // Page template suggestions based off of content types
    if (isset($vars['theme_hook_suggestions']['node'])) {
        $vars['theme_hook_suggestions'][] = 'page__type__'. $vars['node']->type;
        $vars['theme_hook_suggestions'][] = "page__node__" . $vars['node']->nid;
    }
    // Add first/last classes to node listings about to be rendered.
    if (isset($vars['page']['content']['system_main']['nodes'])) {
        // All nids about to be loaded (without the #sorted attribute).
        $nids = element_children($vars['page']['content']['system_main']['nodes']);
        // Only add first/last classes if there is more than 1 node being rendered.
        if (count($nids) > 1) {
            $first_nid = reset($nids);
            $last_nid = end($nids);
            $first_node = $vars['page']['content']['system_main']['nodes'][$first_nid]['#node'];
            $first_node->classes_array = array('first');
            $last_node = $vars['page']['content']['system_main']['nodes'][$last_nid]['#node'];
            $last_node->classes_array = array('last');
        }
    }
    //var_dump($vars['theme_hook_suggestions']);die();
   // Page template suggestions based off URL alias
    if (module_exists('path')) {
        //$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
        $alias = request_path();
        if ($alias != $_GET['q']) {
            //echo'here';die;
            $template_filename = 'page';
            foreach (explode('/', $alias) as $path_part) {
                $template_filename = $template_filename . '__' . str_replace('-','_',$path_part);
                $vars['theme_hook_suggestions'][] = $template_filename;
                //var_dump($template_filename);
            } 
        }
    }

您可以对不同的页面使用drupal_set_title(YOUR_title)。

    drupal_set_title($title = NULL, $output = CHECK_PLAIN)

https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_set_title/7 引导

从主题级别,您可以在模板中使用此代码。php:

function MYTHEMENAME_preprocess_page(&$vars, $hook) {
    $vars['title'] = $custom_title';
    $vars['head_title'] = $custom_title;
}

对于Drupal 7,它是:$vars['site_name']