Jump to content
TNG Community

List Forenames


vectis

Recommended Posts

I was looking into how I could generate a report showing the most popular forenames in my database. The plan was to have a descending list taking into account all forenames, whether they occurred first, second or wherever. I don't think I have the understanding of SQL to be able to do this yet.

Anyway, I then thought about adding a new menu item to show all forenames, in the same way as surnames. I've almost completed this now, you can see it if you visit my site at www.vectisjon.com.

The code was reasonably easy to implement, using the existing surnames files as templates and creating look-alikes for forenames (forenames.php, forenames-oneletter.php, forenames-all.php and forenames-100.php. I also had to add some new lines to text.php. It seems to work quite well.

It would be nice to expand this option to work better when people have multiple forenames, currently it counts John and John William separately, whereas I would prefer if optionally it counted all fornames as if they were separate names.

I do have 3 problems that I have yet to resolve, probably because this is now getting over my head. If anyone can help I'd be obliged.

(1) Where there is no forename entered in the database, I cannot get a list of the entries concerned. For surnames the query generated is http://www.vectisjon.com/familyhistory/sea...&tree=BAKER but I think there must be some clever piece of code somewhere that deals with [no surname] and I would need to replicate for [no forename]

(2) I had a few entries in the database (I use PAF offline) where I had entered the forename as ?, for some reason (presumably because of ascii encoding) it shows up as & (ampersand) on the displays. Minor problem but would still be nice to fix

(3) The code doesn't currently seem to hide living details, although there is code in the files to do so. I have preferences set to that living people only have their initials shown in stead of the full forename, but the code still counts the whole name. Privacy is not too much of an issue still because when you click on the forname of a living person it does not complete the search. Neverhless it would be nice to resolve this.

I am quite happy to share the files if anyone else is vaguely interested, tough I'm not quite sure how I could do this. Maybe this is a candidate for adding to the basic program?

Link to comment
Share on other sites

  • 2 years later...

I quite liked the idea of listing all the forenames in the tree. I can't see that vectis has shared his code, so I've had a go at amending the suranme pages to display forenames myself.

The attached file contains the 3 new files needed to display forenames, plus details of the changes you will need to make to text.php.

You can see the new pages on my site at http://www.stevenwillingale.com/tng/forenames.php

Cheers

Steven

* EDIT * 4th file added to download & orginal 3 amended - see rest of thread for details. I *THINK* this is now working properly!!

* EDIT * Further edits to correct errors highlighted below - 28/01/2009

* EDIT * Revised code now in my post further down the page

Link to comment
Share on other sites

Steven,

Very clever! I like this mod very much. Great idea vectis, and great follow through Steven.

Thanks for sharing the idea and the code!

/BobA

Just received notification of update to this topic, forgotten all about it. I didn't upload the code at the time because I didn't know how to. Not sure I do now either but will give it a go.

Steven, I think you need another file to complete the mod, forenames100.php. At the moment this is linked on your site to surnames100.php. There are also some broken links on some of the pages, but otherwise looks sound.

I see you have concluded in the same way as me, I would dearly love to find a way to improve the pages so that multiple forenames were counted separately, never did work that out

I'll have to try to dig out the changes I mdae to text files, but if it works I will upload the code.

Cheers

forenames.zip

Link to comment
Share on other sites

I'm going to sack my testers... :-D

You are right I've missed the 'forenames100.php' file.

I'll amend my upload once I've had a chance to look at the files again.

Dealing with multiple forenames is a bit beyond me as well.......

Cheers

Steven

Link to comment
Share on other sites

Barry Ennever

Excellent mod guys. Just a thought that it may be better to add the new text to your cust_text file as Darrin may update the standard text file at a future date and may not include your mod.

I think you may have a few bugs still tho:

1) clicking on a firstname in "firstnames-all.php" initiates a search for a last name

2) clicking on "Main firstname page" in the same file looks for firstnames.php instead of forenames.php (renaming forenames.php to firstnames.php will fix)

Hope this helps

Link to comment
Share on other sites

Deffinitely sack the testers!!!

Two "Main firstname page" links (calling firstnames.php) do not work (404 error); these are on:

firstnames-all.php and firstnames-oneletter.php

The other "Main firstname page" link (calling forenames.php), on forenames100.php, does work.

So, where does the code have to be altered in firstnames-all.php and firstnames-oneletter.php?

Otherwise, Steven, thanks for a VERY useful mod.

Graham

Link to comment
Share on other sites

Going back to some of vectis issues, I've sorted the SQL to show only 'first' names, ie

John Frederick Smith

John Brown

John Robert Jones

will all be listed as John on the firstname pages.

As I've sacked my testers :-D and to avoid me releasing iffy code, I'll not post the files just yet, but if someone can look at the files on my site for errors that would be appreciated. I'll have another test tomorrow and if all is OK i'll post the files then. My original files are as is, the new 'one forename only' files are

http://www.stevenwillingale.com/tng/forename.php

http://www.stevenwillingale.com/tng/firstn...-oneletter.php

http://www.stevenwillingale.com/tng/firstname-all.php

http://www.stevenwillingale.com/tng/forename100.php

The forenames1 page has some test code that displays the SQL so you can see how i've done this.

Also I think I've identified the code used to deal with the [no forename] issue (vectis's point 1). This seems to be controlled by line 247 in search.php but I've not had a chance to play with this bit yet.

Cheers

Steven

EDIT

URLs changed as I've tided up the names, also the [no forename] issue is now fixed. Once I'm happy their are no bugs I'll post the code, probably over the weekend

Link to comment
Share on other sites

Herewith the code for the forenames pages.

I've included the code to display either a single forname, or all forenames. This also includes the code changes needed to search.php to deal with 'no forename'.

I think these are bug free!

Steven

EDIT : I've revised the files again, see later post!

Link to comment
Share on other sites

Barry Ennever

Hi Steven, there's one minor inconsistency that you may be able to help out with:

the main forename(s).php page returns the top 30 names with counts but clicking on these names returns a different count ie the main page counts names "beginning with" while the search returns "names containing" so producing different results.

Rgds

Link to comment
Share on other sites

I spotted this as well but decided to leave as is.

The reason is the when you click the link is does a search for that name appearing anywhere in the forename feild, rather than just that name on its own. So clicking the 'John' link will return 'John', John Robert' and 'Michael John' (even on the single forename version).

I'm not entirely sure why as the surname page seems to do an 'equals' whereas the forename pages does a 'contains'. Vectis orginal version of the fornames page seems to have the same issue.

I'll try and review the code over the next few days and see if I can work it so it does an 'equals' (actually thinking about it, 'starts with' would be more appropriate), however my time for playing with TNG is decreasing as I've now restarted my University studies.

Cheers

Steven

Link to comment
Share on other sites

I spotted this as well but decided to leave as is.

The reason is the when you click the link is does a search for that name appearing anywhere in the forename feild, rather than just that name on its own. So clicking the 'John' link will return 'John', John Robert' and 'Michael John' (even on the single forename version).

I'm not entirely sure why as the surname page seems to do an 'equals' whereas the forename pages does a 'contains'. Vectis orginal version of the fornames page seems to have the same issue.

I'll try and review the code over the next few days and see if I can work it so it does an 'equals' (actually thinking about it, 'starts with' would be more appropriate), however my time for playing with TNG is decreasing as I've now restarted my University studies.

Cheers

Steven

Steven, I 'm not sure but I think I did this deliberately, because what I was originally trying to achieve was to find all forenames, regardless of whether they were first, second or third names etc.

I also can't work out what the fix is for the [no forenames] issue. Looking on your site this seems to bring up a list of forenames (Alice, Amy, etc) so not sure you have it working either.

Going back to my original "wish" I like your mod to get just the first forename, though it is not what I was originally trying to figure out. My original idea was that if someone was called John William Thomas Smith, that this would add to the count for John, William and Thomas (hence my first paragraph above). This was to try to find which really is the most popular forneames, or usefully to be able find anyone that had a particular forename, whether it be the first, second, third etc.

Anyway, Uni studies are more important that TNG, so keep up the studying :)

Link to comment
Share on other sites

Vectis,

I think the [no forenames] is working, its my data thats wrong. Although all the names (Alice, Amy, etc) are first names, these are actually stored in the surname field, the first name field being empty. (This being an issue with Family Tree Maker, which treats a single name entered as a surname, and is thus carried over to TNG on import).

From having a quick review of how the searches work, I think replacing the 'equal' statement in the code to 'startswith' will get the results to return just the selected name. ie in forename.php line 69


            $linkstr .= "<a href=\"$search_url" . "myfirstname=$nosurname&amp;lnqualify=equals&amp;mybool=AND$treestr\" class=\"snlink\">$text[nofirstname]</a>";
would become

            $linkstr .= "<a href=\"$search_url" . "myfirstname=$nosurname&amp;fnqualify=startswith&amp;mybool=AND$treestr\" class=\"snlink\">$text[nofirstname]</a>";

Also think you may need to change lnqualify to fnqualify. Similar snipits of code are in this and the other files. No time to test but I'm sure someone else can test & verify.

I'm with you now with regards to counting the forename, regardless of where they appear. I think this will be rather involved to acheive, but not impossible. I'll add it to the to do list, although it may take a while to come up with a solution.

Cheers

Steven

Link to comment
Share on other sites

Picking up on Barrys’ point, following discussions with some of my users, I changed the behaviour of the search function.

The forenames page now does an ‘equals’ search and the forname page does a ‘starts with’, therefore, the search results return the same number of people listed on the forename(s) pages, which makes a lot more sense.

Revised files attached. Hopefully I've now put this one to bed. 8-)

Cheers

Steven

forenames.zip

Link to comment
Share on other sites

  • 3 years later...
swissgenealogy

Hi all,

I was wondering if someone would cooperate with me to revise the first names page (http://tng.lythgoes.net/wiki/index.php?title=First_Names)?

Original Author is Steven Willingale (http://www.stevenwillingale.com/tng/index.php). Many thanks for that.

I have packed my current (BETA) version to a mod.

Unfortunately I am a rookie with PHP, so I need all the help I can get.

These are the points that I want to improve:

1. Would it be possible to display the forenames with bar chart like surnames.php does?

I have already implemented these point - as best I could. Most of the time I did not know what I'm doing. I've only played around with surnames.php - without understanding the code.

Maybe someone could check whether the code is correct now or not?

This is the next step:

2. Would it be possible to split up fornames into two pages - male and female ?

If I am not mistaken, this is the code in which the AND function need to be integrated.

$query = "SELECT ucase( $binary substring_index($surnamestr, ' ',1) ) as firstname, substring_index($surnamestr, ' ',1) as lowername, count( ucase($binary substring_index(firstname, ' ',1) ) ) as lncount FROM $people_table $wherestr GROUP BY lowername ORDER by lncount DESC LIMIT 30";

3. Would it be possible to place a form at the botton of forename.php, in which you can write a forename, push "Go" and which is linked to an extern forname pages?

For example: http://www.vorname.com/name,$variable.html).".html (original address: http://www.vorname.com/name,Ingo.html).

4. Would it be possible to summarize different forames (Johann + John + Johannes + ...)

(less important, because it looks like it is problematic. like we discussed here: http://lythgoes.net/pipermail/tngusers2_ly...er/042863.html)

Thanks

Ingo

forenames_v9.0.3.0.zip

Link to comment
Share on other sites

  • 2 months later...

Installed the mod without any problem, but when I go to the firstname.php page I get the following error:

Cannot execute query: SELECT ucase( substring_index(TRIM(CONCAT_WS(' ',lnprefix,forename) ), ' ',1) ) as forname, substring_index(TRIM(CONCAT_WS(' ',lnprefix,forename) ), ' ' ,1) as lowername, count( ucase( lastname ) ) as lncount FROM tng_people WHERE gedcom = "1" AND lastname != "" GROUP BY lowername ORDER by lncount DESC, lastname LIMIT 30

When I start the firstname100.php file it works fine.

PS I will translate this mod into Dutch. 8)

Link to comment
Share on other sites

This is my updated mod for TNG 9.1.1

It uses the 'new' TNG layout along with the graphs

Hi Steven

I have found text variable errors in

forenames-all.php (line 69)

and

forename-all.php (lines 69 and 71)

where texts in the sub-head are are referring to surnames

Link to comment
Share on other sites

I'm not entirely sure why forename is not working for you, however I have changed the code slightly.

Can you replace the forename/forenames files with those in the attached zip and see if the pages now display correctly. If they do I'll repackage the entire cfg file?

Thanks

Steven

EDIT : see post below for latest cfg files

Link to comment
Share on other sites

I have found text variable errors in

forenames-all.php (line 69)

and

forename-all.php (lines 69 and 71)

where texts in the sub-head are are referring to surnames

The text variables $text['sortedalpha'] and $text['totalnames'] in forename-all.php and forenames-all.php do not display. To get this to work I have added them to the cust_text.php sections of the cfg file.

Link to comment
Share on other sites

Marco,

Please send me the Dutch translations and I'll include in the revised cfg file (please note the couple of additions spotted by Graham).

Graham,

Thanks for spotting the problems with the text variables, I'll include these in a revised cfg shortly

Cheers

Steven

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...