-
AuthorPosts
-
librandi Friend
librandi
- Join date:
- February 2012
- Posts:
- 587
- Downloads:
- 89
- Uploads:
- 163
- Thanks:
- 123
- Thanked:
- 2 times in 2 posts
October 31, 2014 at 2:11 pm #202328hello,
in the russian version, although the intro text is set to 50 characters in some of the articles is not true look at the screen shot
jooservices Friendjooservices
- Join date:
- October 2014
- Posts:
- 8556
- Downloads:
- 0
- Uploads:
- 130
- Thanked:
- 1245 times in 1121 posts
October 31, 2014 at 2:26 pm #553789Hi there,
I have just checked but your site display as well.
And please note it’s 50 characters not words 🙂Thank you,
Viet Vulibrandi Friendlibrandi
- Join date:
- February 2012
- Posts:
- 587
- Downloads:
- 89
- Uploads:
- 163
- Thanks:
- 123
- Thanked:
- 2 times in 2 posts
October 31, 2014 at 3:49 pm #553792did you see the screen shoot?
jooservices Friendjooservices
- Join date:
- October 2014
- Posts:
- 8556
- Downloads:
- 0
- Uploads:
- 130
- Thanked:
- 1245 times in 1121 posts
November 3, 2014 at 2:49 am #553873Hi there,
Yes. It’ not much clearly your issue. Would you mind provide some note.Thank you,
Viet Vulibrandi Friendlibrandi
- Join date:
- February 2012
- Posts:
- 587
- Downloads:
- 89
- Uploads:
- 163
- Thanks:
- 123
- Thanked:
- 2 times in 2 posts
November 4, 2014 at 7:40 am #554082librandi Friendlibrandi
- Join date:
- February 2012
- Posts:
- 587
- Downloads:
- 89
- Uploads:
- 163
- Thanks:
- 123
- Thanked:
- 2 times in 2 posts
November 5, 2014 at 11:35 am #554253can anyone help me?
jooservices Friendjooservices
- Join date:
- October 2014
- Posts:
- 8556
- Downloads:
- 0
- Uploads:
- 130
- Thanked:
- 1245 times in 1121 posts
November 5, 2014 at 1:20 pm #554272Hi there,
Let me check your site. Please wait for moment.Thank you,
Viet Vujooservices Friendjooservices
- Join date:
- October 2014
- Posts:
- 8556
- Downloads:
- 0
- Uploads:
- 130
- Thanked:
- 1245 times in 1121 posts
November 5, 2014 at 2:00 pm #554277Hi there,
/**
* Method to truncate introtext
*
* The goal is to get the proper length plain text string with as much of
* the html intact as possible with all tags properly closed.
*
* @param string $html The content of the introtext to be truncated
* @param integer $maxLength The maximum number of charactes to render
*
* @return string The truncated string
*/
public static function truncate($html, $maxLength = 0)
{
$baseLength = strlen($html);// First get the plain text string. This is the rendered text we want to end up with.
$ptString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = false);for ($maxLength; $maxLength < $baseLength;)
{
// Now get the string if we allow html.
$htmlString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = true);// Now get the plain text from the html string.
$htmlStringToPtString = JHtml::_('string.truncate', $htmlString, $maxLength, $noSplit = true, $allowHtml = false);// If the new plain text string matches the original plain text string we are done.
if ($ptString == $htmlStringToPtString)
{
return $htmlString;
}// Get the number of html tag characters in the first $maxlength characters
$diffLength = strlen($ptString) - strlen($htmlStringToPtString);// Set new $maxlength that adjusts for the html tags
$maxLength += $diffLength;if ($baseLength <= $maxLength || $diffLength <= 0)
{
return $htmlString;
}
}return $html;
}
These code would cause little bit trouble with UTF-8 characters 🙂
Thank you,
Viet Vulibrandi Friendlibrandi
- Join date:
- February 2012
- Posts:
- 587
- Downloads:
- 89
- Uploads:
- 163
- Thanks:
- 123
- Thanked:
- 2 times in 2 posts
November 5, 2014 at 6:23 pm #554307thank you,
… and what can I do?Ninja Lead ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
November 6, 2014 at 3:26 am #554339<em>@librandi 451854 wrote:</em><blockquote>thank you,
… and what can I do?</blockquote>This belongs to mod_articles_category – default module of Joomla, you will need to hack in code to achieve that. Try with my tweak as below:
– Open modules/mod_articles_category/helper.php file
– Find and change
public static function truncate($html, $maxLength = 0)
{
$baseLength = strlen($html);// First get the plain text string. This is the rendered text we want to end up with.
$ptString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = false);for ($maxLength; $maxLength < $baseLength;)
{
// Now get the string if we allow html.
$htmlString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = true);// Now get the plain text from the html string.
$htmlStringToPtString = JHtml::_('string.truncate', $htmlString, $maxLength, $noSplit = true, $allowHtml = false);// If the new plain text string matches the original plain text string we are done.
if ($ptString == $htmlStringToPtString)
{
return $htmlString;
}// Get the number of html tag characters in the first $maxlength characters
$diffLength = strlen($ptString) - strlen($htmlStringToPtString);// Set new $maxlength that adjusts for the html tags
$maxLength += $diffLength;if ($baseLength <= $maxLength || $diffLength <= 0)
{
return $htmlString;
}
}return $html;
}
To
public static function truncate($html, $maxLength = 0)
{
$baseLength = mb_strlen($html);// First get the plain text string. This is the rendered text we want to end up with.
$ptString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = false);for ($maxLength; $maxLength < $baseLength;)
{
// Now get the string if we allow html.
$htmlString = JHtml::_('string.truncate', $html, $maxLength, $noSplit = true, $allowHtml = true);// Now get the plain text from the html string.
$htmlStringToPtString = JHtml::_('string.truncate', $htmlString, $maxLength, $noSplit = true, $allowHtml = false);// If the new plain text string matches the original plain text string we are done.
if ($ptString == $htmlStringToPtString)
{
return $htmlString;
}// Get the number of html tag characters in the first $maxlength characters
$diffLength = mb_strlen($ptString) - mb_strlen($htmlStringToPtString);// Set new $maxlength that adjusts for the html tags
$maxLength += $diffLength;if ($baseLength <= $maxLength || $diffLength <= 0)
{
return $htmlString;
}
}return $html;
}Please note that this change is applied directly to core module of Joomla so you should consider to take a backup of this change when update new Joomla version.
Let me know if it helps
1 user says Thank You to Ninja Lead for this useful post
librandi Friendlibrandi
- Join date:
- February 2012
- Posts:
- 587
- Downloads:
- 89
- Uploads:
- 163
- Thanks:
- 123
- Thanked:
- 2 times in 2 posts
November 9, 2014 at 9:29 am #554631thanks, now it works perfectly
great!!!AuthorPostsViewing 11 posts - 1 through 11 (of 11 total)This topic contains 11 replies, has 3 voices, and was last updated by librandi 10 years ago.
We moved to new unified forum. Please post all new support queries in our New Forum
Jump to forum