Jump to content
TNG Community
kazooter

WordPress Compatible URLs in TNG/PHP

Recommended Posts

kazooter

I'm trying to understand how to write URL/URI links in TNG addons like the Family Group Worksheet to keep them compatible with WordPress and other CMS integrations. My scripts sometimes fail on WordPress sites and I'm pretty sure it's because links to other pages are not working correctly.  I've already scoured the Internet with no joy, but I suspect all the real expertise is right here.

Using the TNG function getURL() is not ideal, since my scripts often work from a TNG sub directory, where I need to define cms['tngpath'] to access TNG libraries, but works against my own scripts which are relative to the working directory of the addon, not the TNG root.  So what does the CMS need?

Could anyone with an integration like WordPress using the TNGcms class share a copy of that script with me to help me understand the internals?

Any other guidance on this issue, such as which links are affected (only menus?) and which are not, would be most helpful.

Thanks.

Share this post


Link to post
Share on other sites
theKiwi

In a WordPress situation I don't think the $cms variable does anything.

And at least for sites using the TNG-WordPress-Plugin it isn't always able to find its way to where it should be.

That's why there are places in TNG that in the past were using the $cms['tngpath'] variable now have to use the $rootpath to find things - image files is one thing that comes to mind that needed this in some places.

Roger

Share this post


Link to post
Share on other sites
kazooter

Thanks, Roger.

For links between my own pages I was thinking that canonical URLs might solve the problems.  I know that WordPress databases pretty permalinks and looks those up to find the real URLs for its own use. I imagine that would be the case for the TNG home page, too.  No Idea about other TNG pages like getperson.php or admin.php -- if they are even run out of WordPress.

I've been trying to avoid this, but I guess I will just have to build a WordPress/TNG site for testing these kinds of issues.  Looks like the Kloosterman Method is our only option for TNGv12.

Rick 😊

Share this post


Link to post
Share on other sites
theKiwi
23 hours ago, kazooter said:

I've been trying to avoid this, but I guess I will just have to build a WordPress/TNG site for testing these kinds of issues.  Looks like the Kloosterman Method is our only option for TNGv12.

 

The TNG-WordPress-Plugin still works with TNG 12.2 - I have 2 sites running it without problems.

It fails if you want to try and use the Synchronised Logins feature that it offers - that is badly broken, but just for display it still deals with it - at least in my case.

Roger

Share this post


Link to post
Share on other sites
kazooter

Thanks Roger.  I'll take a look at it.  Your integrations looks quite clean as I view the source code with FF.  Other "expert" sites I visited seem to function, but their source code as viewed in FF is horrible -- for example, their pages have duplicate <!DOCTYPEs and  multiple html elements placed between the </head> tag and body tag. ???

Rick

Share this post


Link to post
Share on other sites
theKiwi

Yes, that's a feature of the Kloosterman method - there are duplicate <head> sections on the pages.

The tng.php plugin does strip out the <head> and </head> and some of the other stuff from the TNG pages it's including to make the generated WordPress pages more compliant, and I have installed  TNG Mod I created that alters WordPress to suppress the WordPress page <title> so that the TNG <title> can be shown for each different TNG page, even though WordPress thinks it's all the same page.

Roger

Share this post


Link to post
Share on other sites
cfj
8 hours ago, theKiwi said:

 

Yes, that's a feature of the Kloosterman method - there are duplicate <head> sections on the pages.

 

If you do this the correct way, you don't get double header or title code

You can take a look at my source  code 

Share this post


Link to post
Share on other sites
kazooter

cfj,

Your source is good and clean (as it should be).  You need an above average understand of both TNG and your CMS to make it work properly.  So I suppose users who are savvy enough to do the integrations should be able to integrate my mods if I give them the hooks.

cfi, and Roger,

There are so many cms programs out there now, but most seem work the same way.  A pretty permalink is examined in the htaccess file and sent on to a script that use a database or xml table to convert it into a "real" url that can be used by the server to find the resource. So the trick with my cms compatible scripts seems to be to map my normal urls to their equivalent permalinks from the database, etc.

For my Family Group Worksheet and ShowFolio mods, I think I will provide generic hooks for any cms program, but leave it up to the user to provide handling instructions.  So a link in my script like getperson.php?personid=I21&tree=01 might be redirected by the htaccess file to /index.php?destination=getperson.php&personid=I21&tree=01, and end up being served in the browser as www.mysite.com/genealogy/01/person/i21, depending on the particular cms program and how the user configures it up.

****

Looking at the current TNG support for various cms integrations in the TNG globallib functions getURL() and getFORM(), it seems to use a class object named TNGcms for all of them.  It appears the user must provide this class object himself.  I see no instructions for doing this.  Do you have an example of this class definition or any instructions for writing one, and could you share it with me?

Thanks.

Hope you both had a great Christmas holiday,
Rick

Share this post


Link to post
Share on other sites
theKiwi
2 hours ago, kazooter said:

For my Family Group Worksheet and ShowFolio mods, I think I will provide generic hooks for any cms program, but leave it up to the user to provide handling instructions.  So a link in my script like getperson.php?personid=I21&tree=01 might be redirected by the htaccess file to /index.php?destination=getperson.php&personid=I21&tree=01, and end up being served in the browser as www.mysite.com/genealogy/01/person/i21, depending on the particular cms program and how the user configures it up.

 

For these two Mods when I have implemented them on my site(s)...

ShowFolio Mod - the changes you made in a few places some months ago at my suggestion made that work correctly with the tng.php plugin in WordPress. These were changes to use the $rootpath to locate some items as I recall.

Family Group Worksheet - when I had that installed to try it out, I put this into the .htaccess file to force it to open as its own page outside of the WordPress environment

# To get the Family Group Worksheet  to open in /tng/ not in /Genealogy/
RewriteEngine On
ReWriteRule ^genealogy/extensions/fgw(.*)$ tng_11.0/extensions/fgw$1 [R,L]

i.e. directly in TNG. I haven't tried this Mod in recent times.

 

3 hours ago, kazooter said:

Looking at the current TNG support for various cms integrations in the TNG globallib functions getURL() and getFORM(), it seems to use a class object named TNGcms for all of them.  It appears the user must provide this class object himself.  I see no instructions for doing this.  Do you have an example of this class definition or any instructions for writing one, and could you share it with me?

 

I think this is an olde hangover from very early days of TNG, with CMS like Drupal and whatever else some early TNG users used. I seem to remember some notes about this used to be on the TNG Downloads page in the section at the bottom, but that's gone now - it one mentions the WordPress plugin on the TNG 12 Downloads page. Darrin may have some notes from back in the very early days as to what TNGcms was meant to be providing.

Roger

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

×