显示没有页面模板的Drupal视图 [英] displaying a Drupal view without a page template around it

查看:138
本文介绍了显示没有页面模板的Drupal视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个Drupal视图,而没有通常包围它的页面模板 - 我只想要查看节点的纯HTML内容。

I would like to display a Drupal view without the page template that normally surrounds it - I want just the plain HTML content of the view's nodes.

这个视图将被包含在另一个非Drupal网站中。

This view would be included in another, non-Drupal site.

我希望通过一些视图来做到这一点,所以我可以快速轻松地设置这个解决方案将是最好的 - 我不希望每次需要在某个地方添加视图时创建一个.tpl.php文件。

I expect to have to do this with a number of views, so a solution that lets me set these up rapidly and easily would be the best - I'd prefer not to have to create a .tpl.php file every time I need to include a view somewhere.

推荐答案

我正在寻找一种通过ajax提取节点数据的方法,并为Drupal 6提供了以下解决方案。在实现以下更改后,如果在URL中添加ajax = 1(例如mysite.com/node / 1?ajax = 1),您将只得到内容,无需页面布局。

I was looking for a way to pull node data via ajax and came up with the following solution for Drupal 6. After implementing the changes below, if you add ajax=1 in the URL (e.g. mysite.com/node/1?ajax=1), you'll get just the content and no page layout.

在您的主题的template.php文件中:

in the template.php file for your theme:

function phptemplate_preprocess_page(&$vars) {

  if ( isset($_GET['ajax']) && $_GET['ajax'] == 1 ) {
        $vars['template_file'] = 'page-ajax';
  }

}

然后创建page-ajax.tpl .php在您的主题目录中,内容如下:

then create page-ajax.tpl.php in your theme directory with this content:

<?php print $content; ?>

这篇关于显示没有页面模板的Drupal视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆