Hi everyone,

I've just installed Drupal version 5.10 and I really like it's functionalities, really powerful piece of software.
My plan is to develop a mobile website through Drupal 5.10, but I'm having trouble with getting it to generate valid XHTML.
I'm using a mobile template which is working excellent with Drupal 5.10 and is composed of valid XHTML. But as soon as I add content through Drupal to the site, the content is not added in XHTML by Drupal.
How could I tweak Drupal so the content I create through it, is being created by Drupal in valid XHTML? Or does there exist a module for this?

Thanks in advance for taking your time and helping me.
Sincerely,
Jonas

Comments

WorldFallz’s picture

you might try http://drupal.org/project/htmlpurifier

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

TheJED’s picture

Thanks WorldFallz, I will try it out.
Although I'm not sure it will do the thing since it for cleaning up html, not xhtml. I think my problem is caused by Drupal creating content that is in HTML instead of XHTML. But I will try the module and I appreciate that you took the time to reply.

Best regards and I wish you a nice evening,
Jonas

WorldFallz’s picture

...caused by Drupal creating content that is in HTML instead of XHTML.

afaik, core should produce valid xhtml. obviously, contributed modules can vary widely. If your problem is not in a content area, then turn off your contrib modules one by one till you find the culprit. if the problem is with content, that's the responsibility of the person adding the content (if using a plain drupal text box) or the editor if you've installed one of the available content editors.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

TheJED’s picture

Portulaca, thanks for your reply. My doctype is: DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN
"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd"

WorldFallz, thanks again for your reply.
I have done some testing and you're correct that the core produces valid xhtml, whenever I add a module like for example "Who's Online" it's outputed in valid XHTML. But the problem comes when I create content (either a story or page), because In the input options when creating content through Drupal, I have the following options:
"Filtered HTML"
"PHP code"
"Full HTML"
Whenever I create content this way, the content isn't produced in valid XHTML and I believe it's because of that I only could choose from HTML or PHP here. Therefore I would need a module for my Drupal 5.10 or tweak it so in the Input options when creating content, I could choose XHTML.

Does anybody know of where I could find such a module?

Thanks once again for taking your time and thanks in advance everyone for helping me.
Sincerely,
Jonas

dman’s picture

If you understand the difference between HTML and XHTML you'd not have much of a problem. Valid HTML produced by most tools these days (eg the WYSIWYGs) is also XHTML. It's not an either/or choice.

If you enter bad code in your own content editor area, and don't use some process to fix it (there are a few, like htmltidy and the module mentioned here) then you will have bad code in your system.

The filters you see have no influence on preventing you from entering XHTML. All of them will let valid XHTML through if you were to enter it correctly.

The solution is to either stop putting in invalid code, or use one of the tidy tools to repair your mistakes.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

TheJED’s picture

Dan, thanks for the reply. I appreciate it.

The problem is not that I'm entering bad code when creating a page or story. I just write in some simple words without any code at all, but the moment I add the content to the front page the xhtml checker I'm using says that's its not valid xhtml.
When I add modules to the front page like who's online, there isn't any problem at all. It's only when I create content (page or story) and adds it to the front page that it's not valid xhtml anymore (the content I add is one simple word like: Trying).
When Drupal is first installed and there's a welcome message at the frontpage, there isn't any problem with the xhtml. But as soon as I add another content to the front page by creating Story or Page, it becomes not valid xhtml.

The url to the website I'm working on is: www.create .mobi
I'm checking the code with: www.ready.mobi

Appreciate your help and thanks in advance.
Sincerely,
Jonas

dman’s picture

Well having a demo URL sure helps.

Looks like your node.tpl.php is badly formed, and has one too many closing </div> tags in it.
Have a close look at that. Either your $submitted variable should be wrapped in a block or not, one or the other.
Is the mobile 'theme' yours or from somewhere else?

I used the w3c validator, which at least tells me WHERE in the page the XHTML validation problem is and what the message is. That's a little more helpful than just "there is a problem" as a bug report :-)

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

TheJED’s picture

Hi Dan,

The theme was not created by me, I downloaded it from this website. I'm not so experienced in html or xhtml, which you probable could tell by my questions :)
But I looked through the node.tpl.php as you suggested and I simply removed the div tag, and now it's working excellent. I get the 5/5 score on ready.mobi even after I've posted content to the frontpage!
I never imagined the problem was affected by something in the theme since it worked prior to posting content. Thanks Dan for solving the problem for me, you really are the man! Saved a html/xhtml newbie like me countless hours!

Have a great day!

Sincerely,
Jonas

dman’s picture

Got there in the end.
Almost all the time that a valid site becomes invalid later is because invalid content was added by an editor. Which was my forst guess :-)
In this case it was that a template that wasn't used before started to get required once content was added. It is an error in the theme, which is not often a place to suspect.

Please raise an issue against the theme describing what you needed to do.
I can't tell from here what the theme was called.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

TheJED’s picture

Thanks once again Dan.
I will make a note for the theme so others shouldn't have the same problem. I just need to remember from where on the site I found the theme, will have to do a little search again :)

Best regards,
Jonas

portulaca’s picture

what kind of content are you creating, what exactly doesn't pass the validation?

what doctype are you using?