- Posts: 14
Question Displaying fact in personal maner on FactsTab
- pfelix
- Topic Author
- Offline
- New Member
Less
More
4 years 3 months ago #1
by pfelix
Displaying fact in personal maner on FactsTab was created by pfelix
Hi all,
I would like to display the facts in a personal maner :
I would like to print a table with a line for each month between the birth of the person and 1 year after the last event ($indifacts)
For each month, I check (but how in the indifacts array ?) if there is an event and print it if so
I need something like that .... but I don't know how to write it !!
How could I do it in the easiest way ?
for each month from MonthBirth to LastFact {
echo "Month $Month";
foreach ($indifacts as $fact) {
if date $indifact = date Month 1 {
echo $indifact;
}
$Month++;
}
I've tried to do it but I think I've included to many nested loops !!!
FIRST, I try to extract the Month ot the Birth :
foreach ($indifacts as $fact) {
if ($fact->getTag() =='BIRT') {
echo "Fact : ".$fact->getTag();
if (preg_match('/\n2 DATE (.+)/', $fact->getGedcom(), $match)) {
echo "Date = " . $match[1]."";
$date_naissance = $match[1];$BirthDate = explode(" ", $match[1]);
$Birth_day = $BirthDate[0];
$Birth_Month = $BirthDate[1];
$Birth_Year = $BirthDate[2];
AND after I print a loop :
for ($i = $iStart; $i < $iEnd + 86400; $i = strtotime ('+1 month', $i) ) {
...
}
IN wich I look after an event
foreach ($indifacts as $fact) {
if ....
loop
BUT IT'S TO COMPLICATED !!!!!
Do you have a idea of how I can do it easely ?
Thanks for your help !!!
Pierre
I would like to display the facts in a personal maner :
I would like to print a table with a line for each month between the birth of the person and 1 year after the last event ($indifacts)
For each month, I check (but how in the indifacts array ?) if there is an event and print it if so
I need something like that .... but I don't know how to write it !!
How could I do it in the easiest way ?
for each month from MonthBirth to LastFact {
echo "Month $Month";
foreach ($indifacts as $fact) {
if date $indifact = date Month 1 {
echo $indifact;
}
$Month++;
}
I've tried to do it but I think I've included to many nested loops !!!
FIRST, I try to extract the Month ot the Birth :
foreach ($indifacts as $fact) {
if ($fact->getTag() =='BIRT') {
echo "Fact : ".$fact->getTag();
if (preg_match('/\n2 DATE (.+)/', $fact->getGedcom(), $match)) {
echo "Date = " . $match[1]."";
$date_naissance = $match[1];$BirthDate = explode(" ", $match[1]);
$Birth_day = $BirthDate[0];
$Birth_Month = $BirthDate[1];
$Birth_Year = $BirthDate[2];
AND after I print a loop :
for ($i = $iStart; $i < $iEnd + 86400; $i = strtotime ('+1 month', $i) ) {
...
}
IN wich I look after an event
foreach ($indifacts as $fact) {
if ....
loop
BUT IT'S TO COMPLICATED !!!!!
Do you have a idea of how I can do it easely ?
Thanks for your help !!!
Pierre
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
4 years 3 months ago - 4 years 3 months ago #2
by fisharebest
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Replied by fisharebest on topic Displaying fact in personal maner on FactsTab
There is no simple solution.
There are many complications.
e.g. other calendars
1 EVEN
2 DATE @#DFRENCH R@ 01 VEND 0012
e.g. some calendars have leap months as well as leap days
e.g. date ranges
1 EVEN
2 DATE BET 1900 AND 2000
e.g. individuals with no dates
1 BIRT
2 PLAC England
1 DEAT
2 PLAC France
e.g. invalid dates
1 BIRT
2 DATE 1950
1 DEAT
2 DATE 1920
If you want to try, then here are some functions that might help you:
$sorted_facts = $individual->facts([], true);
$birth_year = $individual->getEstimatedBirthDate()->minimumDate()->convertToCalendar('gregorian')->year();
$death_month = $individual->getEstimatedDeathDate()->maximumDate()->convertToCalendar('gregorian')->month();
$month = new GregorianDate('', 'FEB', '2000');
while ($month->year() !== $end_year && $month->month() !== $end_month) {
// Do something with $month.
$next_month = $month->nextMonth();
}
There are many complications.
e.g. other calendars
1 EVEN
2 DATE @#DFRENCH R@ 01 VEND 0012
e.g. some calendars have leap months as well as leap days
e.g. date ranges
1 EVEN
2 DATE BET 1900 AND 2000
e.g. individuals with no dates
1 BIRT
2 PLAC England
1 DEAT
2 PLAC France
e.g. invalid dates
1 BIRT
2 DATE 1950
1 DEAT
2 DATE 1920
If you want to try, then here are some functions that might help you:
$sorted_facts = $individual->facts([], true);
$birth_year = $individual->getEstimatedBirthDate()->minimumDate()->convertToCalendar('gregorian')->year();
$death_month = $individual->getEstimatedDeathDate()->maximumDate()->convertToCalendar('gregorian')->month();
$month = new GregorianDate('', 'FEB', '2000');
while ($month->year() !== $end_year && $month->month() !== $end_month) {
// Do something with $month.
$next_month = $month->nextMonth();
}
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Last edit: 4 years 3 months ago by fisharebest.
Please Log in or Create an account to join the conversation.
- pfelix
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
3 years 11 months ago #3
by pfelix
Replied by pfelix on topic Displaying fact in personal maner on FactsTab
In fact, I would like to do the same thing than in the "Timeline" (/timeline.php).
The only difference would be that I want to create a div for each month (JAN, FEB, MAR, APR ... ) in wich I would display the facts !
How can I do thant ?
Thaks for your help !
The only difference would be that I want to create a div for each month (JAN, FEB, MAR, APR ... ) in wich I would display the facts !
How can I do thant ?
Thaks for your help !
Please Log in or Create an account to join the conversation.