Create an Iframe from a Drupal Website

前端 未结 4 1252
说谎
说谎 2021-01-01 05:24

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:

相关标签:
4条回答
  • 2021-01-01 05:56

    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')));
    
    0 讨论(0)
  • 2021-01-01 05:59

    method 3

    you can use this module https://www.drupal.org/project/entity_iframe that allows you to create IFRAME READY webpages

    install it and go to the display settings of you content type that you want to use as iframe content admin/structure/types/manage/CONTENTTYPE/display

    choose the IFRAME view mode and choose the fields you would like to be shown

    and then use url like this domain.com/entity_iframe/node/NID and you will have a display with no extra headers footers etc ...

    By default a sample EMBED/IFRAME code is provided to the admin under each node the settings

        <iframe width="100%" height="300" src="domain.com/entity_iframe/node/96" frameborder="0" class="entity_iframe entity_iframe_node" id="entity_iframe_node_96" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
    

    The settings in admin/config/system/entity_iframe control some of the details of the embed code

    For complete control of the theme used you can use in combination with https://www.drupal.org/project/entity_iframe_theme

    0 讨论(0)
  • 2021-01-01 06:16

    I found the answer by Graham very useful. Unfortunately I don't have enough reputation on this site to add a comment so I will have to put my comment in an answer.

    5 years on, the information has changed slightly:

    • The module theme_devel now seems to be called devel_themer instead.
    • In D7, the template naming pattern is slightly different with 2 hyphens: page--[front|internal/path].tpl.php (see docs)
    • D7 templates are slightly different based on render arrays, so the template will need to be something like print render($page['content']);
    0 讨论(0)
  • 2021-01-01 06:19

    What do you exactly need to iframe? A node? A block? Should it be static or dynamic?
    You can simply create a node with a php filter and generate the iframe output. Then you can put this output between <pre> tags to display it as code that users can copy/paste in their site.

    0 讨论(0)
提交回复
热议问题