Jump to content
TNG Community
mahesh

TngApi Plugin for Wordpress (Version 3)

Recommended Posts

mahesh

TngApi Plugin for Wordpress (V 3)

A stand-alone plugin for Smooth integration with TNG to display genealogy data in Wordpress pages.

At last, I am (nearly) there!! Latest version of the plugin is available for beta testing. If you have a test site, I would really appreciate your help in testing this plugin.

You may download the latest release of the plugin Here.  There is also a pdf file Here with full details.

The plugin has several useful features:

  • Simple access to the TNG database from within Wordpress.
  • A convenient collection of shortcodes and functions for integrating TNG data into your Wordpress site.
  • A convenient way for users to submit data-additions and data-changes
  • A convenient way, for the administrator, to check and update TNG database from within Wordpress.
  • A convenient way, for the user, to upload default photo from the person page
  • A convenient way, for the user, to upload media and update media links
  • A custom shortcode directory, with a sample shortcode, to help you create and store your own custom shortcodes.

What’s New in TngApi V3

  • In previous versions, user submissions were emailed to the administrator. In Version 3.0, user submissions are stored in temporary Wordpress tables and email is sent to the administrator as before
  • Once checked, the administrator has one-click facility to transfer user-submissions to TNG database
  • The plugin now caters for multiple trees and privacy flags
  • Facility to track a customized special event is now implemented from the setup menu.

Requirements

  • PHP 5.3 or greater
  • Wordpress 3.8 or greater
  • TNG V9 or better
  • TNG installation in one directory below the base.
  • Same User name in Wordpress and TNG
  • User has logged in.

Demo
You may evaluate the plugin at my demo site
Apart from plug-ins for security and administration, the demo site uses

  • TngApi Version 3 to display data from TNG database and
  • Tngwp_frontend_user_functions Version 2 for Registration, Profile and Login / logouts.
  • PHP Version 5.4.38
  • Wordpress Version 4.1.1
  • TNG Version 10.1

 

On my demo site,

TNG database has 2 trees.
I have 2 users for demo purposes.
view is allocated to a specific tree (dummy tree)
viewtree is not allocated to a specific tree.

You may also see the plugin at my live site

On my live site, I am using

  • TngApi to display data from TNG database
  • TNG Wordpress Integration by Mark Barnes Version 2.1 to display TNG pages in Wordpress.
  • Tngwp_frontend_user_functions Version 2.1 by Heather Feuerhelm for Registration, Profile and Login / logouts.
  • Wordpress Version 3.6.1
  • TNG Version 9.1
  • TNG database has 1 tree only.
  • I have 1 user for demo purposes. User  = view, allocated to a specific tree

Please PM me or post here if you would like the password.

Issues

I couple of minor issues have cropped up since I uploaded the plugin to the demo site.

Edited by mahesh
re-edited to remove user name confusion

Share this post


Link to post
Share on other sites
mahesh

Couple of minor issues have now been resolved. The Latest version of TngApi plugin is now available for general release.
You may download the latest release of the plugin Here.

What does it do? Have a look,  Here

The site requires login.  You may use PW=tngview

 

 

Share this post


Link to post
Share on other sites
jayat1familytree

What is the login name to view??   i tried guest with pw=tngview and tngview with pw=tngview and neither worked

Share this post


Link to post
Share on other sites
mahesh

Hi Jay,

I did not want to put the  name and PW together in the same post. The user names are shown in the original post, above. Try view

 

Share this post


Link to post
Share on other sites
Mike Kelley

 

Mahesh,

Your API integration is really nice. I'd like to integrate that to my site when I get my other problems resolved.

Mike

 

Share this post


Link to post
Share on other sites
mahesh

Mahesh,

Your API integration is really nice. I'd like to integrate that to my site when I get my other problems resolved.

Mike

 

​Thanks Mike. It is a stand-alone plugin. So should work with or without any other type of wp integration of TNG pages. TI am not aware of any conflicts

Only issue  at the moment is tngwp_frontend_user_functions plugin by Heather which I use for login/logout. It does not login to TNG because it expects tng and wordpress in one database. Hopefully, Heather would get time to address that issue.

Good luck with sorting out your problems.

 

Share this post


Link to post
Share on other sites
Mike Kelley

​My WP and TNG are in the same database so this function works great for me.

Share this post


Link to post
Share on other sites
Mike Kelley

Hi Mahesh,

I extracted your TngApi to my plugin folder. My WP plugin page displays 2 plugins:

When I attempt to activate "tng api 3.0.3" or "tng-api" WP switches to a blank page displaying this text:

Cannot execute query: SELECT * FROM WHERE username='admin'

I can't get it to activate. What do you think I screwed up?

Thanks,

Mike

Share this post


Link to post
Share on other sites
mahesh

An apology is due Mike.

We had been working on this plugin for so long that we forgot about new user having blank settings page :-(

Latest release now accepts a blank setting page. I have also culled the phantom tng-api that appeared in your plugin page.

Plugin will install as TngApi-3.0.4 so you will have to delete the previous version.

Let me know how you get on.

Share this post


Link to post
Share on other sites
Mike Kelley

Mahesh,

No apologies necessary! Due to my lack of php knowledge I automatically assume I screwed something up! Ha Ha

You're providing me a gift just letting me try all your hard work.

It activated for me this time so fun time. I'll let you know my progress and get my site online soonest. Although, I am installing Win 10 first.

Just as a note the plugin text still says 3.0.3.

Thanks,

Mike

 

 

Share this post


Link to post
Share on other sites
mahesh

Pleased that it activated OK. I hope you find the plugin useful.

Just as a note the plugin text still says 3.0.3.

 Thanks for pointing that out. I have updated the version number.

Look forward to your comments.

Share this post


Link to post
Share on other sites
mahesh

You may download the latest release of the plugin Here.

What does it do? Have a look,  Here

The site requires login.  You may use PW=tngview

I have just noticed some failed attempts at logins to my Demo site. I do not think I did a good job of explaining​ login details.

There are 2 user names, you may use.

User Name = view (restricts user to 1 tree)
User Name =  viewtree (allows access to all trees)

Password in both cases is as shown above.

I hope that clarifies login details
 

Share this post


Link to post
Share on other sites
Mike Kelley

Hi Mahesh,

Most of my suggestions on based on the fact that my folder names for TNG and WordPress are different than yours. I love your family page user interface as it makes it so easy for the novice to add data. So I thought why not redirect all editing functions from TNG to your API which is why I tried the TNG genlib.php hack shown below.

Thank you for entertaining my suggestions,

Mike

 

Suggestions:

Search form shows a label called Array. I haven’t identified the cause yet.

Change all instances of TNGAPI personId to personID. This permits TNG to reliably pass data to TNGAPI family page without performing a search.

 

 

File:        genlib.php

Line:      380

Comment: Changes the TNG Edit and Suggest Tab to link to TNGAPI change page (Family). I don’t know if the TNG plugin custom menu could be adopted for this function. Also reads the WordPress function site_url() to properly link WordPress folder.

From:    $suggest_url = getURL( "suggest", 1 );

To:          $suggest_url = site_url('/family/','');

From:    $menu .= doMenuItem( $nexttab, $cms['tngpath'] . "$editstr" . "ID=$entityID&tree=$tree&cw=1\" target=\"_blank", "sugg", $text['edit'], $currpage, "" );

To:          $menu .= doMenuItem( $nexttab, "$suggest_url" . "?personID=$entityID&tree=$tree", "sugg", $text['edit'], $currpage, "" );

From:    $menu .= doMenuItem( $nexttab, "$suggest_url" . "enttype=$enttype&ID=$entityID&tree=$tree", "sugg", $text['suggest'], $currpage, "suggest" );

To:          $menu .= doMenuItem( $nexttab, "$suggest_url" . "?personID=$entityID&tree=$tree", "sugg", $text['suggest'], $currpage, "suggest" );

 

 

 

File: family.html.php

Line:  38+  

Comment: Need a function to extract TNG site folder name. Hard coding for now.

From:    $mediaID = "../tng/img/male.jpg";

To:          $mediaID = "../gen/img/male.jpg";

From:    $mediaID = "../tng/img/female.jpg";

To:          $mediaID = "../gen/img/female.jpg";

From:    $mediaID = "../tng/photos/" . $defaultmedia['thumbpath'];

To:          $mediaID = "../gen/photos/" . $defaultmedia['thumbpath'];

 

File: family.html.php

Line: 750+  

Comment: Need a function to extract TNG site folder name. Hard coding for now. Created a new Folder in TNG called thumbs and copied all the thumb files to it as this subroutine does not take into account that not all media is in the photos folder.

Insert:   $siteurl = site_url();

From:    $mediaID = "../tng/photos/" . $personmedia['thumbpath'];

To:          $mediaID = "../gen/thumbs/" . $personmedia['thumbpath'];

From:    echo "<a href=\"/genealogy/showmedia.php?mediaID={$personmedia['mediaID']}&medialinkID={$personmedia['medialinkID']}\">";

To:          echo "<a  href=\"$siteurl"."/genealogy/showmedia.php?mediaID={$personmedia['mediaID']}&medialinkID={$personmedia['medialinkID']}\">";

 

All of the following recommendations is to use the WordPress function site_url() to properly link WordPress folder regardless of folder name. I know there are some more that should be changed but I haven’t tested everything yet.

 

File: search.php

Line:  54

From:    <a href="/family/?personId=<?php echo $result['personID']?>&amp;tree=<?php echo $tree; ?> "><?php echo $firstname . ' ' . $lastname; ?></a> -->

To:          <a href="<?php echo site_url()?>/family/?personId=<?php echo $result['personID']?>&amp;tree=<?php echo $tree; ?> "><?php echo $firstname . ' ' . $lastname; ?></a>

 

 

File: manniversaries.php

Line: 80

From:    <td class="tdfront"><a href="/family/?personId=<?php echo $manniversary['personid1'];?>&amp;tree=<?php echo $tree; ?>">

To:          <td class="tdfront"><a href="<?php echo site_url()?>/family/?personId=<?php echo $manniversary['personid1'];?>&amp;tree=<?php echo $tree; ?>">

From:    <td class="tdfront"><a href="/family/?personId=<?php echo $manniversary['personid2'];?>&amp;tree=<?php echo $tree; ?>">

To:          <td class="tdfront"><a href="<?php echo site_url()?>/family/?personId=<?php echo $manniversary['personid2'];?>&amp;tree=<?php echo $tree; ?>">                                                                                        

 

File: manniversariesplusone.php

Line: 13

 

From:    <td><a href="/family/?personId=<?php echo $manniversary['personid1'];?>">

To:          <td><a href="<?php echo site_url()?>/family/?personId=<?php echo $manniversary['personid1'];?>">

From:    <td><a href="/family/?personId=<?php echo $manniversary['personid2'];?>">

To:          <td><a href="<?php echo site_url()?>/family/?personId=<?php echo $manniversary['personid2'];?>">

 

File: danniversaries.php

Line: 82

From:    <td class="tdfront"><a href="/family/?personId=<?php echo $danniversary['personid']; ?>&amp;tree=<?php echo $tree; ?>">

To:          <td class="tdfront"><a href="<?php echo site_url()?>/family/?personId=<?php echo $danniversary['personid']; ?>&amp;tree=<?php echo $tree; ?>">

 

File: danniversariesplusone.php

Line: 21

From:    <td><a href="/family/?personId=<?php echo $danniversary['personid'];?>">

To:          <td><a href="<?php echo site_url()?>/family/?personId=<?php echo $danniversary['personid'];?>">

 

File: birthdays.html.php

Line: 76

From:        <td class="tdfront"><a href="/family/?personId=<?php echo $birthday['personid'];?>&amp;tree=<?php echo $tree; ?>">

To:            <td class="tdfront"><a href="<?php echo site_url()?>/family/?personId=<?php echo $birthday['personid'];?>&amp;tree=<?php echo $tree; ?>">

Share this post


Link to post
Share on other sites
mahesh

Thank you Mike for such detailed list. I appreciate it. 

Search form shows a label called Array. I haven’t identified the cause yet.

Sorry about this. This was left over from one of the debug lines. Please remove / comment out line around 1041 in Upavadi>TngContent.php

 $user = $this->getTngUser();
        $gedcom = $user['gedcom'];
        //echo $user; Comment out or remove this line

So I thought why not redirect all editing functions from TNG to your API which is why I tried the TNG genlib.php hack shown below.

TngApi is designed to be a stand-alone plugin. It only accesses the TNG config file to retrieve the dsettings. The idea is that the Family page would be a landing page for the user.  User would be able to login, submit changes in the family page and then log out. User has the option to go to TNG pages if more information is required.

Your idea is good and may be incorporated as an individual customization. Customized shortcodes may be added in the tng-api-custom. The idea behind this is that your customization would not be over written with future updates.

File: family.html.php

Line:  38+  

Comment: Need a function to extract TNG site folder name. Hard coding for now.

From:    $mediaID = "../tng/img/male.jpg";

To:          $mediaID = "../gen/img/male.jpg";

That's the problem with a very long-term project!! The family.html.php was written about 2 years ago and media function has not been updated. Thanks for pointing that out. Please do make changes that are necessary. I do not like the idea of searching for tng folder. My initial thought is to add a field in the settings to specify tng path.
I also note that not all media is in photos folder.

All of the following recommendations is to use the WordPress function site_url() to properly link WordPress folder regardless of folder name. I know there are some more that should be changed but I haven’t tested everything yet.

 When I started writing the plugin, it was common practice to have wordpress and TNG in parellel folders.

Now that practice has changed, I think it would be a good idea to use site_url for all links.

Thanks for your suggestions.

 

Share this post


Link to post
Share on other sites
Mike Kelley
 

Sorry about this. This was left over from one of the debug lines. Please remove / comment out line around 1041 in Upavadi>TngContent.php

Mahesh,

Thanks for the tip, that worked. OK, I ordered some books so I can become more dangerous with PHP/WordPress and won't asked so many stupid questions. Hopefully I'll figure out then how to write a mod to do what I want to with genlib.php. I changed my previous code hack and instead added a tab named "visual editor" pointed to TngApi.

I plan on having TNG as the landing page and direct editing functions to your plugin as a "visual editor" unless a user is has editor privileges whom would have full access.

Hopefully, I'll have my test site online by the end of the week.

Regards,

Mike

 

Share this post


Link to post
Share on other sites
mahesh

Thanks for the tip, that worked. OK, I ordered some books so I can become more dangerous with PHP/WordPress and won't asked so many stupid questions. Hopefully I'll figure out then how to write a mod to do what I want to with genlib.php.

Mike, you probably know more about coding than I do. When I started this project, I knew nothing about HTML or PHP. My son has helped do all core files. I just do all the padding.

Writing a mod for TNG, to access TngApi is a very interesting idea. I look forward to seeing how it develops.

I am in the process of normalizing links to media. I will PM you once I have done the changes.

Perhaps you can then let me know how it works out.

Thanks again for your input.

Share this post


Link to post
Share on other sites
Mike Kelley

Mahesh,

This thing is working great.

A 1000 thank you's for all your help!

 

Mike

 

Share this post


Link to post
Share on other sites
mahesh

We have just updated TngApi plugin for Wordpress.
You can find the latest stable version (3.1.0) in the releases section.

Bug Fixes:

  • when children were added to person with multiple marriages, incorrect personIDs were given. Fixed.
  • when new parents were added and the head person was not being registered as a child - Fixed
  • Modified settings and family template to cater for varying installations

At my  Demo site, TngApi is used as a stand-alone plugin which is password protected. You may use view, tngview for access.

On my live site, the plugin is used in conjuction with TNG Wordpress Integration plugin. Same login details may be used to access the live site.

 

Share this post


Link to post
Share on other sites
Scrugio

I have recently purchsed TNG 11 and have spent a few days working to get tng and wordpress together as well as getting my home server running  properly.

And i would just like to say the simplicity of this plugin along with the frontend plugin and tng integration plugin. my site is looking awesome.

 

The only thing i need to do now is find a decent theme and customise it to work well with all the above. which seems to be the hardest thing of all.

Share this post


Link to post
Share on other sites
mahesh
2 hours ago, Scrugio said:

I have recently purchsed TNG 11 and have spent a few days working to get tng and wordpress together as well as getting my home server running  properly.

And i would just like to say the simplicity of this plugin along with the frontend plugin and tng integration plugin. my site is looking awesome.

 

The only thing i need to do now is find a decent theme and customise it to work well with all the above. which seems to be the hardest thing of all.

Thank you so much for your kind comments. Really appreciated. I am pleased the plugin works for you.

As you say, TNG-WP Frontend User Functions by Heather Feuerhelm  is awesome. Unfortunately, it does not work with my configuration set up for TNG V10. One of these days, I might tweak it so that it accepts my Wordpress-TNG configuration.
I would like to take this opportunity to say that it was Heather's plugin that got me to delve in to Wordpress-TNG integration. I am really indebted to Heather for her encouragement through out the development of my plugin, with help from my sons.
At age of 73+, I have to learn to code in HTML and php, but it has been worth it.

I am in the process of final tweak to the plugin to make it truely responsive in small devices.

Anyone interested in the plugin, can see it working at http://trial.upavadi.net. Its password protected. Use view, tngview to access the site.

 

Share this post


Link to post
Share on other sites
Scrugio

alright so i finally made my site live for some family to test out all the bits.

when users submit changes they are directed to this page
/wp-content/plugins/TngApi-3.1.0/templates/processfamily-update.php

Ive tried creating a thankyou page
/family/thank-you/ 
/thank-you/

which is not on the menu but is accessable thru the link

but submissions still redirect to 
/wp-content/plugins/TngApi-3.1.0/templates/processfamily-update.php

 

The other issue i have found is it sends mail thru the sendmail php.ini directive instead of the wordpress mail system which would be better ?

Share this post


Link to post
Share on other sites
mahesh

My Bad.

Couple of commented lines are left over in 2 files, from the testing stage. I have been meaning to update the github site.

In templates/processfamily-update.php, please remove the 2 // from line 6 so that line is

header('Location: /thank-you'); instead of //header('Location: /thank-you');

Similarly, In templates/processfamily-add.php, please remove the 2 // from line 4.

You do need to create a Wordpress page named thank-you. You also need to add shortcode

[upavadi_pages_userfamilysheet] to display changes proposed by that user.

The details are in the pdf file Here.

On my site, I have the following

Quote

<h2><span style="color: #d77600; font-size: 14pt;">Thank you for your submitting your family details.</span></h2>Your submissions are listed below.
I will let you know by email,once I have updated the family tree with your details. I wil really appreciate it if you would visit the site again to check if the entries are correct. I look forward to receiving further updates from you, as and when there are changes in the family details.
Fond Regards
Mahesh Upadhyaya
[upavadi_pages_userfamilysheet]

Sorry about the little issue that got away. I hope it did not cause too much trouble for you.

Quote

The other issue i have found is it sends mail thru the sendmail php.ini directive instead of the wordpress mail system which would be better ?

I am not sure which is better. sendmail is general purpose email routing facility that supports many kinds of mail-transfer and delivery methods. Perhaps someone else can help.

Share this post


Link to post
Share on other sites
Scrugio
19 minutes ago, mahesh said:

 

yip that fixed it :grin:  thanks muchly.

Share this post


Link to post
Share on other sites
mahesh

You are welcome.

Just for completeness, could you comment out this line

echo "<pre>{$msg}</pre>";

it's line 232 in processfamily-update.php
line 412 in processfamily-add.php and
line 92 in processfamily-notes.php

Thanks.

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

×