Page 1 of 1

Closing tag </li> missing in nested lists

Posted: Thu 30. Nov 2006, 21:30
by chico_html
I found an error in the code generated by the list content type in phpwcms 1.2.8.
When a list is created and you have for instance:

Code: Select all

~Item1
~Item2
~~Item2a
~~Item2b
~Item3
the following HTML is created:

Code: Select all

<ul>
	<li>Item1</li>
	<li>Item2
		<ul>
			<li>Item2a</li>
			<li>Item2b</li>
		</ul>
	<li>Item3</li>
</ul>
I noticed the absence of the closing tag of the 2nd item of the list. According to the html standard, that <li> tag should be closed after the inner <ul>...</ul>. So the correct html should be:

Code: Select all

<ul>
	<li>Item1</li>
	<li>Item2
		<ul>
			<li>Item2a</li>
			<li>Item2b</li>
		</ul>
	</li>
	<li>Item3</li>
</ul>
I found a solution that worked for me, but I'm not sure of its side effects.
In include/inc_front/content/cnt100.article.inc.php I moved line 119 out of the 'if' wrapping that line.

The original code (starting at line 112):

Code: Select all

if($clist_diff_next > 0) {
	$crow["acontent_text"] .= "</li>\n</ul>\n";
	if($clist_diff_next > 1) {
		for($i=0; $i < (abs($clist_diff_next)-1); $i++) {
			if(!$i) $crow["acontent_text"] .= "</li>\n";
			$crow["acontent_text"] .= "</ul>\n";
		}
		$crow["acontent_text"] .= "</li>\n";
	}
}
The modified code:

Code: Select all

if($clist_diff_next > 0) {
	$crow["acontent_text"] .= "</li>\n</ul>\n";
	if($clist_diff_next > 1) {
		for($i=0; $i < (abs($clist_diff_next)-1); $i++) {
			if(!$i) $crow["acontent_text"] .= "</li>\n";
			$crow["acontent_text"] .= "</ul>\n";
		}
	}
	$crow["acontent_text"] .= "</li>\n";
}
Regards

Posted: Thu 30. Nov 2006, 23:17
by Oliver Georgi
this is solved in my release here ;-)