WPCubed Product Support

How to get text and hyperlink data?

Hi:

Using WPTools 6 I need to get to a certain line of text that has two hyperlinks, and form a string with plain text plus sign '&', plus hyperlink hidden data, just after the text that corresponds to each hyperlink.

For example, I need to have the following string:

"I want to travel to Berlin&[HLK_Data1] and to Munich&[HLK_Data2] this year".

Can you please help me?

Kind regards,

Carlos Borrero

#1 ♥ 0
8k Views 3 users read 3 min
support

Using CodeListTags You can get a lit of all hyperlink objects, access the objects, parent paragraphs, embedded text. You can load and save text from and to the object and delete the objects by freeing them.

TParagraph.DeleteMarkeChar is used to also delete the placeholder.

#2 ♥ 0

I was trying to wrap, the hyperlink value within the <a> tag of html. But the gridview wants us to add hyperlink as a control to the cell. The other approach I was trying is create and add the hyperlink class to the datarow directly (in datatable) and then binding the dataset to the grid, but somehow, the gridview was not displaying the hyperlink column. That was a bit strange to me. But anyways bohunkus, you have given a clean way.
The other thing I was also trying to check is: Get the e.Row.Cells[1].Text's column name. So then, I can check for column name and only then I will add the hyperlink control. This way, I can use the same gridview for other data presentation purpose. Because, I am anyways binding the created dataset to the gridview i.e. programmatically, instead of hard coding the columns.

#3 ♥ 0
support

There is also an interesting demo - Tasks\GridMode". It shows how to create a table from a dataset. Maybe an inspiration.

#4 ♥ 0

What is wrong with the following code?, it doesn't work, LocalHyperlinkObjects.Count is allways 0, no mather how many hyperlinks are in the document:

LocalHyperlinkObjects := WPRichText.CodeListTags(wpobjHyperlink, '*ALL*', true);
try
  for j := 0 to LocalHyperlinkObjects.Count - 1 do begin
     LocalHyperlinkObjects[j].Free;
  end; // for ...
finally
  LocalHyperlinkObjects.Free;
end;

Kind regards,

Carlos Borrero

#5 ♥ 0
support

Hi,

Count will not be 0 if there are links. But the code is also not correct since it will only delete one of the two objects.

You can remove the links

var  LocalHyperlinkObjects : TWPTextObjList;
begin
LocalHyperlinkObjects := WPRichText1.CodeListTags(wpobjHyperlink, '*ALL*', true);
try
  for j := 0 to LocalHyperlinkObjects.Count - 1 do begin
     LocalHyperlinkObjects[j].EndTag.Free;
     LocalHyperlinkObjects[j].Free;
  end; // for ...
finally
  LocalHyperlinkObjects.Free;
end;
WPRichText1.ReformatAll(true, true);
#6 ♥ 0
This category is archived. No new posts are possible.