1

Is it possible to load page content without rendering html.tpl.php? I mean on default Drupal has the follwoing:

Html.tpl.php --> Page.tpl.php -->...(etc.)

my goal is to remove Html.tpl.php for a custom path (site://ajax-unesco)

so:

page--ajax-unesco.tpl.php --> ... (etc.)

7
  • is ajax-unesco content type ? – Sandesh Yadav Jun 29 '13 at 13:47
  • keying in on the ajax portion of your path, if you are wanting Drupal to just output the $content of a page instead of all the various wrappings, in that menu callback, PRINT what you want instead of RETURNing it. – Jimajamma Jun 29 '13 at 13:49
  • It`s a view, i wanna get its contents by ajax call without additional data (like html.tpl contents). – Reza Shadman Jun 29 '13 at 13:50
  • @Jimajamma i didn't get it, currently i have a view with page display and a template file called "page--ajax-unesco.tpl.php (my view name) i'm rendering with the following code: <?php print render($page['content']); ?> – Reza Shadman Jun 29 '13 at 13:53
  • have you tried creating html--ajax-unesco.tpl.php in templates file ? you can create and keep it blank and test. – Sandesh Yadav Jun 29 '13 at 13:54
3

You could do something like this:

/**
 * Implements hook_menu
 */
function MY_MODULE_menu(){
  $items = array();
  $items['clean/view'] = array(
    'page callback'    => 'MY_MODULE_clean_view',
    'page arguments'   => array(2, 3),
    'access arguments' => array('access content'),
    'type'             => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Menu callback for clean/view
 * Output view without wrapper page markup
 */
function MY_MODULE_clean_view($name, $display = 'default'){
  // Note views_embed_view performs views access check
  print views_embed_view($name, $display);
  drupal_exit();
}

You can then use the dynamic path /clean/view/view_name/display_id to render the View without the wrapper markup.

0

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.