Wait a minute... This content is very very old. We no longer sell or support this theme version. New Topics
Version 9
0 points
Beginner
Hi all
I really like the EXCERPT field and want to encourage customers to write something into that field. But my add-listing page doesn’t show it (PremiumPress demo doesn’t either).
In case the first 200 characters of the normal description are displayed instead, can I do something that the text isn’t cut off in the middle of the word? I know php can do that but I don’t know where to put it:
[code title=””]<?php
$text = $fieldsObjects[‘field_text’]->data; // using the raw value of the text
if( strlen( $text ) < 200 ) {
echo $text; // if less than 200 chars, show the entire text
} else {
$cut_text = substr( $text, 0, 200 ); //cut at 200 chars
$last_space = strrpos( $cut_text, ” ” ); //find the position of the last space in the 200 chars text
$short_text = substr( $cut_text, 0, $last_space ); //cut again at the last space
$end_text = $short_text.”…”; // add three dots
echo $end_text;
}
?>
[/code]
Hi all
I really like the EXCERPT field and want to encourage customers to write something into that field. But my add-listing page doesn’t show it (PremiumPress demo doesn’t either).
In case the first 200 characters of the normal description are displayed instead, can I do something that the text isn’t cut off in the middle of the word? I know php can do that but I don’t know where to put it:
[code title=””]<?php
$text = $fieldsObjects[‘field_text’]->data; // using the raw value of the text
if( strlen( $text ) < 200 ) {
echo $text; // if less than 200 chars, show the entire text
} else {
$cut_text = substr( $text, 0, 200 ); //cut at 200 chars
$last_space = strrpos( $cut_text, ” ” ); //find the position of the last space in the 200 chars text
$short_text = substr( $cut_text, 0, $last_space ); //cut again at the last space
$end_text = $short_text.”…”; // add three dots
echo $end_text;
}
?>
[/code]
Thanks a lot!
Members Only Content
This reply is for PremiumPress customers only.
Login NowMembers Only Content
This reply is for PremiumPress customers only.
Login NowMembers Only Content
This reply is for PremiumPress customers only.
Login Now