Jump to content
TNG Community
jorgon

v12 - database not found using historytemplate.php

Recommended Posts

jorgon

New to TNG but very impressed.  It's enjoyable to work with and nice to have a community.

I wanted to create a landing page in the histories folder and so used historytemplate.php

However the database was not being found.  I traced this to:

include ($tngconfig['subroot']."config.php");

in begin.php

It seems the path to config.php held in $tngconfig['subroot'] was not being set as "..\", or was being incorrectly set along the way.  

This was easy to fix but was wondering if this was because of my XAMPP mock up or whether this would happen on the server.

Share this post


Link to post
Share on other sites
Ken Roy

I do not know when the subroot became anchored in the config.php file, but both are managed from Admin > Setup > General Settings.  The subroot.php path is defined in the Path and Folders section. 

Why do you think it should be "..\"  backslashes are a windows convention.  XAMPP I thought was a linux type system that installed Apache. I use Wamp myself since XAMPP did not work in the early days of Vista 64-bit, the first desktop I tried to install it on.

The Config Path used to be managed in subroot.php, so I am not sure where $tngconfig['subroot'] comes from.  If your configuration files are not moved outside of the TNG root folder, then make sure the field is null in Admin > Setup > General Settings and Save the settings.

Edited:  Sorry I only now noticed that the subject indicates use of the historytemplate.php.  The historytemplate.php is designed to be used in a subfolder so if the file you are creating is in the TNG root you need to make adjustments as to where to find the TNG files within the file you are creating from the historytemplate.php

Share this post


Link to post
Share on other sites
bhemph

For a landing page that would be in the root, you would uncomment line 16 to skip the login check and remove the ../ from the path on lines 18, 19, and 21.  It is probably one of these putting the directory a level above where you are to look for the database connection instead of the subroot file, unless your admin pages and everything are not working as well.

Share this post


Link to post
Share on other sites
XerxX

EDIT: Text removed because it's...

 

As Brent pointed out above.

But I wouldn't skip the login-check if my site isn't open.

 

HTH

Erik

Share this post


Link to post
Share on other sites
Newfloridian

You did say in your original post that you were creating your landing page in the history folder. One of the prime functions of historytemplate.php is to allow you to create user added pages (call them histories / Feature Articles etc) which have the characteristics of the template you are using (ie top banner, footer, left hand navigation column if present etc).

One way to test whether you have the coding working within your new user page is to try it out by feeding its full address into your browser

ie http...yourwebsite/histories/yournewpage.php

If that does work perhaps you could let us see this full new page for comment.

I have 500 of such articles and always check them out this way before making sure the links from root (or more usually from some other page or folder on site) are working correctly.

Alan

Share this post


Link to post
Share on other sites
jorgon

Thanks all for your replies.

I did say in my post that my new file using historytemplate.php was not in the root, but was in the histories folder.  "..\" was a mistake on my part, I meant "../" of course.

I think this is an XAMPP issue because when my new file in the histories folder comes to the "include" lines in begin.php, which file is in the root, those lines are finding all the include files which are also in the root quite happily using for example:-

include("subroot.php");

That is, with the exception of config.php.  This seems strange because config.php is also in the root.

In order to include config.php (when using my new file in the histories folder), I have found that the line in begin.php must be:-

include("../config.php");

Neither of these work (they do not succeed in including config.php):-

include("config.php");
include("/config.php");

My workaround has been to use a renamed copy of tng_begin.php and begin.php for use by the new file in the histories folder.  Then I have used the include config.php line which works.  It's just a bit strange. 

 

Share this post


Link to post
Share on other sites
Ken Roy

Make sure you do not have anything in the Admin > Setup > General Settings  Config Path in the paths and folders.  If you do and your configuration files are in the TNG roots folder, then clear the field and Save the settings.

Alternatively use the subroot.php file from the TNG zip file.

The historytemplate.php requires that you indicate where the TNG files are located which is normally one directory or folder above where the file created from the historytemplate.php resides. 

The following instruction needs to remain in the file created from the historytemplate.php

$cms['tngpath'] = "../";

which identifies where the TNG files are.  If you perchance deleted that line, then TNG will not be able to find its files.  Also if the file is not in a subfolder or subdirectory to the TNG folder or directory, then it will not find it either.

Maybe you should attach your new file here so we can see what instructions are incorrect.

Share this post


Link to post
Share on other sites
jorgon

No I didn't delete that line.  If I had done so it wouldn't work at all.  And it does.

This issue is nothing to do with Admin > Setup > General Settings  Config Path

I've explained fully what has happened so I don't want to attach a file.

Thanks though.

Share this post


Link to post
Share on other sites
Ken Roy

Sorry but I do not understand your explanation. 

Share this post


Link to post
Share on other sites
XerxX

Do you run TNG v12.0.3?

Is the historytemplate.php file from that version?

Please note that historytemplate has this up to and including v12.0.2

Quote

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

From 12.0.3 it's

Quote

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

 

I had trouble getting the historytemplate to work but found this solution and told Darrin. We tested it and it works.

I think we found that $cms['tngpath'] isn't set in tng_begin and so it can't find begin.php and other files.

 

The new version of historytemplate was included in the tngupgrade1202-1203 package, I don't know about the full version.

 

HTH

Erik

Share this post


Link to post
Share on other sites
jorgon

Hi Erik

My download was new last weekend (not the upgrade).

Yes, it does include the lines you have reproduced, including this line in historytemplate.php:-

$cms['tngpath'] = "../";

Thanks for raising this because that could have been the culprit, but it appears not!

I am hoping my issue will not replicate when I upload everything to the server in a few days time.

 

Share this post


Link to post
Share on other sites
jorgon

Just to let everyone know, that I uploaded everything to the server today and the issue I had above did not replicate.

I was able to restore the original lines in historytemplate.php in all my new files held in the histories folder.   historytemplate.php works OK.

This was therefore an XAMPP issue and not a TNG issue.

It just remains to thank everybody for your comments, which enabled me to identify this issue as one related to XAMPP.

 

 

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

×