Closing tag </li> missing in nested lists

Use GitHub to post bug reports and error descriptions for phpwcms. Describe your problem detailed!
Locked
chico_html
Posts: 28
Joined: Wed 18. Oct 2006, 15:07
Location: Montevideo - Uruguay

Closing tag </li> missing in nested lists

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9888
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

this is solved in my release here ;-)
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Locked