Search Forums
Forums
Kiwitrees on Twitter
    Tags

    theme, Favourites 3.0.0, tree, locked out, title, access roles, fixing errors, Require visitor authentication, flags, research tasks, index, Add a wife, performance, MAC, not married, transifex, block, GEDCOM, folder, reports, fancy image bar, dates, Favourites, Export/Import, 3.2.0, colors theme, responsive menus, tags, validation, 1939 Register, simpl_research, ID notes, descendants, request, timeout, CHR, batch update, census assistant, styles, time, spouse, road map, error, simpl_pages, notes, xmas, margin, googlemaps, editor, image, privacy, CREM, events of close relatives, Support/Bug Reporting, errors, Google Maps, users, php 5.6, individual resource, html

    Topic:   Print code for All individual facts  

    This topic contains 9 replies, has 2 voices, and was last updated by kiwi kiwi 3 weeks, 2 days ago.

    Viewing 10 posts - 1 through 10 (of 10 total)
    • Author
      Posts
    • #10167

      PierreF
      Participant

      8 posts

      Hi all,
      I would like to print some of the individual fact

      I tried, for the Birth day to use this php code : get_user_setting(WT_USER_ID, \’birth_day\’);
      It doesn’t seems to work at all !
      What is the expression I have ti use ?
      How can I get (print_r) All the individual facts in a array ?

      Thanks for your Help !!!!!!!!!!!!!

      #10171
      kiwi
      kiwi
      Keymaster

      1643 posts

      Hi Pierre.

      Your question is a little worrying and puzzling. You haven’t explained what your intentions are. It is helpful to know what you aim to achieve and why. Then a better answer can be given. There might be simple answers you are not aware of. Re-writing the code would normally only be the last possible solution.

      I cannot understand why you would try “get_user_setting(WT_USER_ID, \’birth_day\’);”.
      1 – “user” means a registered member of your website (you are a “user” when you log in), so there are no facts, no birth dates stored or anything similar.
      2 – The variable “WT_USER_ID” is either from webtrees or a very old version of kiwitrees. It doesn’t exist in kiwitrees anywhere now.
      3 – there is no such string as ‘birth_day’ in the entire code system.

      The expression you need to use will vary, depending on the purpose you want to use it for, so I cannot easily answer that question without more explanation.

      Regarding the array you ask about, in simple terms the answer would be “getIndiFacts(): But on its own, it will not work. You need to define the individual you want the facts for, link to the correct controller and have the page you are calling it from correctly structured.

      What is your experience level with php? At first glance, your questions suggest you are trying something that will require very advanced capabilities.

      Nigel
      My personal kiwitrees site is www.our-families.info
      #10191

      PierreF
      Participant

      8 posts

      You’re right.
      I tried to use an old code and I’m not a php expert.
      So let forget my first question.

      But if I go further in another way, I would like to split the $indifacts array in order to define and use individualy the Day, Month, Year of each event

      I tried to write that code :

      foreach ($indifacts as $fact) {
      $date_event = $fact->getDate();
      $date_eventY = $date_event->date1->y;
      $date_eventM = $date_event->date1->m;
      echo “Day Event : “.$date_eventY;
      echo “Month Event : “.$date_eventM;
      }

      Because the $indifacts array gives that :
      KT_Date Object ( [qual1] => [date1] => KT_Date_Gregorian Object ( [y] => 1967 [m] => 1 [d] => 8 [minJD] => 2439499 [maxJD] => 2439499 ) [qual2] => [date2] => => )

      How can I define the Month, Days, Year of each event ?

      Thanks for your help !!

      #10192

      PierreF
      Participant

      8 posts

      I think that I need to explain exactly what I want to do : I want to create a special display view that shows each month of the person life
      For that, I have create a loop for each month between the first event (wich is the Birth Date) to the last one.
      For each month, I need to verify if there is an event
      If the is one, I print it !
      That all

      In my old Webtrees app, I used this part of code (wich still works) :
      print_add_new_fact_timeline($controller->record->getXref(), $indifacts, ‘INDI’,$date1M,$date1Y);

      where $date1M and $date1Y are the Month and Year date of my loop !!

      What do I need to use to replace the print_add_new_fact_timeline($controller->record->getXref(), $indifacts, ‘INDI’,$date1M,$date1Y); code ?
      Thanks for your help !!

      #10193
      kiwi
      kiwi
      Keymaster

      1643 posts

      Thanks for the explanation. That helps a lot, although I’m still not sure what the purpose is. I hope when you get it working you will share it. I would like to see it.

      There are only a couple of minor errors in your piece of code above, mainly incorrect quote marks. This version does work, and hopefully, help you take it further:

      		$indifacts = $controller->getIndiFacts();
      		foreach ($indifacts as $fact) {
      			$date_event = $fact->getDate();
      			$date_eventY = $date_event->date1->y;
      			$date_eventM = $date_event->date1->m;
      			$date_eventD = $date_event->date1->d;
      			echo $fact->getTag() . ': ';
      			echo 'Day Event : ' . $date_eventD . ' – ';
      			echo 'Month Event : '. $date_eventM . ' – ';
      			echo 'Year Event : '. $date_eventY . '<br />';
      		}
      

      I have added some simple formatting just to help read the output. That doesn’t have to be used.

      In the file /modules_v4/personal_facts/module .php the line that prints the facts is line 106:

      print_fact($fact, $controller->record);

      The function print_facts() is the first (and largest) in the file /includes/functions/finctions_print_facts.php. It does the complicated work of reading and arranging each different type of fact/event, checking privacy rules, separating family facts from individual facts and many other things. But you should find more hints in there about displaying details.

      Nigel
      My personal kiwitrees site is www.our-families.info
      #10194

      PierreF
      Participant

      8 posts

      Thanks a lot, it works …. but for part of what I want to do.

      The part that doesn’t works is that I want to print only the events of the month of my loop, not all the events in each loop.

      Example
      Event 1 : 1 January 1997 : wedding
      Event 2 : 30 January 1997 : Birth of my first child
      Event 3 : 15 April 1999 : Birth of my second child

      In my loop; on january 1997, I just want to print event 1 & 2, not event 3
      That’s why I need to give month & year params to the print_fact function

      Exactly as I was doing in my old function : $controller->record->getXref(), $indifacts, ‘INDI’,$date1M,$date1Y)
      where ,$date1M & $date1Y where my loop date !
      How can I do to print only the month correspondating events ?

      Hope I’m clear enough !!!

      #10195
      kiwi
      kiwi
      Keymaster

      1643 posts

      I think you would need to write your own version of the function print_fact () to create a version that accepts the extra variables, then use “if” statements to only include facts that match those.

      I would guess that your old solution must have had a similar solution.

      It would be a simple case of copying the existing function print_fact () into your new module, with a different name, and extend its definition from

      function print_fact(KT_Event $fact, KT_GedcomRecord $record) {

      to something like

      function myprint_fact(KT_Event $fact, KT_GedcomRecord $record,$date1M,$date1Y) {

      and adding the necessary “If”s.

      Are you able to send me a copy of your old module?

      Nigel
      My personal kiwitrees site is www.our-families.info
      #10196

      PierreF
      Participant

      8 posts

      Hi,
      You’ll find attached two files :
      One of the timeline_fact old webtrees module
      One of the print_fact_timeline_aqv function I created, based on the print_fact function

      The part of code I’ve customed is usually shown by <– AQV …..-> comments in order to isolate good and bad (mine) code.
      As you’ll see, I’m not a php expert !!!!

      I add also 2 pictures of my actual 2 different ways of displaying the individual events based on webtrees app :
      dispaying-events-webtrees.png -> the normal way
      dispaying-events-expected.png -> my personal display adaptation

      Thanks for your help !
      See you !
      Pierre

      Attachments:
      #10198

      PierreF
      Participant

      8 posts

      Sorry, I forget the 2 fother files !!
      Here they are !

      Attachments:
      #10201
      kiwi
      kiwi
      Keymaster

      1643 posts

      Sorry, I forget the 2 fother files !!!

      Pierre, your file timeline_facts.rar was rejected by this site. Not sure why, as .rar files are allowed. Perhaps you just changed the suffix of .php to .rar? THat is still a php file 🙂

      Can you email it to me (admin@kiwitrees.net).

      Nigel
      My personal kiwitrees site is www.our-families.info
    Viewing 10 posts - 1 through 10 (of 10 total)

    You must be logged in to reply to this topic.