-
AuthorPosts
-
September 4, 2014 at 12:35 pm #201071
Hi. In this page of my website http://www.famigliealcentro.it/index.php/about/about-2 I would like to insert a Read More in the preview description of the 4 contacts at the bottom of the page. In fact, if I put a readmore in the form that describes the contact, in the preview the template shows an horizontal line with the rest of the description below, without cutting it.
I would like to have a readmore button after about 4 or 5 rows of the description, as it does in the preview of the articles.
Another solution may be to move the View Profile link after 4 or 5 rows, but I don’t know how to do it.
Can you help me?
Thanks a lotNinja Lead ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
September 5, 2014 at 9:22 am #548437It does not support to cut text like as article page. But you can apply my customization below.
+ Open templates/ja_decor/html/com_contact/category/default_items.php file
Change
defined(‘_JEXEC’) or die;To
defined('_JEXEC') or die;
if(!function_exists(cut_string)) {
function cut_string($title, $max)
{
if($title!=''){
if(is_array($title)) list($string, $match_to) = $title;
else { $string = $title; $match_to = $title{0}; }$match_start = stristr($string, $match_to);
$match_compute = strlen($string) - strlen($match_start);if (strlen($string) > $max)
{
if ($match_compute < ($max - strlen($match_to)))
{
$pre_string = substr($string, 0, $max);
$pos_end = strrpos($pre_string, " ");
if($pos_end === false) $string = $pre_string."...";
else $string = substr($pre_string, 0, $pos_end)."...";
}
else if ($match_compute > (strlen($string) - ($max - strlen($match_to))))
{
$pre_string = substr($string, (strlen($string) - ($max - strlen($match_to))));
$pos_start = strpos($pre_string, " ");
$string = "...".substr($pre_string, $pos_start);
if($pos_start === false) $string = "...".$pre_string;
else $string = "...".substr($pre_string, $pos_start);
}
else
{
$pre_string = substr($string, ($match_compute - round(($max / 3))), $max);
$pos_start = strpos($pre_string, " "); $pos_end = strrpos($pre_string, " ");
$string = "...".substr($pre_string, $pos_start, $pos_end)."...";
if($pos_start === false && $pos_end === false) $string = "...".$pre_string."...";
else $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
}$match_start = stristr($string, $match_to);
$match_compute = strlen($string) - strlen($match_start);
}return $string;
}else{
return $string ='';
}
}
}
+ Call it to trim text
Find
<p>
<?php echo $item->misc; ?>
</p>Change to
<p>
<?php echo cut_string($item->misc, 50); ?>
</p>Let me know if it helps
September 8, 2014 at 9:36 am #548693It works!!!!
Thanks a lotNovember 6, 2014 at 3:41 pm #554442<em>@Ninja Lead 444426 wrote:</em><blockquote>It does not support to cut text like as article page. But you can apply my customization below.
+ Open templates/ja_decor/html/com_contact/category/default_items.php file
Change
defined(‘_JEXEC’) or die;To
defined('_JEXEC') or die;
if(!function_exists(cut_string)) {
function cut_string($title, $max)
{
if($title!=''){
if(is_array($title)) list($string, $match_to) = $title;
else { $string = $title; $match_to = $title{0}; }$match_start = stristr($string, $match_to);
$match_compute = strlen($string) - strlen($match_start);if (strlen($string) > $max)
{
if ($match_compute < ($max - strlen($match_to)))
{
$pre_string = substr($string, 0, $max);
$pos_end = strrpos($pre_string, " ");
if($pos_end === false) $string = $pre_string."...";
else $string = substr($pre_string, 0, $pos_end)."...";
}
else if ($match_compute > (strlen($string) - ($max - strlen($match_to))))
{
$pre_string = substr($string, (strlen($string) - ($max - strlen($match_to))));
$pos_start = strpos($pre_string, " ");
$string = "...".substr($pre_string, $pos_start);
if($pos_start === false) $string = "...".$pre_string;
else $string = "...".substr($pre_string, $pos_start);
}
else
{
$pre_string = substr($string, ($match_compute - round(($max / 3))), $max);
$pos_start = strpos($pre_string, " "); $pos_end = strrpos($pre_string, " ");
$string = "...".substr($pre_string, $pos_start, $pos_end)."...";
if($pos_start === false && $pos_end === false) $string = "...".$pre_string."...";
else $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
}$match_start = stristr($string, $match_to);
$match_compute = strlen($string) - strlen($match_start);
}return $string;
}else{
return $string ='';
}
}
}
+ Call it to trim text
Find
<p>
<?php echo $item->misc; ?>
</p>Change to
<p>
<?php echo cut_string($item->misc, 50); ?>
</p>Let me know if it helps</blockquote>
Brilliant, it’s work for me!
Thanks you guys, you help me couple day headache. -
AuthorPosts
This topic contains 4 replies, has 3 voices, and was last updated by ergcreative 10 years, 2 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum