grubix

Topic: W3C validation (XHTML 1.0 Transitional) - tips!

Hey again you lucky bunch.

I'm just going through my site and improving the validation at the moment. I thought I'd create a new thread to help with ideas for validation as and when I find them.

To start with, if you have some & symbols in your category names, like "Marketing & PR", like I do, then the page won't validate without them being turned into & codes.

1. open functions.php
2. find function get_categories()
3. inside the $categories array, find 'name' => $row['name'] and replace it with 'name' => htmlspecialchars($row['name'])

Enjoy.

Edited to change function name to the universal one, I'd used my own adapted function before.

Last edited by grubix (2011-04-20 12:55:38)

grubix

Re: W3C validation (XHTML 1.0 Transitional) - tips!

As above, to get around ampersands being used in category names, in page_category.php, add the htmlspecialchars() wrapper around $category['title'] and $category['description'] that are assigned to $smarty at the end of the file.

The two lines will then look like:

Code:
$smarty->assign('seo_title', htmlspecialchars($category['title']));
$smarty->assign('seo_desc', htmlspecialchars($category['description']));

grubix

Re: W3C validation (XHTML 1.0 Transitional) - tips!

and another! also in the page_category.php file, a few lines above, wrap $category['name'] up in htmlspecialchars again:

Code:
$smarty->assign('current_category_name', htmlspecialchars($category['name']));

That prevents uncoded ampersands being used in the H2 title tag for the category page.

grubix

Re: W3C validation (XHTML 1.0 Transitional) - tips!

Currently having a big problem getting the post a job page to validate because of the jQuery instant validation error messages such as:

Code:
company: ' <img src="{/literal}{$BASE_URL}_templates/{$THEME}/img/icon-delete.png" alt="" /> {$translations.jobs.company_error}{literal}',

The W3C validator doesn't like it because you can't have an <img> in that position.

Apparently you can avoid it being seen as markup code by a couple of methods:
- the CDATA method: http://www.webdesignerforum.co.uk/topic … alidation/
- escape character slashes: http://www.htmlhelp.com/tools/validator … tml#script

However, I've had no luck - either the jQuery stops working and validating the form, or it just complains about the validation in a different wording.

I also tried changing < and > tags inside the javascript to &lt; and &gt; but this just causes <img... etc. to be printed to the page, and not the actual image.

Any ideas?

Last edited by grubix (2011-04-20 13:32:41)

grubix

Re: W3C validation (XHTML 1.0 Transitional) - tips!

Any ideas anyone? Am I to believe then that no one on this forum has a valid-coded post a job page unless they've removed jQuery validation?

hobo

Re: W3C validation (XHTML 1.0 Transitional) - tips!

Try replacing with text... eg: "Required field"