How do you replace page.tpl.php, which is loaded from a module in Drupal?

I have a special module in Drupal that outputs a serialized data dump. I want this page where the dump doesn't seem to be using an active theme. Instead, I just want the data dump to appear without any HTML markup, theme, JS, CSS, etc. Just a dump (another website will consume it).

If I did this at the topic level, I would simply create a new page.tpl.php file to display a specific type of content without any subject, HTML, etc. But I need to do this at the module level for only this page that the module creates, since this module will be installed on different Drupal sites.

Is there a way to disable all topics and control the output of the HTML page of the module page at the module level? All I really want to do is turn off if possible.

I am running Drupal 6.

+3
source share
2 answers

Well, this is a different approach, but one that has always worked for me.

When your page callback is called in a module, instead of returning data (which will be the themes), simply print or echo the data and do not return to the function.

+7
source

For this use case (output raw data for automatic consumption), Chris's answer is definitely suitable for transition (+1).

, page.tpl.php , moduleName_preprocess_page(&$variables). $variables['template_files'] . , *.php.tpl Drupal, page.tpl.php , , , 'moduleName_page.tpl.php' , .

, , . $variables['template_file'] - $variables['template_files'] , "template_file" .

+5
source

Source: https://habr.com/ru/post/1729252/


All Articles