tags:

views:

262

answers:

4

Hi,

I am using the thickbox module in drupal. The type I am using is the AJAX request via thickbox and I am passing the URL to get only the 'content'.

How can I show only the returned content without the primary links and other stuff like sidebar in drupal? Right now, the thickbox also returns the primary links.

This is the URL that I am passing: http://cec5/bhutan/?q=en/ceccr/subscribe/59&destination=og

I need only to get the 'returned content' from the return_me function. For example, my code is:

<?php
function cec_mypage_menu($may_cache) {
    $items = array();
    $items[] = array(
        'path' => 'cec_mypage',
        'title' => t('CEC My Page'),
        'access' => TRUE,
        'callback' => 'return_me',
        'type' => MENU_CALLBACK,
    );
    return $items;
}

function return_me() {
    return 'Only return this text and nothing more. No primary links, other layouts and stuff.<br />';
}
?>

How can I do that?

Thanks in advance.

Cheers, Mark

+2  A: 

try using echo/print.

For Ajax requests I have the same problem and I just print the content instead of returning it.

function return_me() {
    print 'Only return this text and nothing more. No primary links, other layouts and stuff.<br />';
}
IvanSF
Hehe that is my question in the Drupal forum but thanks anyway :)
marknt15
As Graham says below, you need to die() to prevent the theme layer being applied
mabwi
I did not add a die() but its working ok as expected. Hhmm maybe I will test some more :)
marknt15
+1  A: 

I think that this will work if you do a print, then die() to stop Drupal from adding anything else.

Graham
A: 

To do something similar I created a asmall module:

<?php
/**
 * Implementation of hook_menu().
 */
function ajax_node_menu() {
  $items['ajax-node/get/node'] = array(
    'page callback' => 'ajax_node_get_node',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,

    );

  $items['ajax-node/get/node-teaser'] = array(
    'page callback' => 'ajax_node_get_node_teaser',
    'access arguments' => array('access content'), 
    );

  return $items;
}

function ajax_node_get_node($nid) {
 $n = node_load($nid, NULL, FALSE);
 print node_view($n);
}

function ajax_node_get_node_teaser($nid) {
 $n = node_load($nid, NULL, FALSE);
 print node_view($n, TRUE);
}

?>

The url for the content will be something like : http://www.example.com/q=en/ajax-node/get/node/59

Tom

related questions