Tam*_*lei 2 php drupal drupal-7 drupal-themes drupal-theming
我想在drupal中呈现"基本页面"的内容.像这样的问题:显示一个没有页面模板的Drupal视图,但是对于Drupal 7.
我的尝试几乎奏效:
function mytheme_preprocess_page(&$variables, $hook) {
if ( isset($_GET['ajax']) && $_GET['ajax'] == 1 ) {
$variables['theme_hook_suggestions'][] = 'page__ajax';
}
}
Run Code Online (Sandbox Code Playgroud)
并且page--ajax.tpl.php在template.php所在的同一目录中有一个文件:
<?php print $page['content']; ?>
Run Code Online (Sandbox Code Playgroud)
问题是它仍然从侧边栏呈现菜单和我的两个自定义块.我只想要页面内容.我应该改变什么?
小智 6
你快到了.您唯一需要的是添加自定义HTML包装器模板.
template.php:function THEMENAME_preprocess_html(&$variables, $hook) {
if ( isset($_GET['ajax']) && $_GET['ajax'] == 1 ) {
$variables['theme_hook_suggestions'][] = 'html__ajax';
}
}
Run Code Online (Sandbox Code Playgroud)
html--ajax.tpl.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">`
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php print $styles; ?>
<?php print $scripts; ?>
</head>
<body class="<?php print $classes; ?>">
<?php print $page_top; ?>
<?php print $page; ?>
<?php print $page_bottom; ?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)