Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Store not validating as valid XHTML on W3C validation service
 
bubba
Jr. Member
 
Total Posts:  3
Joined:  2008-06-29
 

I downloaded the latest version of Magento (ver 1.0.19870.4) three days ago.  I Followed all the installation instructions to the letter, including installing the sample catalog, and had no problems at all.  I learned how to create themes pretty easily (compared to other open source shopping cart software).  I was able to easily wrap the store in my website’s page and started to validate the various pages in the store using the W3C validation service. 

Nearly all the pages validate beautifully.  However I keep having a problem with the home page.  At first I thought it might be because I wrapped it in my website’s page so I went back to the default theme and validated the shopping cart using the default theme.  The results were exactly the same as with my theme.  The home page doesn’t validate and are all exactly the same issues as with my theme.

It all boils down to the various images in the content section that all have the same structure such as:

<!-- [start] content -->
<
div class="col-left side-col">
<
class="home-callout">
<
a href="http://www.mywebsite.com/magento/catalog/product/view/s/anashria-womens-premier-leather-sandal/id/135/category/5/"><img src="http://www.mywebsite.com/magento/skin/frontend/my_interface/my_theme/images/ph_callout_left_top.gif" border="0" /></a>
</
p>

           <!-- 
more code similar to above -->
           <!-- 
more code similar to above -->
           <!-- 
more code similar to above -->
           <!-- 
more code similar to above -->

</
div>
<!-- 
[end] content -->

These errors do not occur with any of the images that came with the sample product file.  They are occuring only with images that came with the basic Mageno installer file.

The validation errors are all due to the fact that :
1) There is no attribute “border” allowed in XHTML 1.0 strict
2) The “alt” tag is missing

I figure I have to find the particular file that’s writing the href and img src code.  I’m pretty good with php and javascript so I’ve been all over zillions of phtml and javascript files in the source code, I’ve been all over the forum all day long, and I’ve been in the Admin Panel all day long but I’m just not finding it. I’m not as good with XML files although I have been studying the Magento tutorials and have understood them much better than before in the hopes that that will help me locate the particular file in question but nothing yet.
My idea is to get rid of the “border=0” attribute and move that to the CSS file and then have a generic “alt” attribute such as “alt=’unamed image’ “ placed in these img src tags.

Maybe I’m looking too deep and its right in front of my nose.  Does anyone have any idea where the file is that writes these? Thanks for any info.

By the way, this Magento is really a superior shopping cart.  I love it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bran
Jr. Member
 
Total Posts:  4
Joined:  2008-06-30
 

I’m glad that you pointed this out because I think that standards compliance is very important.

To answer your question there are several files that have this poor “border” use.  A quick search in TextMate shows:
app/code/core/Mage/Rss/Block/Catalog/Catalog.php - line 103
app/code/core/Mage/Rss/Block/Catalog/New.php - line 94
app/code/core/Mage/Rss/Block/Catalog/Special.php - line 116
app/code/core/Mage/Rss/Block/Catalog/Tag.php - line 80
app/code/core/Mage/Rss/Block/Wishlist.php - line 69

I imagine it would be appropriate to use the alt="” tag at those places as well.  However, this might not completely solve the compliance problem because there are several instances of “border=” in reference to TABLES within many files as well.

A possible way to solve the IMG border issue would be to remove the references from the files I specified and edit the CSS file to include something like:
img { border: none; }
or
a>img { border: none; }

Though I haven’t tested it.  Good luck.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bubba
Jr. Member
 
Total Posts:  3
Joined:  2008-06-29
 

Thanks for the tip.  I’ll be looking at those files.  At least that will solve much of my problem.  And I think the CSS idea is pretty good.  I’ll try them and test them later this week.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bubba
Jr. Member
 
Total Posts:  3
Joined:  2008-06-29
 

Just an update.  I did follow Bran’s advice and took out the ‘border="0" ‘ in the above files and moved the border control to the CSS.  However it did not fix my problem.  I am not sure why those files above are still written that way because anytime they get used whatever they are used on will result in invalid XHTML 1.0 Strict pages. 

However, I felt I was always looking too deep into this thing and as it turned out I was.  I finally traced the problem to the CMS section of the Admin Panel.  In fact, the two files that would not validate were “hard coded” pages in the CMS section under “Manage Pages” AND “Static Blocks”.  For some reason I never even thought about checking there.  These were all the original files that came with the “Sample Data” download.  Whoever “hard coded” these two pages that came with the “Sample Data” had forgotten to close some tags, closed other tags incorrectly for XHTML 1.0 strict, used ‘border="0" ‘, and left off the ‘alt’ attribute in all images.  It took me about 5 minutes to correct all of those and now everything validates perfectly. 

If you are trying to validate your pages and they are not validating and you are using the files that came with the “Sample Data” download, go to the Admin Panel and check the hard coded pages there first before you drive yourself crazy for three days like I did.

Other than that, I am absolutely blown away by this shopping cart.  It’s fantastic.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bran
Jr. Member
 
Total Posts:  4
Joined:  2008-06-30
 

Thanks for the update.  I didn’t think to look there either.  I’m glad that it validates for you now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Thejosh13
Sr. Member
 
Total Posts:  252
Joined:  2008-06-23
 

Would you mind pasting your changes here? I have the same problem but I don’t know the difference between bad code and what the correct code is suppose to look like

 
Magento Community Magento Community
Magento Community
Magento Community
 
dcorrell
Jr. Member
 
Total Posts:  21
Joined:  2008-07-28
 

also, in app/code/core/Mage/Wishlist/Blocks/Links.php - the addWishlistLink() function causes pages not to validate (using the recently released “blank” skin)

around line 54

$parentBlock->addLink($text'wishlist'$texttrue, array(), 30null'class="top-link-wishlist"');

change to

$parentBlock->addLink($text'wishlist'$texttrue, array(), 30null'###class="top-link-wishlist"');

replace the ### with a blank space

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sebsemillia
Jr. Member
 
Total Posts:  3
Joined:  2010-10-26
 

Thx! Perfect!! this saved me a lot of time.. wink

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top