Jump to content
TNG Community
Lee

tngToday (add-on script)

Recommended Posts

Lee    0
Lee

** UPDATE tngToday v2.6a ** (alpha) - currently being updated.

Now supports TNG version 11.x

DESC

tngToday provides "DataBox" tags that, when included within php pages, produce boxes of data pulled from your TNG database. The purpose is to produce small lists of data to be included in your genealogy home page, or any other TNG genealogy page.

IPB Image

NEW

Reworked the package a bit, noticed some heavy server hits during Statistics as well as a couple of dataBox reports (oldest living, etc). Adding caching to reduce those loads and speedup response time. The cache files are updated one a day, after that the script just reads them right from the cache file instead of querying the database (which would slow it down).

Added more options for display - see How2Use on the site to read specifics.

You can download it here or at the mytree.net (download).

[** Prior Details Below Posted Last UPdate **]

Brought today.php up to date and improved it a bit (I posted the original back in March 2005). It is now a single include with the addition of "DataBox Tags"

DataBox Tags available:

getBirthToday(), getMarriedToday(), getDeathsToday(), longestLived(), getStats() and diagToday().

Examples:

http://mytree.net/tng_today/

Details:

Today.php provides "DataBox" tags that, when included within php pages, produce boxes of data pulled from your TNG database. The purpose is to produce small lists of data to be included in your genealogy home page, or any other TNG genealogy page.

Today.php script *MUST* be included in display page for DataBox Tags to function.

example: <?php include '/gen/today.php'; ?>

Tags can be inserted as needed.

example: <?php longestLived(); ?>

Each DataBox Tag can use arguments; if none are used, defaults are used (width=100%)

Prior versions: thread here

* Version update *

Version 2.1

- Fixes error in Hide Living flag.

version 2.15

- $sPerson not made globel in getBirthToday() - Fixed.

- Argument MISSING Error Fixed - Arguments are now required by all tags, z=zero.

- Filter all results by tree defined in $myTree - Added.

- diagToday() tag added - to help with troubleshooting.

version 2.16

- Fixed Databoxes opened and not closed due to empty lists.

- Fixed Query in longestLived() function (query not supported by mysql prior to v4.1)

- Fixed Query in getStats() function (averageAge query not supported by mysql prior to v4.1)

- Optimized queries for older MySQL database engines.

- Added: notice if list returns empty.

TNGToday2.16.zip

tngToday2.2b.zip

tngToday2.6a.zip

Share this post


Link to post
Share on other sites
afoster    0
afoster

** UPDATE TNG Today v2.0 **

Now supports TNG version 6.x

Brought today.php up to date and improved it a bit (I posted the original back in March 2005). It is now a single include with the addition of "DataBox Tags"

DataBox Tags available:

getBirthToday(), getMarriedToday(), getDeathsToday(), longestLived() and getStats().

Examples:

http://mytree.net/tng_today/

Details:

Today.php provides "DataBox" tags that, when included within php pages, produce boxes of data pulled from your TNG database. The purpose is to produce small lists of data to be included in your genealogy home page, or any other TNG genealogy page.

Today.php script *MUST* be included in display page for DataBox Tags to function.

example: <?php include '/gen/today.php'; ?>

Tags can be inserted as needed.

example: <?php longestLived(); ?>

Each DataBox Tag can use arguments; if none are used, defaults are used (width=100%)

I've been trying to get this script to work and have run into quite a few error msgs. One of the questions I have is that if the today.php file is in the same folder as the file that I want to add the DataBox tags, should the include show like this: <? include 'today.php'; ?> rather than <? include '[path]/today.php'; ?>

Thanks.

Share this post


Link to post
Share on other sites
Lee    0
Lee

One of the questions I have is that if the today.php file is in the same folder as the file that I want to add the DataBox tags, should the include show like this: <? include 'today.php'; ?> rather than <? include '[path]/today.php'; ?>

Yes, if the today.php file is located in the same folder as the file that you are including it within, then the include statement would look like:

<?php include 'today.php'; ?>

the [path] is to indicate where you'd put the path to the file if needed.

lh

Share this post


Link to post
Share on other sites
rritger    0
rritger

Lee:

I tried out the Today.php script and it looks like it could be quite useful. Thanks!

I did have an issue:

I can't seem to get the switch to hide living links to work properly as it generated an error when I switched the value from "0" to "1". If left to '0' there are no errors but I'd rather not display living individuals.

Share this post


Link to post
Share on other sites
Lee    0
Lee

I tried out the Today.php script and it looks like it could be quite useful. Thanks!

I did have an issue:

I can't seem to get the switch to hide living links to work properly as it generated an error when I switched the value from "0" to "1". If left to '0' there are no errors but I'd rather not display living individuals.

I haven't tested that function since version 1 back in 2005 :) Will look at it tonight and get post a fix.

Thanks for the bug report.

Lee

---

http://mytree.net

Share this post


Link to post
Share on other sites
Lee    0
Lee

I can't seem to get the switch to hide living links to work properly as it generated an error when I switched the value from "0" to "1". If left to '0' there are no errors but I'd rather not display living individuals.

Found the problem. I will put up a new version with the fix already applied, but in the mean time you can patch it yourself:

Find the line (around line number 158):

if ($hLiving) { $sLstr = 'AND people.living=0'; }

and replace it with

if ($hLiving) { $sLstr = "AND $people_table.living=0"; }

thats all.

It's better to copy the new line and paste it as the replacement .. less chance to over look something.

Lee

---

http://mytree.net

Share this post


Link to post
Share on other sites
mlmckenzie    0
mlmckenzie

This is wonderful! I haven't tried it yet, but thanks!

Share this post


Link to post
Share on other sites
Bruce Roy    0
Bruce Roy

Found the problem. I will put up a new version with the fix already applied, but in the mean time you can patch it yourself:

Find the line (around line number 158):

if ($hLiving) { $sLstr = 'AND people.living=0'; }

and replace it with

if ($hLiving) { $sLstr = "AND $people_table.living=0"; }

thats all.

It's better to copy the new line and paste it as the replacement .. less chance to over look something.

Lee

---

http://mytree.net

Lee, I have tried that but still get the following error if living people are omitted:

Query ERROR: SELECT personID,firstname,lastname,birthdate,birthplace,YEAR(birthdatetr) AS lYear FROM tng_people WHERE month(birthdatetr) = 10 AND dayofmonth(birthdatetr) = 27 AND people.living=0 ORDER BY lYear

If I reset to include living people it works. If I log out I can see living people.

I have also uploaded your recent update which includes the above change, with the same result.

This is crucial for using the script as, like others, I do not wish to show birth and marriage details of living people.

Bruce

Share this post


Link to post
Share on other sites
Lee    0
Lee

Lee, I have tried that but still get the following error if living people are omitted:

Query ERROR: SELECT personID,firstname,lastname,birthdate,birthplace,YEAR(birthdatetr) AS lYear FROM tng_people WHERE month(birthdatetr) = 10 AND dayofmonth(birthdatetr) = 27 AND people.living=0 ORDER BY lYear

If I reset to include living people it works. If I log out I can see living people.

I have also uploaded your recent update which includes the above change, with the same result.

This is crucial for using the script as, like others, I do not wish to show birth and marriage details of living people.

Hi Bruce, sorry, I haven't uploaded the new version with the patch included yet. :)

Here is the patched version, but I still haven't posted it "officially" yet so please use the link below.

Lee, I have tried ..

Also Bruce, I noticed that your links are getting double slashes in the paths / links from the DataBox Lists .. I think you may have used a trailing backslash in your $URLpath values. Check it and see, but I think you may have $URLpath='/genealogy/'; and it should be $URLpath = '/genealogy';

Of course this is not related to the Living People issues.

Lee

---

http://mytree.net

TNGToday2.1.zip

Share this post


Link to post
Share on other sites
rritger    0
rritger

Lee:

I inserted the line you posted and made the switch to hide the living individuals. Everything works great now - thanks!!

FWIW, I made a slide modification to your code to have the links for birthdays go directly to the person's individual page versus the relationship chart. Thanks again for a very nice addition to my home page.

Share this post


Link to post
Share on other sites
Bruce Roy    0
Bruce Roy

Hi Bruce, sorry, I haven't uploaded the new version with the patch included yet. :)

Here is the patched version, but I still haven't posted it "officially" yet so please use the link below.

Also Bruce, I noticed that your links are getting double slashes in the paths / links from the DataBox Lists .. I think you may have used a trailing backslash in your $URLpath values. Check it and see, but I think you may have $URLpath='/genealogy/'; and it should be $URLpath = '/genealogy';

Of course this is not related to the Living People issues.

Lee

---

http://mytree.net

Lee,

I still have problems with hide living - different ones now. If I set hide living to yes, the Married List outputs </table> - nothing else. If I set it to no, all works OK.

I have set up an "index2" file at http://royroyes.net/genealogy/index2.php for working on this. The code is exactly as you have it with the testing query lines deleted. The current setting for hide living is "yes". I have changed the birthday list link to getperson rather than relationship... I'll put it back to your code when I get a chance to test it.

Bruce

Share this post


Link to post
Share on other sites
afoster    0
afoster

Lee,

I still have problems with hide living - different ones now. If I set hide living to yes, the Married List outputs </table> - nothing else. If I set it to no, all works OK.

I have set up an "index2" file at http://royroyes.net/genealogy/index2.php for working on this. The code is exactly as you have it with the testing query lines deleted. The current setting for hide living is "yes". I have changed the birthday list link to getperson rather than relationship... I'll put it back to your code when I get a chance to test it.

Bruce

I've tried to get this script to work, but I get the following error msg when I try to use the longestlived() DataBox. I have not tried any of the others, but can you tell me what I'm doing wrong?

Warning: Missing argument 1 for longestlived() in /home/xxxx/public_html/geneology/today.php on line 185

Query ERROR: SELECT personID, firstname,lastname, yearsold, totaldays FROM (SELECT personID, firstname, lastname, YEAR(deathdatetr) - YEAR(birthdatetr) AS yearsold, DAYOFYEAR(deathdatetr) - DAYOFYEAR(birthdatetr) AS daysold, IF(DAYOFYEAR(deathdatetr) AND DAYOFYEAR(birthdatetr) , TO_DAYS(deathdatetr) - TO_DAYS(birthdatetr), (YEAR(deathdatetr) - YEAR(birthdatetr)) *365) AS totaldays FROM tng_people WHERE birthdatetr != '0000-00-00' AND deathdatetr != '0000-00-00' AND SUBSTRING(birthdate, 3) NOT IN ('AFT', 'BEF', 'ABT', 'BET', 'CAL') AND SUBSTRING(deathdate, 3) NOT IN ('AFT', 'BEF', 'ABT', 'BET', 'CAL') ORDER BY totaldays DESC ) AS initSelect WHERE yearsold <115 ORDER BY totaldays DESC LIMIT 10

Share this post


Link to post
Share on other sites
Bruce Roy    0
Bruce Roy

Lee,

I still have problems with hide living - different ones now. If I set hide living to yes, the Married List outputs </table> - nothing else. If I set it to no, all works OK.

I have set up an "index2" file at http://royroyes.net/genealogy/index2.php for working on this. The code is exactly as you have it with the testing query lines deleted. The current setting for hide living is "yes". I have changed the birthday list link to getperson rather than relationship... I'll put it back to your code when I get a chance to test it.

Bruce

Further to my previous.

I went off to lunch with a friend, couple of glasses of red, came home several hours later - the page is working!

Highly recommended problem-solving strategy!

Bruce

Share this post


Link to post
Share on other sites
Bruce Roy    0
Bruce Roy

Further to my previous.

I went off to lunch with a friend, couple of glasses of red, came home several hours later - the page is working!

Highly recommended problem-solving strategy!

Bruce

Lee,

It occurred to me that omitting the year in the lists for living people would be a neat way of listing all birthdays and anniversaries without breaching total security/privacy concerns??

Just a thought for your next development??

Bruce

Share this post


Link to post
Share on other sites
cybercase    0
cybercase

Thanks for this version.

It work fine, I have however 1 problem with the tree parameter.

I have 2 trees defined in my database and normally allow only 1 tree. (CK01 & SC01)

So I define the tree on the today.php as 'CK01'.

Funny enough it also finds in 'Deaths today' persons in the other tree 'SC01' and displays them.

When I click on the link and it tries to go to Getperson.php ist shows the Tree 'CK01', but the person which it displays is in the other tree.

When I omit the tree parameter, it displays all persons correctly in all trees, but again cannot follow the link, as the tree is missing.

My suggestion: Try to include the "gedcom" field from "people" or "families" tables in the database to define the link to follow.

Regards

Cornelis Kuit

Share this post


Link to post
Share on other sites
mwilbers    0
mwilbers

Hi Lee,

I get an error on the getAverageQry too. It doesn't say what kind. Just "Query error"...

Maarten Wilbers

Share this post


Link to post
Share on other sites
haroldw    0
haroldw

this looks like a great add on and i have gotten to the point of putting on my server and including it in my index php. but the modification of template 5 [or anyother] is making me crazy. what is best source for learning the commands in php?

Share this post


Link to post
Share on other sites
Lee    0
Lee

I get an error on the getAverageQry too. It doesn't say what kind. Just "Query error"...

Hello Maarten,

Could you give me the settings you have defined within today.php so I may try and duplicate the error?

Obviously, do not include your db name or db password .. but please confirm that it is defined correctly.

Also, are you using Livetest.php?

I get an error on the getAverageQry too

You are not trying to use getAverageQry() as a Tag are you?

Thanks

Lee

Share this post


Link to post
Share on other sites
vectis    0
vectis

Thanks for this excellent add-on. I got it working relatively easily tonight, a bit of trial and error due to my limited php knowledge but really straightforward.

I have so far only put the Birthday query on my home page, works fine, but when I click on the person's name to take me to the relationship calculator page for the person it doesn't do what I expect. I expected it to calculate the relationship to "I1" (i.e. me) but it seems instead to calculate some other relationship (haven't quite figured out what yet).

Any ideas what may be wrong?

The page with the function inserted is at:

http://www.vectisjon.com/familyhistory/

Thanks

Jon

Share this post


Link to post
Share on other sites
Lee    0
Lee

It occurred to me that omitting the year in the lists for living people would be a neat way of listing all birthdays and anniversaries without breaching total security/privacy concerns?

Let me see if I understand you correctly.

You would like Today's Birthdays List to have an option to exclude the year so you could include living without revealing their age, right? I think I can add that to the next version.

You would like Today's Anniversary's List to have an option to exclude the year they were married for the simliar reasons? I can probably do that too in the next version.

Anything else?

lh

Share this post


Link to post
Share on other sites
Lee    0
Lee

I have so far only put the Birthday query on my home page, works fine, but when I click on the person's name to take me to the relationship calculator page for the person it doesn't do what I expect. I expected it to calculate the relationship to "I1" (i.e. me) but it seems instead to calculate some other relationship (haven't quite figured out what yet).

Copy and paste the lines from today.php that match the ones below:

// Person for relationship graph. (see results)

$sPerson = 'I1'; // the personID you want the results to graph relationship

For some reason your links do not have a value for the $sPerson ..

lh

Share this post


Link to post
Share on other sites
mwilbers    0
mwilbers

Hi,

Yes, I was using livetest to test today.php. I'm just usig the 2 files in the zip (attached), nothing else.

Thanks for taking the trouble!

Maarten

mw.zip

Share this post


Link to post
Share on other sites
Lee    0
Lee

For those that are waiting on a response from me, currently I am working on solutions for the following and should have something soon:

afoster

rritger

mlmckenzie

Bruce Roy

cybercase

mwilbers

haroldw

vectis

If you no longer have a problem, please let me know so I can remove your name from the list :)

Greetings

Lee

Share this post


Link to post
Share on other sites
vectis    0
vectis

Copy and paste the lines from today.php that match the ones below:

// Person for relationship graph. (see results)

$sPerson = 'I1'; // the personID you want the results to graph relationship

For some reason your links do not have a value for the $sPerson ..

lh

Thanks for the reply Lee. However I do have that line in my copy of today.php

// Person for relationship graph. (see results)

$sPerson = 'I1'; // the personID you want the results to graph relationship

As a workaround I have hard-coded I1 into the concatenation to create the url which works fine. I'm just puzzled why the line does not pick up the value from sPerson.

Share this post


Link to post
Share on other sites
Bruce Roy    0
Bruce Roy

Let me see if I understand you correctly.

You would like Today's Birthdays List to have an option to exclude the year so you could include living without revealing their age, right? I think I can add that to the next version.

You would like Today's Anniversary's List to have an option to exclude the year they were married for the simliar reasons? I can probably do that too in the next version.

Anything else?

lh

That would be great, Lee. The privacy/security issue is really important to many people in our trees. The options would seem to be to hook today.php into the login process so that only those with privileges can see the details of living people. Or, a complete list is produced without the year of birth or marriage for those who are living. In this last case, those who prefer not to show the names of living people to guests might not be inclined to want to use your script.

As someone whose server is on the east coast of the USA and many of whose family live in Australia and New Zealand, the today setting is anything like 15-18 hours behind. I have wondered how to get TNG to respond to the user's computer's today() setting rather than the server's, but I understand from others that this is not easy to do. In my Reports I have set up 48 hour birthday, marriage, death lists, but would like one day to get my head around a better solution. Perhaps another challenge for you??

Incidentally, I notice with the marriage anniversary that if only one party is living (and the 'hide living' option is set), the name of the deceased person appears nevertheless. I don't know that that is a problem so much as an oddity!

Thanks for sharing your script.

Bruce

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×