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

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

问题描述

我有一个drupal网站。我想从我的drupal网站生成一个含有内容的iframe,其他网站可以嵌入。



我认为这可以实现:



方法1 创建一个从drupal引擎自主的php脚本。



导入配置文件,从而访问数据库。将内容生成为独立网页。将此脚本的URL作为iframe的源URL分发。
问题:无法在iframe中提供drupal功能,例如与登录用户的互动。



方法2 创建来自drupal的iframe。



创建一个新模块,使用hoom_menu(iframe的url)定义菜单条目。从菜单项的回调函数定义iframe的内容。然后 为所需的iframe网址分配一个自定义的page.tpl.php主题,以便只有iframe的内容才能呈现,而不需要所有其他页面元素(块,菜单,页脚等)。



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

解决方案

我刚刚完成了这个,本周!



我创建了一个只输出我想要的内容的自定义模块(使用 hook_menu())。然后我创建了一个页面模板( page-mycustommodule.tpl.php ),只有

 code><?php print $ content; ?> < body> 标签中的



基本上都是这样。要找出您的页面模板所需的名称,请使用 devel theme_devel 模块,然后单击您的页面,它会告诉您哪些模板寻找。



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

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


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

How I think this can be achieved:

Method 1: Create a php script that is autonomous from the drupal engine.

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.

Method 2: Create the iframe from within drupal.

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.).

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

解决方案

I have done exactly this, just this week!

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; ?> 

within the <body> tags.

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.

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天全站免登陆