Jump to content
TNG Community
Sign in to follow this  
slowjim

Using Kloosterman method with Wordpress integration

Recommended Posts

slowjim

I have been working for days attempting to integrate my website with WP by using Mr. Kloosterman's method. I am using TNG V11.1.1 and WP 4.8.2 running Twenty Seventeen theme. I am doing this on wampserver installed on my home computer before I attempt it with my site. Initially, it seemed to work. The devil is going to be in the details, obviously. However, before I can get to work on making it more aesthetically pleasing, I need to solve a couple of problems. When I try to link to files in my tng history folder, I receive the following two errors;

Warning: require_once(C:\wamp64\www\mywebsite\tng/wp-includes/load.php): failed to open stream: No such file or directory in C:\wamp64\www\mywebsite\tng\wp-load.php on line 49

Fatal error: require_once(): Failed opening required 'C:\wamp64\www\mywebsite\tng/wp-includes/load.php' (include_path='.;C:\php\pear') in C:\wamp64\www\mywebsite\tng\wp-load.php on line 49

Wordpress is installed in the root folder and tng is installed in a subfolder.

I followed Mr. Kloosterman's instructions to the best of my ability and I created the new topmenu, footer, and header files and pasted in his examples. I have them in the root of the tng folder. I have been unable to find a solution so far. Looking at the beautiful Kloosterman Genealogy website, it is obvious that I must have made an error somewhere. 

Thanks

error.jpg

Share this post


Link to post
Share on other sites
klooster

Hi Jim,

When I check the error code you are receiving it seems that something is indeed wrong, because it searches for wp-load.php in the wrong directory!

It searches in : c:\wamp64\www\mywebsite\tng\wp-load.php . So the the directory is wrong. I should search for the root directory of WP and that is on your local server c:\wamp64\www\mywebsite\wp-load.php (without the TNG)

You probably made a PhP mistake.

 

It shoud be require ("../wp-load.php");  with two dots before the /wp-load.php

I Think you forgot a dot and typed require ("./wp-load.php");

Share this post


Link to post
Share on other sites
slowjim

Hi and thanks for answering.

I checked the topmenu file and it reads require ("../wp-load.php");  as it should. Everything else works! links to profiles and media show as they should.  I was also experimenting with Kathleen's integration method, but I found your method gave me a bit more control.  I might have combined or confused steps from both methods. The best thing is to go back through this one step at a time and I am sure I'll get  it. I am learning to use Wordpress, TNG, and now Artisteer 4 all at once. 

 

Share this post


Link to post
Share on other sites
slowjim

Hi

I am still no closer to solving this problem. Every thing else works! It is only with the history files that I have a problem. I have deleted and reinstalled the tng system in the tng folder. I have followed the steps in the Kloosterman method to the best of my understanding. I cut and pasted the content of the 3 php files that I created as per the instructions and I put them in the tng folder. I set Site Design and Definition part of the TNG setup as per instruction.

The only commonality between the files that cause the error is that all of them were written with the historytemplate.php file. The lines in the top of that template are;

include( "../tng_begin.php"); if( !$cms['support'] ) $cms['tngpath'] = "../";

I believe the  if statement is supposed to take care of the fact that the file is in a sub-folder (histories) of the tng folder. But it apparently doesn't. Klooster told me that the directory is wrong that WPTNG-topmenu.php should be searching for wp-load.php in the root directory where WP is installed, but that instead, according to the error message it is searching in the tng directory which is a sub-directory of the folder WP is installed in. I do not understand how if WPTNG-topmenu.php had some error it, that everything else could be working properly as it should. I did check klooster's website and he doesn't seem to have any problem accessing history files. I wonder if perhaps I used the wrong history template or something to create my history files. I need help solving this. I seem so close to getting it all put together.

Thanks

Share this post


Link to post
Share on other sites
klooster

Ah, Jim, that explains a lot.

First off all, I am not using the historytemplate.php to make histories, so thatswhy I did not encounter this problem before.

 Because the history files are in a subdirectory of TNG

 So the history template will get the history file in the subdirectory of TNG, then starts the tng-begin.php one directory higher with the code “include( "../tng_begin.php"); “

WPTNG-topmenu.php thinks it is in the TNG directory, but it is not, it is in the subdirectory of the history files.WPTNG-topmenu.php cannot find the wp-load.php because the PhP code " require (" ../wp-load.php ");  " and especially the " ../ " means that it will search only one directory higher than the TNG subdirectory and goes to the TNG directory in stead of going to the root.

.. /        selects the parent directory from the current. Of course, this can be chained:

../../    This would be two directories up.

So try this In the historytemplate.php:

After:  include( "../tng_begin.php"); if( !$cms['support'] ) $cms['tngpath'] = "../";

 In the historytemplate.php put the next line:

 require (" ../../wp-load.php "); 

 When you are sure your historytemplate.php file is perfectly working, chances are that you will still get the error code, because WPTNG-topmenu.php wil still try to search in the wrong directory

To prevent PHP from displaying error messages, use a text editor to modify the .htaccess file in your root as follows:

Add the following line: 
php_flag display_errors Off

An alternative is to put in the beginning of your historytemplaphp these lines:  
ini_set('display_errors', '0');     # don't show any errors...
error_reporting(E_ALL | E_STRICT);  # ...but do log them

 

PS:  I am not suggesting this is best practice. It is oke for a simple development environment. 

Share this post


Link to post
Share on other sites
slowjim

Thank you klooster for your help.

Unfortunately, it did not work. Copying and pasting the require statement and turning off the errors resulting in my server leaving this message on the screen;

This page isn’t working localhost is currently unable to handle this request.

I think I would like to solve the problem by not dealing with it. In other words, I can easily rewrite those pages some other way. A simple html file will work. Just put it in the history folder and add new to the history media  and now it's listed as a history file and will display with no problems whatsoever. There might be other downsides to this because the history template did write to a log file and all that. I may try doing that and seeing what the downside to that is. What do you think?

Thank you so much for your help so far.

Share this post


Link to post
Share on other sites
slowjim

I have it working now. At least for the moment.

First, I replaced include( "../tng_begin.php"); if( !$cms['support'] ) $cms['tngpath'] = "../"; with just include("tng_begin.php"); and then moved it into the root of the tng folder. Next I used phpMyAdmin and went to the tng_media table and found the record. The field mediatypeID says 'histories' and the field 'path' says just the filename. I altered that filename by putting a ../ in front of it. Then tried it and it worked! Now the page shows on my wordpress page and it is working for the moment. I do not know if this solution is very elegant or if something won't eventually screw it up. But until I can find a better solution, right now, this will have to do.

If you come up with an idea that is cleaner or safer then please let me know.

Jim

 

Share this post


Link to post
Share on other sites
slowjim

OK, I have refined my method of solving this problem and it works for me, I have tested it.

In all my history files I have replaced the code at the top of the files;

include( "../tng_begin.php");
if( !$cms['support'] )
$cms['tngpath'] = "../";

with just;

include( "begin.php");

First, I gave the filenames a prefix, 'hist_'. Then I moved them into the folder where TNG is installed. Next, I went to Administration > Setup > General Settings > Paths and Folders. I changed History Folder from 'histories' to '../tng' (without the ' ' marks). The folder 'tng' is the folder that TNG is installed in. Click the Save button. Now you will have to redo your links to your history files. Administration > Media. Collection Histories. Delete all the links to your History Files. Next, Add New Tab. Collection History. Add each new one. You will have to look through a lot of files because now the TNG install folder is where your history files are.

Now it works and no more errors when I link to them with my wordpress menus and the files display on my wordpress page as they should.

I cannot assure that there isn't a more professional solution, but at least now it works for me. 

 

Share this post


Link to post
Share on other sites
Ken Roy

Jim,

You should not have to move where histories are stored, nor where new TNG history media files are created.  The historytemplate.php file is just an example of creating files so they use the TNG templates and display the same look and feel.  Please read the wiki article on User Pages - Getting Started and potentially other articles anchored on the Main Page in the Customizing Your Site section.

When you are not storing the page in a subdirectory you need to adjust where TNG will find the files.  If used with a CMS (WordPress or other) additional adjustments might be necessary.

Share this post


Link to post
Share on other sites
slowjim

Thanks for your answer. However, pointing me back to an encyclopedia of information without being more specific is not going to be a lot of help. The particular problem here was because of a necessary modification made so that wordpress can use it's api with TNG. I tried the method using the TNG plugin. I would set everything up and it all seemed to be working. But when I logged out of Wordpress and tried to log back into it, half the time, I could not get back in. I'd log in and then get a blank screen with nothing on it and no way to get out of it. I did some trouble shooting with that by changing the name of the plugins folder, effectively blocking Wordpresses' access to the plugin and guess what. It let me log back in! The problem was somehow with the plugin! Now, I am sure that many others have used that plugin successfully. For some reason, there was something incompatible with my setup and I did not have a clue as to how to solve that.

So, I  had to find a way to do this without the plugin. Kloosterman's method worked in every way except with the files I put in the history folder that I built using the history template..

So, if I have to become a coding guru just to make this stuff work, then it is more than I asked for. If the answer to this particular problem is somehow buried in all that information you suggested I study, then could you at least be a bit more specific as to where.

Thanks

Share this post


Link to post
Share on other sites
Ken Roy

I know nothing about WordPress nor am I interested in learning about it.  My reply was posted because you changed the way TNG histories media is being handled which I think is incorrect and not necessary when all you needed to change was the section of the file you created using the historytemplate.php to point to the correct place where the TNG files exist.

I adjust my user created pages to find them in the TNG root folder as well as folders on the same level as TNG or above TNG in the directory structure.

Share this post


Link to post
Share on other sites
Jim Williamson

When you start doing things outside the scope if the original intent, then you have 2 choices.. learn to do it yourself, or wait for someone to do it for you.

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
Sign in to follow this  

×