* Custom fact - html link partially pre-defined

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Custom fact - html link partially pre-defined

Post by Valkrider »

To put this in to context I will detail what I want to do.

On my Surname Study website I currently display a subset of the information in FH as a table. The CSV for this table is created by a custom query and then exported as a CSV and imported into the website.

I now want to add a url link to a specific page to each individual to display them as a family in a tree from the SVG Generator programme discussed on another thread.

The way I am currently doing this is time consuming as the url is manually entered into the table on the website. As a result I would like to automate the process.

I think that a simple custom fact (attribute rather than event) may do this but again it would be a manual process to add all the data. The format of the url is an html link so what I need is something like:

Code: Select all

<a href ="https://mydomain.com/tree1">Show</a>
. Is there a way to have

Code: Select all

<a href ="https://mydomain.com/">Show</a>
pre-defined in the custom fact and just add tree1 or tree2 etc when I add the fact?

Anyone got any bright ideas on an alternative method?
User avatar
DavidNewton
Superstar
Posts: 464
Joined: 25 Mar 2014 11:46
Family Historian: V7

Re: Custom fact - html link partially pre-defined

Post by DavidNewton »

You could set up a custom fact with an Auto Create note containing the partial link and then add a data reference to the note in your query.

David
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

What controls the link which needs to be added? Is is computable? If so you could set a flag for each Tree id or add the members of each tree a named list and use the fact they are in the list to set the value for the link remember you can concatenate strings in a query.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Jane

Thanks for the reply I could possibly make it computable using the Family ID as the unique identifier to the word Tree.

I will have a play.

David

Thanks I will look at that also
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

Depending on which family is correct something like this might work.

Code: Select all

=Text("<a href='http://www.mylink.com?id=" . RecordId(%INDI.FAMS>%) . ">Show</a>")
You might need to do a check for FAMS existing and use FAMC if it doesn't.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom fact - html link partially pre-defined

Post by tatewise »

Would it work better if, instead of Individual, it was a Family custom Attribute?
Then there would be one link per spouse Family and the Family Record Id is easier to obtain.
=Text("<a href='https://mydomain.com/tree" . RecordId(%FAM%) . ">Show</a>")

However, I have a recollection that any URL like that in a text field is 'adjusted' by the FH Website Wizard such that it displays literally as text <a href='https://mydomain.com/tree123>Show</a> instead of becoming an active hyperlink, unless you use the Improve Website or CD DVD HTML Plugin to convert that text into a URL hyperlink.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Mike

Thanks for that, it looks ideal. I do not want that text transformed my website will handle the translation I want the literal text / code inserted.

Quick question before I try it will it add it to children / how many generations will this auto add to?
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

The way I read your original request you were exporting a CSV for your website so the expression Mike gave will simply exist as a column in your exported CSV, so you would not need to add an attribute to any record, simply have a tree for each family.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Mike

I am having a problem with your suggestion.

My custom query is an Individual query so how do I show a custom Family attribute in the query? I can only see individual attributes in the query window.

Jane

That is what I thought but I tried Mikes code

=Text("<a href='https://mydomain.com/tree" . RecordId(%FAM%) . ">Show</a>"

The query window is showing an error
Capture7.JPG
Capture7.JPG (17.6 KiB) Viewed 11118 times
Any thoughts
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

As your Query is on individuals you will need to use the %INDI.FAMS>% or %INDI.FAMC>% as per my example.

You can't use %FAM% when working on a Individual Query.

Code: Select all

=Text("<a href='https://mydomain.com/tree" . RecordId(%INDI.FAMS>%) . ">Show</a>")
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Jane

Sorry I should have said I get exactly the same error with your expression.
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

Strange I it cut it out from a query to post it and just pasted it back from the web site and it worked fine.

Mikes is missing a closing bracket did you remember to add one?

You are using an Individual Query?
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Jane

Yes using an individual query. Is it a missing single ' as I can only see one in both yours and Mike's queries?
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom fact - html link partially pre-defined

Post by tatewise »

You are right there is a missing closing ' in all the examples, so try a variant where "' is a double then single quote:

=Text("<a href='https://mydomain.com/tree" . RecordId(%INDI.FAMS>%) . "'>Show</a>")
or
=Text("<a href='https://mydomain.com/tree" . RecordId(%FAM%) . "'>Show</a>")

But even that may be disrupted by other string quotes in the area of that text.

We seem to going off in various directions.

I think we need to better understand the process of getting from FH Project to website files.
A) Where is the 'expression' we have been proposing meant to be applied?
B) Which Individual webpages, or whatever, need the Show URL link?
How does the process work that gets from A) to B)?
i.e. What commands are you using to export and process the necessary data files?

The %FAM% style expression only works in Family contexts, i.e. Family record Facts, or Family type Queries, and NOT Individual Facts/Queries for which you need to go through the %INDI.FAMS>% or %INDI.FAMC>% route, but what about multiple spouses and maybe multiple parents that will need %INDI.FAMS[2]>%, etc.
Alternatively, a Fact type Query maybe is what you require?
Without understanding the process in more detail it is difficult to advise with confidence.
Clearly, you know your process, but we are coming to it afresh and don't know it.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Mike

I have a modified All Individuals Query that exports ID, Name, BMD dates and locations and Spouse Name. I run the query and export the result as a CSV file.

Ideally to this query I need to add an additional column with the html code in as per the original question.

It seems that I cannot create this link programatically using the suggested expressions either from you or Jane.

I am happy to, ideally, add this html code as a custom fact event or attribute if necessary.

It seems that this actually works :D

Code: Select all

=Text("<a href='https://mydomain.com/tree" . RecordId(%FAM%) . "'>Show</a>")
But it does generate a blank number where the person is an individual rather than part of a family. Is there any way to supress this?
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

What do you want to happen if they are unmarried, do you want to open the parents tree?

If you say what you want to happen the link can be conditioned to be blank or direct to the Family as Child for the person involved.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Jane

Ideally I would like all children included in the parents tree reference and if thay are 'island' individuals without parent or children than no link generated.

mmm thinking about that some more that may be a problem if I have multi generations in one family which I do. I think that the above would suffice for now and then I need to do some more thinking.
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

Code: Select all

=TextIf(IsTrue(Exists(%INDI.FAMC>%) or Exists(%INDI.FAMS>%)),Text("<a href='https://mydomain.com/tree".TextIf(Exists(%INDI.FAMC>%),RecordId(%INDI.FAMC>%),RecordId(%INDI.FAMS>%)). "'>Show</a>"))
I think this should use the Parents Family if it exists, else the Spouse Family or blank if no children or parents.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
Jane
Site Admin
Posts: 8508
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Custom fact - html link partially pre-defined

Post by Jane »

If you wanted to you could add attribute for any you want something else to happen and add a test for the attribute as well.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom fact - html link partially pre-defined

Post by tatewise »

That still does not cope with multiple Spouses.
Presumably those URL anchors link to a family group page of some sort?

Would it make sense to have multiple links in several columns, one per family group?
e.g. one for parents %INDI.FAMC>% and one for each partner/spouse %INDI.FAMS[1]>%, %INDI.FAMS[2]>%, et seq?
That would make the expressions so much simpler and transparent.
e.g. One expression per Query Column:
=CombineText( "<a href='https://mydomain.com/tree", RecordId(%INDI.FAMC>%), "'>Parents</a>" )
=CombineText( "<a href='https://mydomain.com/tree", RecordId(%INDI.FAMS>%), "'>Partner</a>" )
=CombineText( "<a href='https://mydomain.com/tree", RecordId(%INDI.FAMS[2]>%), "'>2nd Partner</a>" )
=CombineText( "<a href='https://mydomain.com/tree", RecordId(%INDI.FAMS[3]>%), "'>3rd Partner</a>" )

=CombineText(...) automatically outputs nothing when there is no FAMC/FAMS record and thus no Record Id.

A variant, instead of just Parents as the anchor name, would be to add their names:
Text("'>Parents " . %INDI.~FATH>% . " & " . %INDI.~MOTH>% . "</a>")
Similarly, for each Partner add their name, then you don't need the Spouse Name column:
Text("'>Partner " . %INDI.~SPOU>% . "</a>")
Text("'>Partner " . %INDI.~SPOU[2]>% . "</a>")
Text("'>Partner " . %INDI.~SPOU[3]>% . "</a>")

I have tried all those in an All Individuals based Query and all work OK, except single parent families produce imperfect 'names'.
i.e. There is an unwanted ampersand in the Parents names, and no name after Partner.
But with a bit more sophistication in the expressions I am confident that can be fixed too.

BTW:
This thread's Subject refers to HTML link, but the anchor URL are missing the .html part, so should be:
=CombineText( "<a href='https://mydomain.com/tree", RecordId(%INDI.FAMC>%), ".html'>Parents...</a>" )
to produce:
<a href='https://mydomain.com/tree123.html'>Parents...</a>

Furthermore, the Parent/Partner names may (rarely) include reserved characters that need to be converted to their protected form such as & < > etc, after being saved to CSV file.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Thanks Mike & Jane for all your help with this.

As regards a second / third spouses I use 3 queries one for this (don't have any 4th Spouses yet).

I don't need the .html as the CSV is processed on the website by the table plugin and just displays the url correctly.

I don't have any reserved characters at the moment but will keep an eye out for those.

A display example is at https://le-fever.org/tree1/ this is called from the first entry on this page https://le-fever.org/lefever-gb/ which shows the table.

This will considerably cut down on my work to produce each of the links BUT I will still have to produce each of the pages with the trees on. ;)

Thanks once again.
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom fact - html link partially pre-defined

Post by tatewise »

Are you using fhugdownloads:contents:utility_svg_family-tree_generator|> Utility ~ SVG Family-Tree Generator to produce the trees?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Valkrider
Megastar
Posts: 1563
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom fact - html link partially pre-defined

Post by Valkrider »

Yes I am Mike that is what I said at the start of the thread. I am displaying it on a Wordpress site using the SVG Wordpress Plugin.
Post Reply