I'm very new to Drupal and I have a bunch of sites to manage that are in different cms's like wordpress, sharepoint and others. My goal is to merge all the content into drupal over time.

I want to manage a master menu in Drupal and when items are added or removed generate a html code snippet representing the menu that the other sites can pick up from the local file system or via a url if they are not.

How can I serve content from a url without the themes and drupal html being applied?


have this url serve a css file


or get a js file from


or from a url like this


get this html snippet ONLY

 <div class="nav">
     <li><a href="">Menu Item 1</a></li>
     <li><a href="">Menu Item 2</a></li>
     <li><a href="">Menu Item 3</a></li>

* EDIT * The answer about the menu hook is really close to what i want, but I think i may have confused things by mentioning menus at all.

So I apologise as I didn't make what I am after very clear. Ill try and reword it.

For an arbitrary url I want to return content of any kind from the drupal 7 cms.

Which 'hook' takes the url, matches it to a pattern, and then allows me to send anything back on the response stream, and how do I change the mime types.


There is another simplest way using hook_preprocess.

function mytheme_preprocess_node(&$variables) {
  $node = $variables['node'];
  if (!empty($node) && $node->nid == $the_specific_node_id) {
    drupal_add_js(path_to_theme() . "/file.js", "theme");
    drupal_add_css(path_to_theme(). "/file.css", "theme");

Insert this function in your theme's template.php file

See theme functions here


You'll need a custom module for this (see the Module Developer's Guide if you're not already familiar with creating modules, it's pretty straightforward).

Once you've got your custom module set up you need to implement hook_menu() and define a callback function for your URL:

function MYMODULE_menu() {
  $items['globalmenu.html'] = array(
    'title' => 'Global Menu',
    'access callback' => TRUE, // If you want any source to be able to access this page
    'page callback' => 'MYMODULE_deliver_global_menu'

  return $items;

function MYMODULE_deliver_global_menu() {
  print '<div class="nav">...';

Since Drupal will only actually apply the theme wrappers to a page if something is returned from the page callback, simply printing your HTML and calling drupal_exit() is all you need to do.

Sorry if some of that is stuff you already know, I thought it best to err on the side of caution.

  • thanks you were right to keep it basic...I know nothing. I give this a try right now – Peter Jun 16 '12 at 0:23

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.