Forums / General Questions / Annoying Home Page Validation (Just one Error)

Annoying Home Page Validation (Just one Error)

Views: 1,638

Results 1 to 14 of 14
15 Jul 2012, 2:27 PM
#1
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Annoying Home Page Validation (Just one Error)

I can't seem to figure out what's causing this error on the home page of www.silkblooms.co.uk:

"line 443 column 3 - Error: document type does not allow element "ul" here; assuming missing "li" start-tag"

Can anyone see what's causing it? It's quite annoying to have just one validation error on the home page. Would love to have none :)

15 Jul 2012, 3:05 PM
#2
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

It looks to me as though you need a <li> just before the <ul> in line 443. There's a closing </li> in line 473 without an opening tag

I've just tried it and it seems to work.

Simon

15 Jul 2012, 11:11 PM
#3
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

simon1066:

It looks to me as though you need a <li> just before the <ul> in line 443. There's a closing </li> in line 473 without an opening tag

I've just tried it and it seems to work.

Thanks for the reply. New question. Which file is generating line 473? I tried to track it down and it was leading me to /includes/functions/extra_functions/categories_dressing_functions.php as this is one of the few files with a <ul>

Adding a <li> just before it didn't cure the problem, it created another (2 validation errors)........ sop probably not the correct file?

16 Jul 2012, 5:57 AM
#4
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

All I did to cure the error was to input the <li> into the source at validator.w3.org - it then validated ok, I've had similar problems like this in the past and as li/ul's can be from different files it can be pretty difficult to track down the correct location for such missing tags. I can only suggest to perhaps find the file that has the closing </li> (on line #473 in the 'show source' section of the validator) and see if that file is an appropriate place to add the missing tag to.

Sorry can't be of more help here.

Simon

16 Jul 2012, 6:04 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Annoying Home Page Validation (Just one Error)

Actually, you need a closing </ul> before the <ul> that's on line 443.

<!--// bof: chcategories //-->
<div class="leftBoxContainer" id="chcategories" style="width: 190px">
<h3 class="leftBoxHeading" id="chcategoriesHeading">Wedding Flowers</h3>
<div id="chcategoriesContent" class="sideBoxContent">
<ul class="catLinks"><li><a class="category-links" href="http://www.silkblooms.co.uk/index.php?main_page=products_new">New Products ...</a></li>
</ul><ul>
<li><div class="catBoxHeading3"> <a href="index.php?main_page=coming_soon">Coming Soon ...</a></div></li>
<li class="cat-top"><a class="cat-not-selected-text" href="http://www.silkblooms.co.uk/index.php?main_page=index&cPath=349">Hire Products ...</a></li>
<li><hr class="catBoxDivider1" /></li>
<li class="cat-bolder"><a class="cat-not-selected-text" href="http://www.silkblooms.co.uk/index.php?main_page=index&cPath=1">All Products ...</a></li>
[B]<ul>[/B]
<li class="cat-products"><a class="cat-not-selected-text" href="http://www.silkblooms.co.uk/index.php?main_page=index&cPath=1_6">Bridal Bouquets</a></li>
```And that code appears to be generated from within the "chcategories" addon you're using.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jul 2012, 3:44 PM
#6
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

Something's telling me it's in this file, but I can't seem to fix it. Everything I try seems to make it worse. Can you see anything in this file that can be causing it?

<?php
/**
* @copyright Copyright 2009 Glenn Herbert
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.gnu.org/licenses/ GNU Public License V3.0
* includes/functions/extra_functions/categories_dressing_functions.php
* Categories Dressing v2.6  - Glenn Herbert (gjh42)   - 20090128 
*/

function cat_active_level_manage($path) {
 $skip_cat = 0;
 if (defined('CAT_BOX_ACTIVE_LEVEL')) {
   $cat_box_active_level = explode('|',constant('CAT_BOX_ACTIVE_LEVEL'));
   $current_top = (int)$_GET['cPath'];
   $iteration_top = (int)$path; // set = this iteration's topcat
   $cat_depth = substr_count($path,'_');
   //tests for various kinds of skipping - more can be added
   $skip_cat = $skip_cat + ($cat_box_active_level[0] == 1 and $current_top != $iteration_top)?1:0;
   $skip_cat = $skip_cat + ($cat_box_active_level[0] == 2 and $current_top != $iteration_top and $current_top != 0)?1:0;
   $skip_cat = $skip_cat + ($cat_box_active_level[1] > $cat_depth and $cat_box_active_level[0] != 2)?1:0;
   $skip_cat = $skip_cat + ($cat_box_active_level[2] < $cat_depth)?1:0;
 }//defined
 return $skip_cat;
}


function cat_ul_manage($current_path, &$prev_cat_depth, $new_group) {
 $ul_content = '';
 $cat_depth = substr_count($current_path,'_');
 if ($cat_depth > $prev_cat_depth) {
   $ul_content .= str_repeat('<ul>',(($cat_depth - $prev_cat_depth) - $new_group)) . "\n";
 } elseif ($cat_depth < $prev_cat_depth) {
   $ul_content .= str_repeat('</ul>',(($prev_cat_depth - $cat_depth) + $new_group)) . "\n";
 } else {
   $ul_content .= $new_group?'</ul>':'';
 }
 $ul_content .= $new_group?'<ul id="catGroup' . $current_path . '">' . "\n":'';
 $prev_cat_depth = $cat_depth;
 return $ul_content;
}

function cat_box_heading($current_path) {
 $heading_content = '';
 $new_group = 0;
 if (defined('CAT_BOX_HEADING_' . $current_path)) {
   $cat_box_heading = explode('|',constant('CAT_BOX_HEADING_' . $current_path));
   if ($cat_box_heading[0]) {
     $new_group = 1;
   }
   if ($cat_box_heading[1]) {
     $heading_content .= '<hr class="catBoxDivider' . $cat_box_heading[1] . '" />' . "\n"; 
   }
   if ($cat_box_heading[2]) {
     //display image if exists for category name in current language - with title tag
     $heading_content .= file_exists(DIR_WS_TEMPLATE . 'buttons/' . $_SESSION['language'] . '/' . $cat_box_heading[2]) ? '<div class="catBoxHeadingImg">' . zen_image(DIR_WS_TEMPLATE . 'buttons/' . $_SESSION['language'] . '/' . $cat_box_heading[2], $cat_box_heading[3]) . '</div>' . "\n":$cat_box_heading[3] . "\n";
   }
   $i=4;
   while ($i<(sizeof($cat_box_heading)-1)) {
     $heading_content .= '<div class="catBoxHeading' . $cat_box_heading[$i+1] . '">' .  $cat_box_heading[$i] . '</div>' . "\n";
     $i = $i+2;
   }
 }
 return array($new_group,$heading_content);
}
   
function cat_name_display($cat_name_display, $current_path) {
 $cat_img_bg = '';
 //display image if exists for category name in current language - with title tag
 if (file_exists(DIR_WS_TEMPLATE . 'buttons/' . $_SESSION['language'] . '/catimg' . $current_path . '.gif')) {
   $cat_name_display = zen_image(DIR_WS_TEMPLATE . 'buttons/' . $_SESSION['language'] . '/catimg' . $current_path . '.gif', '', '', '', 'title="' . $cat_name_display . '"'); 
 //display background image if exists for category name in current language - with title tag
 } elseif (file_exists(DIR_WS_TEMPLATE . 'buttons/' . $_SESSION['language'] . '/catbg' . $current_path . '.gif')) {
   $cat_name_display = zen_image(DIR_WS_TEMPLATE_IMAGES . 'pixel_trans.gif', '', '100%', '100%', 'title="' . $cat_name_display . '"');
   $cat_img_bg = ' catBg' . $current_path;
 } else {
   $cat_img_bg = '-text';//append to main classname
 }
 return array($cat_img_bg, $cat_name_display);
}

function cat_box_subtext($current_path) {
 $subtext = '';
 if (defined('CAT_BOX_SUBTEXT_' . $current_path)) {
   $cat_box_subtext = explode('|',constant('CAT_BOX_SUBTEXT_' . $current_path));
   $subtext .= '<div class="catBoxSubtext' . $cat_box_subtext[1] . '">' . $cat_box_subtext[0] . '</div>' . "\n";
 }
 return $subtext;
}
?>
16 Jul 2012, 4:29 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Annoying Home Page Validation (Just one Error)

Replace the obsolete v2.6 of Categories Dressing with the latest released v2.7.3 and this error will be eliminated. You don't need to replace the categories_dressing_defines.php; there might be some new stock defines you could add to that file, I don't remember exactly what changed between those versions. You would need to make the correct settings to activate the desired switch case in the new categories_dressing_functions.php. See the readme for more info.

16 Jul 2012, 4:40 PM
#8
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

Thanks for replying Glen. I tried to upgade to the latest version some time ago and it was proving a bit tricky for me. Can't remember exactly what it was doing but it was going to take me a while to try and fix it back to how we need it. Is there a simpler way to just inset a closing </ul> in the file to fix the validation error as I'd prefer to just stick with the v.2.6 which works beautifully, otherwise.

16 Jul 2012, 11:57 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Annoying Home Page Validation (Just one Error)

Compare these functions... you may be able to just swap the newer one in.
V2.6: ```php
function cat_ul_manage($current_path, &$prev_cat_depth, $new_group) {
$ul_content = '';
$cat_depth = substr_count($current_path,'_');
if ($cat_depth > $prev_cat_depth) {
$ul_content .= str_repeat('<ul>',(($cat_depth - $prev_cat_depth) - $new_group)) . "\n";
} elseif ($cat_depth < $prev_cat_depth) {
$ul_content .= str_repeat('</ul>',(($prev_cat_depth - $cat_depth) + $new_group)) . "\n";
} else {
$ul_content .= $new_group?'</ul>':'';
}
$ul_content .= $new_group?'<ul id="catGroup' . $current_path . '">' . "\n":'';
$prev_cat_depth = $cat_depth;
return $ul_content;
}

V2.7.3:```php
function cat_ul_manage($current_path, &$prev_cat_depth, $new_group) {
  $ul_content = '';
  $cat_depth = substr_count($current_path,'_');
  $group_id = ' id="catGroup' . $current_path . '"';
  if ($prev_cat_depth < 0) {//first item
    $ul_content .= str_repeat("\n" . '<ul><li>',$cat_depth) . "\n" . '<ul' . $group_id . '>' . "\n";
  } else {
    if ($cat_depth > $prev_cat_depth) {//deeper
      $ul_content .= str_repeat('<ul><li>',($cat_depth - $prev_cat_depth - 1)) . "\n" . '<ul' . $group_id . '>' . "\n";
    } elseif ($cat_depth < $prev_cat_depth) {//higher
       $ul_content .= str_repeat('</li>' . "\n" . '</ul>',($prev_cat_depth - $cat_depth)) . ($new_group?'</li>' . "\n" . '</ul>' . ($cat_depth > 0? '</li>' . "\n" . '  <li>':'') . "\n" . '<ul' . $group_id . '>':'</li>') . "\n";
    } else {//no depth change
      $ul_content .= '</li>' . ($new_group?"\n" . '</ul>' . ($cat_depth > 0? '</li>' . "\n" . '  <li>':'') . "\n" . '<ul' . $group_id . '>':'') . "\n";
    }
  }//if
  $prev_cat_depth = $cat_depth;
  return $ul_content;
}
17 Jul 2012, 12:04 AM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Annoying Home Page Validation (Just one Error)

Your tpl_categories.php should have this line just below the top comments:

$prev_cat_depth = -1;//do not alter

If it is not like that, replace the original with this version.

17 Jul 2012, 6:07 AM
#11
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

When I validated your page and corrected it with HTML tidy and then compared the code with the original I found that it added the extra <li> that I mentioned, adding this allowed the page to validated. Whether that's right or not, could you not try to add this tag as a workaround - unless of course it breaks something?

I mention this without a huge amount of knowledge so apologies if it's a dumb suggestion.

Simon

17 Jul 2012, 8:29 AM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Annoying Home Page Validation (Just one Error)

The code is dynamic and has to allow for a large number of possible ul/li configurations, so there is no one "spot" to just add a <li>.

17 Jul 2012, 8:37 AM
#13
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

I see, thanks Glenn

Simon

17 Jul 2012, 1:57 PM
#14
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Annoying Home Page Validation (Just one Error)

gjh42:

Compare these functions... you may be able to just swap the newer one in.
V2.6: ```php
function cat_ul_manage($current_path, &$prev_cat_depth, $new_group) {
$ul_content = '';
$cat_depth = substr_count($current_path,'_');
if ($cat_depth > $prev_cat_depth) {
$ul_content .= str_repeat('<ul>',(($cat_depth - $prev_cat_depth) - $new_group)) . "\n";
} elseif ($cat_depth < $prev_cat_depth) {
$ul_content .= str_repeat('</ul>',(($prev_cat_depth - $cat_depth) + $new_group)) . "\n";
} else {
$ul_content .= $new_group?'</ul>':'';
}
$ul_content .= $new_group?'<ul id="catGroup' . $current_path . '">' . "\n":'';
$prev_cat_depth = $cat_depth;
return $ul_content;
}

> V2.7.3:```php
function cat_ul_manage($current_path, &$prev_cat_depth, $new_group) {
  $ul_content = '';
  $cat_depth = substr_count($current_path,'_');
  $group_id = ' id="catGroup' . $current_path . '"';
  if ($prev_cat_depth < 0) {//first item
    $ul_content .= str_repeat("\n" . '<ul><li>',$cat_depth) . "\n" . '<ul' . $group_id . '>' . "\n";
  } else {
    if ($cat_depth > $prev_cat_depth) {//deeper
      $ul_content .= str_repeat('<ul><li>',($cat_depth - $prev_cat_depth - 1)) . "\n" . '<ul' . $group_id . '>' . "\n";
    } elseif ($cat_depth < $prev_cat_depth) {//higher
       $ul_content .= str_repeat('</li>' . "\n" . '</ul>',($prev_cat_depth - $cat_depth)) . ($new_group?'</li>' . "\n" . '</ul>' . ($cat_depth > 0? '</li>' . "\n" . '  <li>':'') . "\n" . '<ul' . $group_id . '>':'</li>') . "\n";
    } else {//no depth change
      $ul_content .= '</li>' . ($new_group?"\n" . '</ul>' . ($cat_depth > 0? '</li>' . "\n" . '  <li>':'') . "\n" . '<ul' . $group_id . '>':'') . "\n";
    }
  }//if
  $prev_cat_depth = $cat_depth;
  return $ul_content;
}

Replacing this code makes 51 errors, as opposed to 1.

my tpl_categories.php does not have this line: $prev_cat_depth = -1;//do not alter .... adding it seems to have zero effect.

It's ok Glen, don't waste any more of your time on this as it's just one little error. I know now that it's not just a case of slotting in a <li> somewhere as it's a dynamic code.