5

I'm new to Drupal (and SE) and am looking for a way to embed Drupal 7 content in an external website. D6 had modules for that (web widget and embed widget). How can I do it in D7? Thank you!

0
6
+25

Web Widgets now has a Drupal 7 release, so it might be worth trying it out.

1

Not sure about a Drupal 7 Module that is out yet. As an interim solution maybe PHP scrapping from your Drupal 7 Installation?

http://net.tutsplus.com/tutorials/php/html-parsing-and-screen-scraping-with-the-simple-html-dom-library/

The solution is not ideal but might help until one of the projects you posted is ported to 7/

2
  • thank you. Do you think it's possible to create a view and assign a custom template that's more or less blank. Then embed the page with an iframe? – uwe Mar 31 '11 at 17:27
  • Web Widgets module does it for you – Eugene Fidelin Jan 10 '13 at 9:28
1

You can implement the hook_preprocess_page() in your theme's template.php file to unset the regions you don't need (if your don't do this it will generate a performance issue. see http://www.lullabot.com/articles/drupal-performance-tip-block-visibility) and then you can set a custom template file for the page using the $variables['theme_hook_suggestions'] variable. This will give you the ability to show just the content region on the desired path on your Drupal site using a custom HTML structure for instance.

/**
 * Implements hook_preprocess_page().
 */
function mytheme_preprocess_page(&$variables) {
  $path = request_path();

  if ($path = 'the/path/you/want/to/customize') {
    unset($variables['page']['header']);
    unset($variables['page']['footer']);
    unset($variables['page']['sidebar_right']);
    $variables['theme_hook_suggestions'][] = 'page__my_custom_template_file';
  }
}

Then you need to create the file page--my-custom-template-file.tpl.php on your theme's templates directory to set the HTML that you need in the page.

<div id="custom-content-wrapper">
  <div class="custom-inner-content-div">
    <?php print drupal_render($page['content']); ?>
  </div>
</div>

For more info about Drupal theme files, see http://drupal.org/node/171194

After that you will just need to add an iframe tag in the place you need that content on the external website following the example:

<iframe src="http://mydrupalsite.com/the/url/to/the/page"></iframe>

For more info. about the iframe tag. See http://www.w3schools.com/tags/tag_iframe.asp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.