Get doctype
Permalink 1 user found helpful
Hi,
In the header you are adding
<?php Loader::element('header_required'); ?>
Before this code, there is some HTML and the doctype. How can I check for the doctype within header_required.php?
I want to check if it is HTMl5 doctype or not and change some meta stuff. Currently, no HTML5 page will correctly validate due to the generation of:
<meta http-equiv="content-type" content="text/html; charset=<?php echo APP_CHARSET?>" />
Thanks
In the header you are adding
<?php Loader::element('header_required'); ?>
Before this code, there is some HTML and the doctype. How can I check for the doctype within header_required.php?
I want to check if it is HTMl5 doctype or not and change some meta stuff. Currently, no HTML5 page will correctly validate due to the generation of:
<meta http-equiv="content-type" content="text/html; charset=<?php echo APP_CHARSET?>" />
Thanks
I'm not sure if it's possible to "detect" the doctype or how you would change it if you did. What you might try is overriding that element header_required.php file by copying it from /concrete/elements/header_required.php to your own /elements/header_required.php and then you could edit it or put a conditional statement around it.
Oh, getting the Doctype out of an HTML isn't the problem. I need to know how I can get the HTML at all. I already did what goldhat did but I'd like to make it more independent.
Maybe you are preloading it somehow but I just guess, I can't even get the HTML.
Maybe you are preloading it somehow but I just guess, I can't even get the HTML.
I'm sorry, I have no idea what you are trying to achieve.
That response confuses me too, what do you mean by "get the html"? What does that mean? You mean programmatically as in load it through a function or class and then be able to change it? As you can see in the template files the HTML is part of a theme, so you can override those templates, but you cannot load it into PHP as a variable unless you replace those template parts with variables that you set yourself in your code. Now if you want that level of control you could create a $doctype variable or an html class, and then output that into the template files... the question is WHY would you need or want to do that?
As I said, get the HTML of the template to change the meta tag according to the DOCTYPE.
1. I create a Doctype Var and Display it on the page (which somehow sucks) or according to somethign likehttp://framework.zend.com/manual/2.0/en/modules/zend.view.helpers.d...
2. I finda way to get the HTML of the template (serverside!) and change the meta tag.
Why I need this? Because I want my HTMl to validate. As ssimple as that. Because I want clean HTML. Proper HTML.
I want to use HTML5 Dotype which is impossible at the moment using Concrete5 without changing it by hand. So I need to know what component puts together the template and how I can get the HTML there and inject some info into header_required.php
The only reason is: I want my HTML to validate.
Actually I think using the 1. Idea is better since less magic is always better.
Anyway, maybe I'm overseeing something. I'll probably just go and create some Doctype Helper kind of thing. Thats also a godo practice. ;)
1. I create a Doctype Var and Display it on the page (which somehow sucks) or according to somethign likehttp://framework.zend.com/manual/2.0/en/modules/zend.view.helpers.d...
2. I finda way to get the HTML of the template (serverside!) and change the meta tag.
Why I need this? Because I want my HTMl to validate. As ssimple as that. Because I want clean HTML. Proper HTML.
I want to use HTML5 Dotype which is impossible at the moment using Concrete5 without changing it by hand. So I need to know what component puts together the template and how I can get the HTML there and inject some info into header_required.php
The only reason is: I want my HTML to validate.
Actually I think using the 1. Idea is better since less magic is always better.
Anyway, maybe I'm overseeing something. I'll probably just go and create some Doctype Helper kind of thing. Thats also a godo practice. ;)
Even if you are able to 'get the HTML', here's the problem, IMHO.
50% of concrete5 add-ons are free and built by volunteers which means your going to have a hard time forcing any of them to care enough to make them validate. In your quest for the Holy Grail, you will have to re-write a lot of this code.
50% of concrete5 add-ons are free and built by volunteers which means your going to have a hard time forcing any of them to care enough to make them validate. In your quest for the Holy Grail, you will have to re-write a lot of this code.
Yeah I don't see why doctype isn't part of the addon details. Don't see why such a doctype helper wasn't included by beginning. Think it's quite important to have validate HTML. It's not a holy grail.
I see what you mean but I don't take it as an argument not to work on this issue.
Wouldn't it make sense to implement this in the comming version?
I see what you mean but I don't take it as an argument not to work on this issue.
Wouldn't it make sense to implement this in the comming version?
The ultimate answer to any open source 'want': anyone can submit a pull request on Github.
So are you saying even if you changed the doctype in the theme, and then removed/changed meta tags in header_required, that wouldn't be enough to make the HTML valid?
If the HTML in one of your add-ons isn't valid then any page containing the invalid add-on will not validate. If it's important to you then you will have to dig into the add-on's HTML and fix whatever's ailing it.
Of course that works as I said before. But I don't think, it's a good solution.
@JohntheFish
Of course, I never said anyone has to do it for me, did I? I'll first work with overwriting header_required.php and if I have the time I'll try to add the functionality I imagen and submit it.
Anyway, thanks for you inputs.
@JohntheFish
Of course, I never said anyone has to do it for me, did I? I'll first work with overwriting header_required.php and if I have the time I'll try to add the functionality I imagen and submit it.
Anyway, thanks for you inputs.
Have you ever received an answer to this? How did you solve your problem?