Rich text field in view for browser

I would like to display the customized view for a web browser.

The view displays subject, date, author, and the body. Subject, date, and author can be displayed perfectly. However, I got the problem displaying the body (as this is a rich text field).

Does anyone have the solution to this issue? Helps would be highly appreciated.

Thank you.

Regards,

Melissa

Subject: RE: Rich text field in view for browser

Unless you store an abstract of the Notes rich text field in a summary field, you can’t do it with a view. You could create a report agent that creates the HTML but it might be a bit of work depending whether you need the formatting, images etc.

Subject: RE: Rich text field in view for browser

Thank you for the quick response.

Would you give me any pointers to any sites that might have the agent code creating the HTML for the abstract field of the rich text?

Thank you very much.

Best Regards,

Melissa

Subject: RE: Rich text field in view for browser

Not offhand, but you probably would have to either use DXL or the Midas toolkit from Genii Software, so modify your searches with those.

Subject: SOL’N: Create Abstract frm Rich Text field & HTML Tag Stripper

Not sure if any of these are what you’re after, but if not, maybe other folks will find these useful.

  1. I haven’t tried this out – it’ll remove the HTML tags for you from a text

field – From: http://www.javascriptkit.com/script/script2/removehtml.shtml

  1. If you need to do this “on the fly” as the page is being submitted, try

something like this. We had to create a 150 character text-only version of an

RT field (JS not as consise as above for sure).

function getAbstract()

{

var form = document.forms[0];

var getAbs = form.Abstract.value;

 if (getAbs == "" )

 {

  getAbs = form.BodyText.value;

  //need to parse out html tags

  var openPos;

  var closePos;

  var cleanStringPre;

  var cleanStringPost;

  //get started

  openPos = getAbs.search(/</);

  closePos = getAbs.search(/<*>/);

  cleanStringPre = getAbs.slice(0, openPos);

  cleanStringPost = getAbs.substr(closePos + 1);

  //then loop through the string until all <> tags have been removed

  while (cleanStringPost.match(/</))

     {

      openPos = cleanStringPost.search(/</);

      closePos = cleanStringPost.search(/<*>/);

      cleanStringPre = cleanStringPre + ' ' + cleanStringPost.slice(0, 

openPos);

      cleanStringPost = cleanStringPost.substr(closePos + 1);

      }

  //cleanStringPre may still have &nbsp; in it marking blank spaces, so 

remove them while setting to getAbs var

  getAbsFull = cleanStringPre.replace(/&nbsp;/g, ' ')

  if (getAbsFull.length > 150 )

     {

       getAbs = getAbsFull.slice(0, 151) + '...'

       }

  else

      {

      getAbs = getAbsFull

       } 

   }

form.Abstract.value = getAbs;

}

Then in form submitDocument() function:

_getEditAppletData();

//write applet data to the plain text field, BodyText, by taking it from the

Domino field that stores the applet content

form.BodyText.value = form.Body.value;

getAbstract();

  1. Or, if you want to do this enmasse in a periodic LS agent, you can loop

through your documents …

	If Not abstractFound Then

		If doc.HasItem("BodyText") Then

			'get body text into abstract, parse html, cut 

at 150 characters

			origBodyText = doc.BodyText(0)

			interimText = HTMLTagStripper(origBodyText, " ")

			parsedBodyText = Fulltrim( atReplaceSubstring( 

atReplaceSubstring( interimText, " ", " " ), “&nbsp”, " " ) )

			If Len(parsedBodyText) >149 

Then

				abstractText = Left$(parsedBodyText, 
  1. & " …"

       	Else
    
       		abstractText = parsedBodyText
    
       	End If
    
       	Set item = doc.ReplaceItemValue("Abstract", 
    

abstractText)

			Call doc.Save(True, True)

		Else

			If doc.HasItem("Body") Then

				'get body content into body text,

				Set mime = doc.GetMIMEEntity("Body")

				If Not( mime Is Nothing ) Then

					doc.BodyText =  

mime.ContentAsText

			'get body text into abstract, parse html, cut 

at 150 characters

					origBodyText = doc.BodyText(0)

			

				interimText = 

HTMLTagStripper(origBodyText, " ")

					parsedBodyText = Fulltrim( 

atReplaceSubstring( atReplaceSubstring( interimText, " ", " " ), “&nbsp”,

" " ) )

					If Len(parsedBodyText) >149 

Then

						abstractText = 

Left$(parsedBodyText, 150) & " …"

					Else

						abstractText = 

parsedBodyText

					End If

					Set item = 

doc.ReplaceItemValue(“Abstract”, abstractText)

					Call doc.Save(True, True)

				End If

			End If

		End If

	End If   ' ... if not abstractFound ...

Const HTML_PATTERN$ = “" & “[” & "<][>]*” ’ having trouble pasting the

string in here as a literal … you can chg it to 1 string in your code

Function HTMLTagStripper( source As String, separator As String ) As String

Dim newSource As String

Dim beforeTag As String

Dim afterTag As String

Dim startPos As Integer

Dim endPos As Integer



While source Like HTML_PATTERN$ 

	startPos = Instr( source, "<" )

	endPos = Instr( source, ">" )

	If startPos > 1 Then

		beforeTag = Mid$( source, 1, startPos - 1 )

	Else 

		beforeTag = ""

	End If

	afterTag = Mid$( source, endPos + 1, Len( source ) )

	newSource = Trim$( beforeTag ) + separator + Trim$( afterTag )

	source = newSource

Wend

HTMLTagStripper = Trim$( source )

End Function

Subject: RE: SOL’N: Create Abstract frm Rich Text field & HTML Tag Stripper

Thanks for the response.

I will give it a try.

Regards,

Mel