// June 22nd, 2009 // No Comments » // Uncategorized
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Warning: implode() [
function.implode]: Invalid arguments passed in
/home/hshare27/public_html/wp-content/plugins/devformatter/devgeshi.php on line
100
Working with datviews and Sharepoint designer often, i come across the need to show the first few words of a rich text column often, especially the “body” tag say of a blog.
It would be pretty easy using the ddwrt:limit function or the substring() for any other column, but in this case the body tag is actually in html format. The “Limit” function then brings us back ugly part html which is no good to display.
Luckily there is a way. There are essentially two steps here:
1. strip the html
2. return the first ‘x’ words
I used a simple template to strip the html, here it is:
| 01 |
|
| 02 |
|
| 03 |
|
| 04 |
|
| 05 |
|
| 06 |
|
| 07 |
|
| 08 |
|
| 09 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 | |
Then we need to return the first ‘x’ words:
| 01 |
|
| 02 |
|
| 03 |
|
| 04 |
|
| 05 |
|
| 06 | 07 | ">
|
| 08 |
|
| 09 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 | 16 | string-length(substring-before($TextData, ' ')) > 0)">
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 | |
Then just under your
line:
Credit given: Thanks to Mark’s post for the help.