Hello, Max,
I an testing your comments.
In the Latest comment module some Lithuanian national characters at the end of the line do not show correctly.
Please, see attachment.
How can I fix that?
I an testing your comments.
In the Latest comment module some Lithuanian national characters at the end of the line do not show correctly.
Please, see attachment.
How can I fix that?
Hi andrius,
do they show correctly in the admin area ?
Regards
Max
do they show correctly in the admin area ?
Regards
Max
Hello,
No, characters are shown incorrect in Admin area too. But only at the end of the line where there is "..."
You can see the problem at my site: http://mem.lt/index.php/apg1l-apranga
No, characters are shown incorrect in Admin area too. But only at the end of the line where there is "..."
You can see the problem at my site: http://mem.lt/index.php/apg1l-apranga
Hi andrius,
Ahhh . . . the problem is that teh code is using substr() with UTF characters and it doesn't correctly find the character breaks.
If you have multi-byte string mbstring PHP extension installed then mb_substr would presumably work.
If not, then in the PHP Manual Notes for substr() there are a couple of alternatives suggested - functions that only break on spaces; and functions that try to recognise UTF characters correctly and only break on character boundaries.
Adding one of these would probably fix the problem.
Bob
Ahhh . . . the problem is that teh code is using substr() with UTF characters and it doesn't correctly find the character breaks.
If you have multi-byte string mbstring PHP extension installed then mb_substr would presumably work.
If not, then in the PHP Manual Notes for substr() there are a couple of alternatives suggested - functions that only break on spaces; and functions that try to recognise UTF characters correctly and only break on character boundaries.
Adding one of these would probably fix the problem.
// function to break on spaces
function str_stop($string, $max_length)
{
if ( strlen($string) > $max_length ){
$string = substr($string, 0, $max_length);
$pos = strrpos($string, " ");
if($pos === false) {
return substr($string, 0, $max_length)."...";
}
return substr($string, 0, $pos)."...";
} else {
return $string;
}
}
<?php
function utf8_substr($string, $start)
{
preg_match_all("/./su", $string, $ar);
if ( func_num_args() >= 3 ) {
$end = func_get_arg(2);
return join("", array_slice($ar[0], $start, $end));
} else {
return join("", array_slice($ar[0], $start));
}
}
?>
Neither of these are tested here - I think I've used the first function successfully before.Bob
Hello, Bob,
Thank you for an answer.
I am not so advanced user... Would you tell me exactly in which file and what place do I have to insert this code?
Thank you for an answer.
I am not so advanced user... Would you tell me exactly in which file and what place do I have to insert this code?
Hi andrius,
OK = let's try the Admin first and see if we can get a fix to work.
Please make a backup copy of admin.chronocomments.html.php and put it somewhere safe.
Open the original copy and go to line 211 - should be an empty line just before the last ?>
Paste this function in there
Go to line 87 which should read
Bob
OK = let's try the Admin first and see if we can get a fix to work.
Please make a backup copy of admin.chronocomments.html.php and put it somewhere safe.
Open the original copy and go to line 211 - should be an empty line just before the last ?>
Paste this function in there
// function to break on spaces
function str_stop($string, $dummy, $max_length)
{
if ( strlen($string) > $max_length ){
$string = substr($string, 0, $max_length);
$pos = strrpos($string, " ");
if($pos === false) {
return substr($string, 0, $max_length)."...";
}
return substr($string, 0, $pos)."...";
} else {
return $string;
}
}
there should then be two } before the function and still the ?> after it.Go to line 87 which should read
<td width="40%" align="left" ><?php echo substr($row->text, 0, 50).' .....'; ?></td>
and replace it with<td width="40%" align="left" ><?php echo str_stop($row->text, 0, 50).' .....'; ?></td>
Save the file and see if this works - if it doesn't we can try the other function.Bob
Hi,
I replaced the code, tried to enter comments administration and got this error message: "Parse error: syntax error, unexpected $end in /home/ecoauto/domains/mem.lt/public_html/administrator/components/com_chronocomments/admin.chronocomments.html.php on line 224"
Sorry, didn't help...
I replaced the code, tried to enter comments administration and got this error message: "Parse error: syntax error, unexpected $end in /home/ecoauto/domains/mem.lt/public_html/administrator/components/com_chronocomments/admin.chronocomments.html.php on line 224"
Sorry, didn't help...
Hi andrius,
Two possibilities, let's try once more. From line 206 on paste this code - the first couple of lines should overlap what is there now.
Bob
Two possibilities, let's try once more. From line 206 on paste this code - the first couple of lines should overlap what is there now.
</form>
<?php
}
// function to break on spaces
function str_stop($string, $dummy, $max_length)
{
if ( strlen($string) > $max_length ){
$string = substr($string, 0, $max_length);
$pos = strrpos($string, " ");
if($pos === false) {
return substr($string, 0, $max_length)."...";
}
return substr($string, 0, $pos)."...";
} else {
return $string;
}
}
}
?>
Bob
Hi Bob,
Changed the code, but still no luck...
I can see the same question marks. But no Fatal errors 🙂
Any other ideas?
Changed the code, but still no luck...
I can see the same question marks. But no Fatal errors 🙂
Any other ideas?
Hi andrius,
please open admin.Chronocomments.html.php and find around line 87 this line:
please replace it with :
now please test the admin area and let me know if the problem is solved ?
Regards,
Max
please open admin.Chronocomments.html.php and find around line 87 this line:
<td width="40%" align="left" ><?php echo substr($row->text, 0, 50).' .....'; ?></td>
please replace it with :
<td width="40%" align="left" ><?php echo JString::substr($row->text, 0, 50).' .....'; ?></td>
now please test the admin area and let me know if the problem is solved ?
Regards,
Max
Hi, Max,
Now the characters are shown correct in admin panel.
(note, that I changed only the 87 line and no other changes were made)
What should I change to correct the problem at the Front-end?
Now the characters are shown correct in admin panel.
(note, that I changed only the 87 line and no other changes were made)
What should I change to correct the problem at the Front-end?
Hi andrius,
Good catch by Max to find the Joomla solution - much better than the PHP functions.
I think that the front-end needs a change in line 57 of root/modules/mod_chronocomments/helper.php where
Bob
Good catch by Max to find the Joomla solution - much better than the PHP functions.
I think that the front-end needs a change in line 57 of root/modules/mod_chronocomments/helper.php where
substr(modChronocommentsHelper::censor(modChronocommentsHelper::bb2html(modChronocommentsHelper::cleanBB($commentx->text))), 0, $params->get( 'limittext', 0 ))
needs to becomeJString::substr(modChronocommentsHelper::censor(modChronocommentsHelper::bb2html(modChronocommentsHelper::cleanBB($commentx->text))), 0, $params->get( 'limittext', 0 ))
Bob
Hello,
Yes, problem solved 😀
Thank you for your help...
Now the special characters in the back-end and in the latest comment module front-end are shown correct 😀
Andrius S.
Yes, problem solved 😀
Thank you for your help...
Now the special characters in the back-end and in the latest comment module front-end are shown correct 😀
Andrius S.
Great news, thanks for letting me know!🙂
Regards,
Max
Regards,
Max
This topic is locked and no more replies can be posted.