ContentType (content-type) [Solved inside]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
fredt
Forum Members
Forum Members
Posts: 144
Joined: Mon Jun 27, 2005 10:36 am
Location: Southern France

ContentType (content-type) [Solved inside]

Post by fredt »

As I still needed to get pure xml from cmsms, i finally hacked plugins/function.content.php :

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
Now is :

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
(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 :

Code: Select all

{content contenttype='text/xml' block="content_en" wysiwyg="false"}
(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)

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>
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 !

;D
cyberman

Re: ContentType (content-type) [Solved inside]

Post by cyberman »

Thanks for that nice solution :) ...
Post Reply

Return to “Modules/Add-Ons”