0

Perhaps the question is simple, but I can not understand how to return the body of a node without a menu. I did a module that loads the content of node into the custom area.

function loadnode_in_region_menu_alter(&$items) {
    $items['load_node/%'] = array(
        'page callback' => 'loadnode_in_region_node_page_view',
        'page arguments' => array(1),
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );

return $items;  
}

function loadnode_in_region_node_page_view($nid) {
    $node = node_load($nid, NULL, false);
    $vnode = node_view($node);
    return drupal_render($vnode);
}

JS looks like

    jQuery.ajax({
        type: 'GET',
        url: Drupal.settings.basePath + 'load_node/' + id,
        dataType: 'html',
        success: function(data){
            jQuery('#ajax-result').html(data);
        },
    });

Result looks like this, with a duplicate menu enter image description here

If I change line from

    return drupal_render($vnode);

to

    echo drupal_render($vnode); OR print drupal_render($vnode);

The result looks like I would like it, but some fields are not displayed correctly, such as voting and image. Looks as if they are not themed. enter image description here

How to return themed node body without a menu?

0

You can create tpl for the menu and render the content and design tpl as required or create tpl for the content type in theme

| improve this answer | |
  • Thanks for the answer. The problem is that besides the menu the module re-adds scripts to the custom region. In fact, it adds the whole page. I tried to create region--(r_description).tpl.php but it does not replace formatting (the same situation as here https://www.drupal.org/node/1200498). Do you know another way how this can be done? – makbuk Mar 9 '17 at 9:39

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.