ContentType (content-type) [Solved inside]
Posted: Tue Jan 09, 2007 6:31 pm
As I still needed to get pure xml from cmsms, i finally hacked plugins/function.content.php :
Was :
Now is :
(added
if (isset ($params['contenttype'])) {$gCms->variables['content-type']=$params['contenttype'];}
)
Then I created a new Template, XMLOnly, with just a content tag, using our new "contenttype' param :
(see my previous post/patch on content and content_en to get only 1 edit box)
And finally I have a page, "somexml", using Template XMLOnly: (using note.xml from w3schools.com)
This page is Active, but Hidden from Menu.
Now, calling http://myintranet/somexml.html, I get nice & pure xml, with content-type : xml.
The whole thing is managed by (root) index.php, here:
header("Content-Type: " . $gCms->variables['content-type'] . "; charset=" . (isset($pageinfo->template_encoding) && $pageinfo->template_encoding != ''?$pageinfo->template_encoding:get_encoding()));
(nothing to change here).
Just my 2c.
Of course, this can be used to send any other type of info and content-type !

Was :
Code: Select all
elseif (isset($_REQUEST['mact']))
{
$ary = explode(',', $_REQUEST['mact'], 4);
$modulename = (isset($ary[0])?$ary[0]:'');
$id = (isset($ary[1])?$ary[1]:'');
$action = (isset($ary[2])?$ary[2]:'');
$inline = (isset($ary[3]) && $ary[3] == 1?true:false);
}
if (isset($_REQUEST[$id.'action'])) $action = $_REQUEST[$id.'action'];
else if (isset($_REQUEST['action'])) $action = $_REQUEST['action'];
//Only consider doing module processing if
//a. There is no block parameter
//b. then
// 1. $id is cntnt01
// 2. or inline is false
Code: Select all
elseif (isset($_REQUEST['mact']))
{
$ary = explode(',', $_REQUEST['mact'], 4);
$modulename = (isset($ary[0])?$ary[0]:'');
$id = (isset($ary[1])?$ary[1]:'');
$action = (isset($ary[2])?$ary[2]:'');
$inline = (isset($ary[3]) && $ary[3] == 1?true:false);
}
if (isset($_REQUEST[$id.'action'])) $action = $_REQUEST[$id.'action'];
else if (isset($_REQUEST['action'])) $action = $_REQUEST['action'];
//FredT ADDED following line
if (isset ($params['contenttype'])) {$gCms->variables['content-type']=$params['contenttype'];}
//Only consider doing module processing if
//a. There is no block parameter
//b. then
// 1. $id is cntnt01
// 2. or inline is false
if (isset ($params['contenttype'])) {$gCms->variables['content-type']=$params['contenttype'];}
)
Then I created a new Template, XMLOnly, with just a content tag, using our new "contenttype' param :
Code: Select all
{content contenttype='text/xml' block="content_en" wysiwyg="false"}
And finally I have a page, "somexml", using Template XMLOnly: (using note.xml from w3schools.com)
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
</__body>Don't forget me this weekend!<__body>
</note>
Now, calling http://myintranet/somexml.html, I get nice & pure xml, with content-type : xml.
The whole thing is managed by (root) index.php, here:
header("Content-Type: " . $gCms->variables['content-type'] . "; charset=" . (isset($pageinfo->template_encoding) && $pageinfo->template_encoding != ''?$pageinfo->template_encoding:get_encoding()));
(nothing to change here).
Just my 2c.
Of course, this can be used to send any other type of info and content-type !
