content_type UDT for use in CMSMS 1.12.x and 2.x
Previous article Next articleIn several of my tips and tricks articles I use the content_type UDT to change the content type of the page. In the upcoming 2.0 release of CMS Made Simple this method is changed and won't work anymore. If you change the UDT like done below it will work in both 1.11 as in the 2.0 series!
How to use
Change the content_type UDT to:
if ($content_type != '') {
if (version_compare(CMS_VERSION, '2.0', '<')) {
cmsms()->variables['content-type'] = $content_type; // 1.12.x series
} else {
cmsms()->set_content_type($content_type); // 2.x series
}
}
You already have a website using CMS Made Simple 2.x? That makes life a lot easier, this code is sufficient:
if ($content_type != '') { cmsms()->set_content_type($content_type); }
Comment Form
ReviewManager
ReviewManager
4 Comments
All is described in this tutorial https://www.cmscanbesimple.org/blog/easy-way-to-combine-and-minify-javascript-files-and-code
Thanks for your quick reply, i see your test, it's ok
So strange i don't understand the problem in my case... have you any .htaccess rules overwritting the default ?
I'm using php 7.0.22 and you ?
Have you a config.php with extended options ?
I try to find a solution.
Thanks and have a good day.
I did a quick test and it works for me:
https://www.cmscanbesimple.org/page.js
++++++++++++++++++++++++++++++++++
{content_type type='text/javascript'}
$(document).ready(function() {
$('#slider').cycle( {
delay: -2000,
timeout: 6000,
speed: 2000,
pause: 1
} );
} );
++++++++++++++++++++++++++++++++++
Hello Rolf,
I just install the version 2.2.3.1, and i'm not succeed to do that (but it was working since several years with 1.11.x and 1.12.x with a similar solution)
The page doesn't render, CMSMS do like the "page.js" doesn't exist, i do the minimal :
Gabarit "minimal" : {content}
"page.js" with "minimal" : few lines of javascript code with UDT "content-type" in first line
UDT "content-type" : cmsms()->set_content_type('text/javascript');
Config CMSMS :
....
$config['url_rewriting'] = 'mod_rewrite';
#$config['page_extension'] = '.html';
#$config['default_encoding'] = 'utf-8';
...
I have no error in Apache logs... i use php 7.0 on a Ubuntu 16.04 VM
If you have an explication, i will take it ;o)... thanks a lot in advance.