How can I create a Drupal "Page" (not a block) without any theme like the following:
http://www.oniva.com/upload/1356/em.jpg

I would like the page this "Page" in HTML iframe

I do not want this "Page" to include any header / footer / left / right column.

Can to set this update in Drupal?

when i request to Drupal Node like - node/31

then the Page show up without any theme applied.

Comments

allanmayberry’s picture

...Taxonomy Theme? This allows you to apply multiple themes across your website, by defining which page has which theme...

I know you said you were looking for a page with "no theme" but my understanding is that this isn't possible (could be wrong i guess) but you could create an additional theme for your site which is just completely blank, and apply this to the appropriate pages?

Barrett’s picture

Or just create it as plain old html and manage it outside of Drupal completely. It could live in the same directory as Drupal files but not invoke any of the Drupal engine. Instead of the link to it being node/31 it would be .../plain_old_html.html

Alan D.’s picture

Two options come to mind:

1) Create a new content type, "Iframe page" for example, and define a custom page.tpl.php template for it that does not have any of the regions (Eg: page-iframe.tpl.php).

All it really needs is the html/head/body tags and echo $content;

2) Add some sort of flag, (ckk, node id, or whatever), that you can detect in page.tpl.php. Then if this is present, simple echo $content and return.


Alan Davison
manoloka’s picture

I'm also interested in something like that.

The reason;

I want other webpages be able to display a "iframe" style of a dropdown menu that would pull some data from my website.

e.g. my site is a professional directory, other pages could benefit from my database of professionals and pull results from it.

Any ideas?

allanmayberry’s picture

...in a bit more detail, as in would you want elements from your database pulled into an external site to display details of professionals, or to display a full website page within the iframe. I guess you could maye create two themes, one for your actual visitors, and a plain one for when a page is 'pulled' from your site, you could maybe use the taxonomy_theme module in some way, although I'm not sure how you would then determine which theme to apply to a page, based on if it was to be displayed in an iframe or not?

manoloka’s picture

For example;

The page at www.dealocal.co.uk/bath-and-north-east-somerset displays professionals working in an area (Bath and North East Somerset).

What I'd like to do is another page (new URL of course) that only pulls the "Content" (i.e the view list of the professionals) and nothing else, no blocks, no header, no menus.

I am assuming (because I don't know it for sure) that then I'd be able to use an iFrame to pull that page (or any other for the matter) from any website. Wouldn't I?

I imagine the option suggested by Alan D (above) is what I'll have to go for, it makes sense doesn't it? But I'm not sure how to do it.

Thanks

P.S. I cannot use taxonomy_theme because I'll be upgrading this site to Drupal 6 very soon, don't want to use modules that won't allow me to upgrade it.

Alan D.’s picture

I would create an entire new theme that is blank, just the header section, $content, and $closure.

You will need a custom module to provide a hook_init to switch themes based on the page request (if there isn't another module like taxonomy theme in both 5 and 6 already).

Cut n paste from http://api.drupal.org/api/file/developer/examples/page_example.module

Then if the hook_init, look for the flag to switch themes. In this example I am looking for a node of type xxx

<?php
function hook_boot() {
  global $theme;
  $a1 = arg(0);
  $a2 = arg(1);
  $a3 = arg(2);
  if ($a1 == 'node' && is_numeric($a2) && empty($a3) ) { 
    $node = node_load(array('nid' => $a2));
    if ($node && $node->type == 'xxx') {
      $theme = 'my_stripped_theme_name';
    }
  }
}
?>

It could be worth defining your own AJAX page callbacks and doing this all via AJAX. This would remove the need for the iframe


Alan Davison
manoloka’s picture

Wow .... Alan that is far too much for my brain :-s I only have a very (VERY) basic knowledge of PHP (always happy to learn more though :-).

Please correct me if I'm wrong.

When I read your option 1) above. I thought I could use something like this.

I did manage to theme the maintenance page using the advice at http://drupal.org/node/58562#comment-266358 (great advice by the way)

I thought I may be able to use a similar way to theme a custom page (or a whole directory maybe e.g. all the pages within www.example.com/if/ directory would use the theme).

Obviously I'd have to create a new function (within the template.php and new template page e.g iframed.tpl.php)

Any chance of this working? if yes
Any idea of what the function should look like?

Alan D.’s picture

K. The other option apart from paying someone to do implement this is to do the site upgrade to 6 and to use something like themekey. There are a couple other theme related modules, but this seems to meet your requirements. You will still need to create the blank theme.

Another option, a bit hackish is to create a content type for the pages that go into the iframe. Then in you page.tpl.php paste in the following:

<HTML>
<HEAD>
<!-- cut -->
</HEAD>
<!-- NEW CODE -->
<?php if ($node && $node->type == 'blank_page_content_type') :?>
<BODY>
  <?php print $content; ?>
  <?php print $closure; ?>
</BODY>
<?php else : ?>
<!-- END NEW CODE -->
<BODY>
  Add everything down to body
</BODY>
<!-- NEW CODE -->
<?php endif; ?>
<!-- END NEW CODE -->
</HTML>

Replace the if ($node && $node->type == 'blank_page_content_type') : with your content type that your using to flag the template.

Eg: For the standard Drupal Page content type if ($node && $node->type == 'page') :


Alan Davison
manoloka’s picture

At this time I'm going to use this "another option" until I've got the site upgraded to D6 then I'll look into it again.

I modified a bit the position of the new code, so I can use a separate .css style page exclusive for this page.

Also I changed a bit in node.tpl.php.

In line 10 you got;

  <?php if ($submitted): ?>
    <span class="submitted"><?php print t('Posted ') . format_date($node->created, 'custom', "F jS, Y") . t(' by ') . theme('username', $node); ?></span> 
  <?php endif; ?>

I changed it for;

   <?php if ($submitted && !$node->type == 'iframe'): ?>
    <span class="submitted"><?php print t('Posted ') . format_date($node->created, 'custom', "F jS, Y") . t(' by ') . theme('username', $node); ?></span> 
  <?php endif; ?>

This eliminates the "posted by" which wouldn't make much sense as this form will be seen in someonelses website

Check it out at http://www.dealocal.co.uk/betatest/if/findadea.htm

Thanks a lot Alan :-)

seansies’s picture

Alan, this thread was very helpful to me. Forgive me for asking for more on your already generous post.

I'm loading a view from another site (http://staging.geneticalliance.org) in an iFrame here: http://www.diseaseinfosearch.org. I want a completely stripped out view of a view (diseases), which I created (in your words, hackishly!) by adding a blank content type on the GA site (and modifying page.tpl.php to look for that content type, and display only a very bare html page if it finds it).

I'm having trouble, though, when clicking on a term, on also stripping out the site-results page. I've tried several methods -- including created blank tpl.php versions of the views for site_search iFrame and diseases_Iframe and a straight ajax-rendering call -- but can't get anything to work.

Maybe I should stick to my original faked up method: is there a way to add another IF condition to page.tpl.php to also look for the phrase "iFrame" in the URL and load the blank page type if it finds it? even for views or search results?

allanmayberry’s picture

...in the way you mention above, its just a case of defining the iframe on any html page and then pulling in the content, in your case a URL


<iframe src=" http://www.your_url_here" width="800" height="600" scrolling="auto" frameborder="0" allowtransparency="true"></iframe>

manoloka’s picture

Alan, I wonder if I could get the same effect for a view?

:-)

Alan D.’s picture

Anythings possible in drupal :)

Hard way - custom coding/theming, easy way the Insert View module. Great little module


Alan Davison
manoloka’s picture

easy way the Insert View module

Sorry read it fast and missed you were referring to a different module than View.

I'm checking it out.

thanks again

manoloka’s picture

What should I use to achieve the same effect for a view?

maybe this;

<?php if ($node && $node->view== 'my_view_name') :?>

thanks

Alan D.’s picture

I hope that you realize that you can control the submitted by info here: index.php?q=admin/build/themes/settings


Alan Davison
manoloka’s picture

I did know but I forgot :-( about this option

I've now taken of the hack in the node.tlp.php

Thanks for that,

Budrick’s picture

Maybe just:

 echo "you html";
exit; 

like for ajax requests?

tonebari’s picture

I did a chat module for a client and thinking of contributing it. Uses a pop window like IMCE and rather than put the file at the root level, which I have done plenty; that is not going to work for a module that would interest.
You can just create a page.inc file and use module_load_include, but don't return any output for the menu item.

_grizly’s picture

I prefer

    echo "whatevs..";
    module_invoke_all('exit');
    exit();

But thanks! I was looking for exactly this and didn't think of it.

Alan D.’s picture

Does this work?

print 'abc';
drupal_exit();

It is the proper way to exit :)


Alan Davison
_grizly’s picture

And it's less typing! Cheers mate.

n_nelson350’s picture

Create a new node and use a custom theme for that node. You can skip out the header/footer from that. Also you can set a different CSS for that in the same style.css using different naming conventions. Just print only the content in that .tpl.php file of that node type.

If any Help please forward the page details, I will help it out

kekko87fg’s picture

Hi, I wanted to know if you can create a view without CSS and without the template? I would need to see just a part of my site on Facebook ... facebook app to redirect the path of the view created ...
thanks

n_nelson350’s picture

Go to the actual Views and edit the view. Now Click on Theme Information, you will find various theme information related to field, display etc. Choose one of the names under the display output(Copy the last name given under that option). Now make a [yourviewdisplayname].tpl.php using that name and upload that tpl page into /sites/all/themes/[yourthemefolder]/. Now under the same folder create page-[yourviewdisplayname].tpl.php again under the same directory without the css included in it.

Please try it and ask if any query.

mrded’s picture

/**
 * Implementation of hook_menu().
 */
function example_menu() {
  $items = array();

  $items['node/%node/iframe'] = array(
    'title' => 'Iframe',
    'page callback' => 'node_view',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_LOCAL_TASK,
  );

  return $items;
}

/**
 * Implements hook_preprocess_html().
 */
function example_preprocess_html(&$vars) {
  if (arg(2) === 'iframe') {
    $vars['theme_hook_suggestion'] = 'html__iframe';
  }
}

/**
 * Implements hook_preprocess_page().
 */
function example_preprocess_page(&$vars) {
  if (arg(2) === 'iframe') {
    $vars['theme_hook_suggestion'] = 'page__iframe';
  }
}

Then you need to create two empty templates:

html--iframe.tpl.php
<?php print $page ?>

page--iframe.tpl.php
<?php print render($page['content']) ?>

jftzsmns’s picture

Nice solution, works perfectly!

rcodina’s picture

Thanks @mrded! This worked like a charm!

tyler.frankenstein’s picture

Yes, this works amazingly (D7), very clever.

mcdoolz’s picture

If you wish to return your content programatically without a theme you can pop this into a raw menu hook callback:

$content['details'] = [
  '#type' => 'markup',
  '#markup' => 'Hello world.',
];
print render($content);

If you use return without render, you'll see a full themed page.
If you return the rendered content, Drupal 7 will simply display it without any surrounding theme.

-
Be the occasion.