Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8162919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:53:32+00:00 2026-06-06T18:53:32+00:00

I have a module that is being used to create only a few page

  • 0

I have a module that is being used to create only a few page nodes (done in .install). That’s working fine. The problem is that these nodes contain xml, json, jsonp content, so I want to be able to render them without the theme, no header, no footer, no styling, just node->content.
This module is going to be shared with several other Drupal sites so I can’t do this with theme development, I don’t want anyone to have to create or modify templates.

Is there a way to do this using a hook from within the module, the .module? Basically detect the node title or node alias (or something) and then prevent the theme from rendering and only render the content. I’ll know the titles and aliases of the nodes because I’m creating them in the .install.

I would also like to modify the headers to correctly to say tell whats being returned is xml, json, etc.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:53:35+00:00Added an answer on June 6, 2026 at 6:53 pm

    Normally, I’d go about this another way. I’d define the content through hook_menu() menu router items rather than as node content, as it’s rarely intended to be directly user-editable. If there is a lot of processing, you can separate it from the .module and include it as a file for each item.

    /**
     * Implementation of hook_menu().
     */
    function MODULE_menu() {
      $items = array();
    
      $items['example/json'] = array(
        'title'            => 'JSON example',
        'page callback'    => '_MODULE_json',
        'access arguments' => array('access content'),
        'type'             => MENU_CALLBACK,
      );
      $items['example/xml'] = array(
        'title'            => 'XML example',
        'page callback'    => '_MODULE_xml',
        'access arguments' => array('access content'),
        'type'             => MENU_CALLBACK,
      );
    
      return $items;
    }
    
    /**
     * JSON example.
     */
    function _MODULE_json($string = '') {
      $data = array();
      $data['something']    = 0;
      $data['anotherthing'] = 1;
      drupal_json($data);
    }
    
    /**
     * XML example. No idea if this actually produces valid XML,
     * but you get the idea.
     */
    function _MODULE_xml($string = '') {
      $data = array();
      $data['different'] = 2;
      $data['evenmore']  = 3;
    
      // Build XML
      $output  = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
      $output .= "<data>\n";
      $output .= format_xml_elements($data);
      $output .= "</data>\n";
    
      // We are returning XML, so tell the browser.
      drupal_set_header('Content-Type: application/xml');
      echo $output;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a war module that is being built and is including a few
I have a module that reads the StandardError of a process. Everything works fine,
I have code in a rails helper that is being used in a view
I have module that implements custom content type via NodeAPI hooks ( hook_insert ,
Suppose you have a module that you know is safe. You want to mark
Let's say that I have a module that has a Queue in it. For
I have this module pattern that stores a bunch of vars. I want to
I have an HTTP Module that I use to clean up the JSON returned
I have a python module that imports a module generated with swig. When I
I have a python module that I've been using over the years to process

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.