Description limitation causes layout issues IE/FF
Posted: 28 Feb 2010, 16:06
First, this is a fantastic module, thanks for all of your work!
I had a bug that took a while to track down, and although it's fairly particular, I thought I'd post my findings in case anyone else encounters this, or similar issues with the PhocaGalleryText library/wordDelete function.
When displaying descriptions in Category View Settings (List of Images), I encountered display errors in FF and IE. Part of the problem was due to the client's use of the default text editor in the Image description, which adds paragraph tags to the beginning and end of the description. The actual bug comes when the description exceeds the Number of Characters in Image Description limitation within the Phoca Gallery parameters.
The first problem is that any closing paragraph tag will be lost. This does not result in rendering errors, just dirty HTML code.
The second problem causes rendering issues in FF(validated in 3.5/3.6) and IE (validated in 8.0), although Chrome (4.0) and Safari (4.0) display properly (FF, IE, Safari validations in Win7 and OS X 10.5; Chrome validated in Win7). This occurs when the Description limitation truncates the content in the middle of a closing tag. Hence the Description string goes from:
to a truncated:
A fix (though not a great one, as it will fail if the user is actively adding HTML tags to the description) is below. In JOOMLA_ROOT/administrator/components/com_phocagallery/libraries/text/text.php --> wordDelete function:
Change:
To:
Hopefully this saves someone the time of troubleshooting.
I had a bug that took a while to track down, and although it's fairly particular, I thought I'd post my findings in case anyone else encounters this, or similar issues with the PhocaGalleryText library/wordDelete function.
When displaying descriptions in Category View Settings (List of Images), I encountered display errors in FF and IE. Part of the problem was due to the client's use of the default text editor in the Image description, which adds paragraph tags to the beginning and end of the description. The actual bug comes when the description exceeds the Number of Characters in Image Description limitation within the Phoca Gallery parameters.
The first problem is that any closing paragraph tag will be lost. This does not result in rendering errors, just dirty HTML code.
The second problem causes rendering issues in FF(validated in 3.5/3.6) and IE (validated in 8.0), although Chrome (4.0) and Safari (4.0) display properly (FF, IE, Safari validations in Win7 and OS X 10.5; Chrome validated in Win7). This occurs when the Description limitation truncates the content in the middle of a closing tag. Hence the Description string goes from:
Code: Select all
<p>My awesome picture description that is too long to display in the alotted area!</p> Code: Select all
<p>My awesome picture description that is too long to display in the alotted area!</Change:
Code: Select all
function wordDelete($string,$length,$end = '...') {
if (JString::strlen($string) < $length || JString::strlen($string) == $length) {
return $string;
} else {
return JString::substr($string, 0, $length) . $end;
}
}
Code: Select all
function wordDelete($string,$length,$end = '...') {
if (JString::strlen($string) < $length || JString::strlen($string) == $length) {
return $string;
} else {
if (strpos($string,"</") != false){
// This is only safe for the default editor's addition of </p> tags at the end of descriptions.
// It will fail if the user is entering custom HTML with multiple closing tags amidst the text.
$closetag = strstr($string,"</");
$string = substr($string,0,strpos($string,"</"));
return JString::substr($string, 0, $length) . $end . $closetag;
} else {
return JString::substr($string, 0, $length) . $end;
}
}
}