我试图在各个页面上列出几个游戏。当游戏页面打开到新窗口时,页面标题(< title>
)被设置为游戏页面标题(< h1>
我的游戏)。还要列出我正在使用快速标签的所有游戏类型。
从12种类型的游戏中,只有2种游戏的标题得到了正确的解决,我的问题是我不知道它来自哪里。我已经尝试var_dump()
所有标题,并且所有标题都返回相同的“游戏”而不是db的标题/标题。
我应该在哪里查看或下一步是什么?
$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);
}
}
}
答案 0 :(得分:1)
您可以将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
从主题级别,您可以在template.php中使用此代码:
function MYTHEMENAME_preprocess_page(&$vars, $hook) {
$vars['title'] = $custom_title';
$vars['head_title'] = $custom_title;
}
对于Drupal 7,它是: $瓦尔[ 'SITE_NAME']