This topic is locked
[SOLVED]

 custom truncate

2/19/2012 11:46:57 PM
PHPRunner General questions
C
chanpeter88 author

I am using phprunner 6.0
I want to add truncate field with more link in custom view. I don't know what the script for more link using javascript exactly like truncate field in misc .

C
cgphp 2/20/2012

Could you reformulate your question?

C
chanpeter88 author 2/20/2012

add the code in custom view to perform truncate field function as below ;
$length_limit = 25; //limit to this number of characters

$actual_length = strlen($value); //count characters in the $value

$mytext = $value;

$mytext = substr($mytext,0,$length_limit ); //picks up characters from left to right starting at position zero all the way to 25
//Truncate if exceeds $chars value!

if($actual_length <= $length_limit){

$value = $mytext;

} else {

$mttext = $mytext."...";

$value = $mytext;

$value.= " <a href=javascript:void(0);>more</a>";

}
href link not work to show full text of field. pls advise

C
cgphp 2/20/2012
$length_limit = 25; //limit to this number of characters

$actual_length = strlen($value); //count characters in the $value

$original_text = $value;

$truncated_text = substr($value,0,$length_limit); //picks up characters from left to right starting at position zero all the way to 25
//Truncate if exceeds $chars value!

if($actual_length <= $length_limit){

$value = $original_text;

} else {

$value = $truncated_text." ... <a href='javascript:void(0);'>more</a>";

}
C
chanpeter88 author 2/20/2012

Thank your updating my code.
However, the problem is on the hyperlink. I don't know what is the proper link to read the full content of field.
javascript:void(0) is my testing which is obtained from default truncate large field setting in misc.

C
cgphp 2/20/2012