I need a module, which should send just its self output, also nothing from Drupal core or other modules. No header, no footer, no sidebars-blocks etc...

Example:
It must just print "Hello World", nothing else from header, footer, blocks etc

Let say I have a captcha module and I just want to print an image to screen also no-html code.

How can I do that?

Comments

nevets’s picture

Are you creating the module? If not what is the source of the output?

cafewebmaster’s picture

Yes, I want to create a module which prints just "Hello World" nothing else. No output from any module or Drupal core.

nevets’s picture

You will need a module that implements hook_menu() and a callback function. See http://drupal.org/node/206753 for a tutorial on creating modules. You need to read at least 1, 2, 3, 8 and 9. 8 covers the callback function, 9 hook_menu (also talked about in 7).

To just print "Hello World" the one difference from the tutorial you want to implement is that in step 8 the callback function returns the output, you want your callback function to print the output.

cafewebmaster’s picture

I have already read module docs and developed a hello_world module. The problem is I see left and right blocks and header-footer too. For example this module should print a demo javascript page, means just module content should transferred to browser nothing from blocks etc. I dont want to disable blocks or change template for whole site.

ie: I want to prevent that ..< html >< head >... appears twice on that page

<html>
<head>
... some js for test
</head>
<body>
... some demo code
</body>
</html>

mm167’s picture

there's no normal way to do it ..but there are many hacker ways to do it ...

say ..follow the "site is off-line" way.

Make another "off line" module. Then u will have the only the output from your module but NOT from others (i.e. header, footer, sidebars..etc)

another option:
set the css style "display:none" to all you div u dont want to see.
But u may have to do it one by one for all div u dont want to see.

have a nice weekend.

nevets’s picture

What does your module look like?

cafewebmaster’s picture

If I want to show users a html-demo of a menu or any code etc, I cant do it with Drupal's node/add. It will be printed as $content, also subcontent of a Drupal page. But I want to print exactly what code you see in this menu, nothing else.

http://www.cafewebmaster.com/demo/css-menu/dropdown_web2_style.html

stefan vaduva’s picture

I know this thread is old, but in case anybody else needs this.

1. Create a file called page-node-simple.tpl.php and add the following code:

<?php 
  print $node->body 
?>

2. On your page.tpl.php add this above everything else:

<?php
//display a page without header, footer and regions
if ($_GET["format"] == "simple") {
  include ('page-node-simple.tpl.php');
  return;
}
?>

3. Create a new page and put your HTML in the body field (don't forget to select full HTML or PHP code as input format)

4. Access your newly created node with /node/[your node id]?format=simple

krystlel’s picture

Hi Stefan,

Thanks very much for your quick and easy solution! I have just tried it and it works great. I really expected to have to create a whole new sub-theme, or add large amounts of code.

I am happy now. :) I'm glad you decided to post on the thread even though it's really old.

Thanks.

tyler-durden’s picture

Just thought I'd post this code has saved me from hours of coding and unneeded overhead. This was brilliant!

nevets’s picture

You can also achieve this without code by using the display suite module which allows you to add any number of build modes and use them in both views and panels.

himagarwal’s picture

I am getting a page with just "Array" in Drupal 7.

Is there something wrong that I am doing?

tyler-durden’s picture

I am now trying to apply this to D7 and it's working wonderfully, other than an error message on every page:
Notice: Undefined index: format in include() (line 3 of sites/all/themes/at_mono/templates/page.tpl.php).

The line this refers to is

if ($_GET["format"] == "simple") {

Does it need to be modified for D7, or does something else need to change? Thanks for any tips.

jaypan’s picture

It's not a Drupal thing, it's a PHP thing. You are checking if $_GET['format'] is equal to something, but $_GET['format'] doesn't exist in the first place, so it cannot be checked. This throws up a PHP warning, which is what you are seeing.

You can change it to this to get rid of the warning:

if (isset($_GET['format']) && $_GET["format"] == "simple") {

Contact me to contract me for D7 -> D10/11 migrations.

naitik’s picture

I had execute your code nut it is not working
it show just "Array" print on page

jdjeet’s picture

In case you are creating a custom page and want this to be loaded through ajax callback.

All you need to create a tpl file in your theme named page--UR_MENU_NAME.tpl.php
and write the html with required content only.
Normally you can have your page related data through $page variable.
like if you want to load only returned content of your custom page. just print $page['content']

clear the cache and reload the page. you are done.