Posted by jredding on October 28, 2006 at 8:59am
Quick question...
I have a PHP Page that outputs XML but its theming it within PHPTemplate.
So.. umm. .how do I prevent ALL theme output?
Quick question...
I have a PHP Page that outputs XML but its theming it within PHPTemplate.
So.. umm. .how do I prevent ALL theme output?
Comments
easy
don't call theme('page'). just print your output and then return empty string or NULL (i can't recall) from your menu callback
Thanks but...
Wouldn't this require altering my theme so that theme('page') isn't called? Is it possible to do this if you are using a standard Page node and selecting PHP Code as the input format?
i.e.
create content-->Page
Type in php code
Select Input Format "PHP Code"
Hit Submit?
Or do I need to create a CCK Type named something like "PHP Code Feeds", then create a template file content-php_code_feeds.tpl.php and prevent the theme('page') call from the template file?
Now that I think of it.. I don't think this is possible.. Drat! but... maybe???
-Jacob Redding
-Jacob Redding
Hacks
I've hit this before. Here are some not-pretty hacks; I've used both of these:
(1) Set the headers yourself using php, e.g.,:
<?phpheader("Content-type: text/xml; charset=UTF-8");
print "<?xml blah blah blah
?>
?>
the rest of your XML here
<?phpexit;
?>
(2) Set up a vocabulary for "special themes." In your template.php, check the taxonomy term for "XML output" and short-circuit the normal themeing and just dump the body wrapped in the appropriate whatever...
That was me... Sorry about
That was me...
Sorry about the code formatting. WTF? Anyway, should be readable.
I should also say that if
I should also say that if you take the "set the headers and exit" approach, I highly recommend adding some kind of wrapper around it to make sure you can access the node when logged in as admin. I've done this one of two ways:
(1) Check to see if the user is in an "admin" (or other) role and if so, do not actually dump the output (this requires you to use a different browser or log out to test)
(2) Look for a $_GET variable and only intercept headers when this variable is set; fix links accordingly
What about CCK types?
Instead of setting up a taxonomy could I use a CCK Type and check for the type?
Also maybe I'm tired or overworked but how exactly do I check for this with template.php? What function do I override?
-Jacob Redding
-Jacob Redding