从 Drupal 网站创建 iframe [英] Create an Iframe from a Drupal Website

查看:18
本文介绍了从 Drupal 网站创建 iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Drupal 网站.我想用我的 drupal 网站中的内容生成一个 iframe,其他网站可以嵌入.

I have a drupal website. I want to generate an Iframe with content from my drupal site, that other sites can embed.

我认为如何实现:

方法 1:创建一个独立于 drupal 引擎的 php 脚本.

导入配置文件,从而获得对数据库的访问权限.将内容生成为独立网页.将此脚本的 url 分发为 iframe 的源 url.问题:无法在 iframe 中提供 Drupal 功能,例如与登录用户的交互.

Import the configuration file and hence gain access to the database. Generate the content as a standalone webpage. Distribute the url of this script as the iframe's source url. Problems: cannot provide drupal functionality within the iframe such as interaction with logged in user.

方法 2:从 drupal 中创建 iframe.

使用 hoom_menu(iframe 的 url)创建一个定义菜单项的新模块.从菜单项的回调函数中定义 iframe 的内容.然后以某种方式为所需的 iframe url 分配一个自定义 page.tpl.php 主题,以便仅呈现 iframe 的内容,而不呈现所有其他页面元素(块、菜单、页脚等).

Create a new module that defines a menu entry using hoom_menu (the url for the iframe). Define the content of the iframe from the callback function of the menu entry. Then Somehow assign a custom page.tpl.php theme for the desired iframe url so that only the content of the iframe is rendered without all the other page elements (blocks, menus, footer, etc.).

特别是对方法 2 的任何评论将不胜感激!:)

Any comments especially for method 2 will be greatly appreciated! :)

推荐答案

我已经做到了,就在这周!

I have done exactly this, just this week!

我创建了一个自定义模块,它只输出我想要的内容(使用hook_menu()).然后我创建了一个只有

I created a custom module that outputs only the content that I want (using hook_menu()). Then I created a page template (page-mycustommodule.tpl.php) that only has

<?php print $content; ?> 

标签内.

基本上就是这样.要找出您的页面模板需要的名称,请使用 develtheme_devel 模块,然后只需单击您的页面,它就会告诉您它查找的模板.

That was basically all. To find out the name that your page template needs to have, use the devel and theme_devel modules, then just click on your page and it will tell you which templates it looked for.

需要注意的一件事:iframe 中的任何链接只会更改该框架的内容,因此当您的模块创建链接时,请使用正确的目标使父页面跳转到新 URL:

One thing to look out for: any links in the iframe will only change the contents OF THAT FRAME, so when your module creates links, use the proper target to make the parent page jump to the new URL:

l('link text',
  'node/' . $mynode->nid,
   array('attributes' => array('target' => '_parent')));

这篇关于从 Drupal 网站创建 iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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