).
)
/*
* Inherit contentType from Parent
* Written By Paul Suckling 26 Sep 2007
* Based on "Inherit Parent Template by "Raymond Irving - 12 Oct 2006
*
* Simply results in new documents inherriting the contentType
* of their parent folder upon creating a new document
*
* Configuration:
* check the OnDocFormPrerender event
*
* Version 1.0
*
*/
global $content;
$e = &$modx->Event;
switch($e->name) {
case 'OnDocFormPrerender':
if(($_REQUEST['pid'] > 0) && ($id == 0)) {
if($parent = $modx->getPageInfo($_REQUEST['pid'],0,'contentType')) {
$content['contentType'] = $parent['contentType'];
}
}
break;
default:
return;
break;
}
global $content;
$e = &$modx->Event;
switch($e->name) {
case 'OnDocFormSave':
// Get the current alias
$alias = $content['alias'];
// Discard the extension if one exists...
$dotPosition = strpos($alias,'.');
if (!($dotPosition === false)) $alias = substr($alias,0,$dotPosition);
// select the appropriate extension
switch($content['contentType'])
{
case 'application/xhtml+xml':
$extension = '.html';
break;
case 'text/html':
$extension = '.html';
break;
case 'text/xml':
$extension = '.xml';
break;
// Other contentTypes here...
default:
$extension = '.html';
break;
}
// Register the modified extension
$content['alias'] = $alias . $extension;
break;
default:
return;
break;
}
and now it would be nice if the extention to the alias is also set to match the ContentType if css is selected would be nice to have .css and if you select xml . xml etc.
(ok, ok, it’s not public yet but maybe backport it to 0.9.6 if you can’t wait and if it’s doable)