IPB
IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Last updated script
Barbara
post Feb 4 2008, 10:52 AM
Post #1


Advanced Member


Group: Members
Posts: 30
Joined: 18-January 08
From: North Carolina
Member No.: 6,171



We are wanting to add a "website was last updated ...." thingy on the home page of the site ... so, when ANYTHING is altered on the site (add, delete, change any data) ... the script updates to the current date, so visitors know when the site was last updated.

If I put a javascript on the home page, I would imagine it would only look for changes on the home page.

What's the best way to do this?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Feb 4 2008, 12:41 PM
Post #2


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



QUOTE(Barbara @ Feb 4 2008, 11:52 AM) *

We are wanting to add a "website was last updated ...." thingy on the home page of the site ... so, when ANYTHING is altered on the site (add, delete, change any data) ... the script updates to the current date, so visitors know when the site was last updated.


The script attached here might do what you want it to. It takes the date of the last data import which is what I work with since all my data is imported into TNG rather than entered in TNG.

If you only have a single tree it writes out a single line, and if you have multiple trees it writes out a wee table.

You can see it in action here

http://roger.lisaandroger.com/

and a multiple tree output

http://houliston.lisaandroger.com/

Cheers

Roger

Attached File  lastimport.php ( 1.1k ) Number of downloads: 197
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Barbara
post Feb 4 2008, 12:57 PM
Post #3


Advanced Member


Group: Members
Posts: 30
Joined: 18-January 08
From: North Carolina
Member No.: 6,171



Roger,

At this point, we are manually inputting data ... will it still work ?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Feb 4 2008, 02:02 PM
Post #4


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



I don't think so, but it costs nothing to try it and see what output it gives.

Roger
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Barbara
post Feb 6 2008, 01:45 PM
Post #5


Advanced Member


Group: Members
Posts: 30
Joined: 18-January 08
From: North Carolina
Member No.: 6,171



I want to try the above lastimport.php page ... how do I connect it to the home page ... placing the code in a certain spot on the home page, like you did? When I do a view source of your page, it fills in all the details, not the commands.

Sorry, not fully in command of php yet.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tomk
post Feb 6 2008, 03:30 PM
Post #6


Advanced Member


Group: Members
Posts: 267
Joined: 19-July 06
From: Georgia, USA
Member No.: 1,208



QUOTE(Barbara @ Feb 6 2008, 02:45 PM) *

I want to try the above lastimport.php page ... how do I connect it to the home page ... placing the code in a certain spot on the home page, like you did? When I do a view source of your page, it fills in all the details, not the commands.

Sorry, not fully in command of php yet.


Barbara,

Open up the downloaded 'lastimport.php' file with a text editor, and copy/paste it into your index.php file for the template you are using.

For example if you are using template 4, you can add this after your welcome message. Just add some words such as 'last updated' and then paste the code.

If you don't have a way to edit directly on the server, edit a local copy of your index.php file on your PC, added the code, save it, and then upload the updated index.php file to the server in your TNG folder.

TomK
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Feb 6 2008, 05:19 PM
Post #7


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



QUOTE(tomk @ Feb 6 2008, 04:30 PM) *

Barbara,

Open up the downloaded 'lastimport.php' file with a text editor, and copy/paste it into your index.php file for the template you are using.

For example if you are using template 4, you can add this after your welcome message. Just add some words such as 'last updated' and then paste the code.

If you don't have a way to edit directly on the server, edit a local copy of your index.php file on your PC, added the code, save it, and then upload the updated index.php file to the server in your TNG folder.

TomK


Or probably better is to "include" it into the page, then when or if there's a change to this little block you just get the new file and put that on your server.

To include the file, find the place you want it to appear on your page and then put this

<?php include("lastimport.php"); ?>

Cheers

Roger
User is online!Profile CardPM
Go to the top of the page
+Quote Post
nimebe
post Feb 6 2008, 11:47 PM
Post #8


Advanced Member


Group: Members
Posts: 111
Joined: 8-December 07
Member No.: 5,592



This may be more of what you're looking for. For some reason this sounded like a good idea so I wrote a script to do it. This script compares the most recent changedate fields from the people, family, and media tables in the db. It then prints out the newest date from those returned. You can see it in action on any of my tng pages:

http://www.flintfamilyhistory.com/e107_plu...IL/surnames.php

All you need to do is upload the lastupdated.php file to your tng directory. Then add this code to the page you want the last modified line to display:

CODE

include('lastupdated.php');


The include line must happen on a page in which a tng db connection has already been made. If you include the file and it doesn't work you probably need to add the following code to the top of the file you're trying to include the lastupdated.php into:

CODE

include("begin.php");
include($cms[tngpath] . "genlib.php");
$textpart = "whatsnew";
include($cms[tngpath] . "getlang.php");
include($cms[tngpath] . "$mylanguage/text.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;


To add this to all of your tng files you can add the include line in the begin.php or footer.php (rename footer.html and change in admin) file.

I tried to do this all as a single sql query, but I couldn't figure that out.

Download From: http://www.flintfamilyhistory.com/download.php?view.5
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Feb 7 2008, 07:08 AM
Post #9


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



Most of the little add on files I have that do things like last import, random photos, birthdays etc all start out with

CODE
include_once("begin.php");
include_once($cms[tngpath] . "genlib.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;


so that you can run the file by itself without including it into any other pages. So for example

http://roger.lisaandroger.com/lastimport.php

or

http://roger.lisaandroger.com/randomphoto.php

both work alone - very helpful for testing in particular. The thing is to use "include_once" rather than include for the lines like the path to genlib.php so that if it's on a page already using that it doesn't happen again and cause errors.

Roger
User is online!Profile CardPM
Go to the top of the page
+Quote Post
nimebe
post Feb 7 2008, 08:17 AM
Post #10


Advanced Member


Group: Members
Posts: 111
Joined: 8-December 07
Member No.: 5,592



QUOTE(theKiwi @ Feb 7 2008, 07:08 AM) *

Most of the little add on files I have that do things like last import, random photos, birthdays etc all start out with

CODE
include_once("begin.php");
include_once($cms[tngpath] . "genlib.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;


so that you can run the file by itself without including it into any other pages. So for example

http://roger.lisaandroger.com/lastimport.php

or

http://roger.lisaandroger.com/randomphoto.php

both work alone - very helpful for testing in particular. The thing is to use "include_once" rather than include for the lines like the path to genlib.php so that if it's on a page already using that it doesn't happen again and cause errors.

Roger


Thanks for the tip Roger!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Barbara
post Feb 13 2008, 11:40 AM
Post #11


Advanced Member


Group: Members
Posts: 30
Joined: 18-January 08
From: North Carolina
Member No.: 6,171



Sorry for the delay in response.

I want to thank both of you for your help.

I think I got it all set now. Will let you know if there are any problems.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Deni
post May 14 2008, 12:08 PM
Post #12


Advanced Member


Group: Members
Posts: 64
Joined: 16-March 07
Member No.: 2,574



Roger, I included this on my site, but I'm having some trouble. It works great on the index.php file, but when I put the "include" in my footer.php file, I get the error message:

Error: TNG is not communicating with your database. Please check your database settings and try again.

I would like to have this in the footer on every page. This is my current footer.php file:

CODE

<!-- begin footer.php -->
                        </center></span>    
                    </td>
                </tr>
            </table>                    </td>
                </tr>
            </table></center>
    
    </td></tr>
    <tr>
        <td colspan="4" align="center">
<br /><img src="appbar.gif" alt="" width="289" height="29" hspace="0" vspace="0" border="0"><br />
All my data is here on this site. <br />If it's not here, I don't have it.<br /><br />


<?php include("lastimport.php"); ?>

            <span class="topmenu">
              This site powered by<br />
            <a href="http://lythgoes.net/genealogy/software.php" class="topmenu">The Next Generation of Genealogy Sitebuilding</a>,<br />
            Copyright © 2001-2008,<br />created by Darrin Lythgoe, Sandy, Utah.<br />All rights reserved.<br><br>
            </span>
        </td>
    </tr>
</table>
<a href="http://www.jimandcarol.us/lucy.php"><img src="windblown-imprisonment.gif" height="1" width="1" border="0"></a>

<!-- end footer.php -->


Basically, what I did was to copy my footer.html file, name it footer.php and stick in the "include" line. Obviously this is will not work.

I set the file back to footer.html so that I didn't have the error showing up on all my pages.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tmcguire
post May 24 2008, 10:41 PM
Post #13


Advanced Member


Group: Members
Posts: 65
Joined: 15-January 08
Member No.: 6,126



Hello -

QUOTE(Deni @ May 14 2008, 01:08 PM) *

Basically, what I did was to copy my footer.html file, name it footer.php and stick in the "include" line. Obviously this is will not work.

There are some instances when an HTML file can be included as a PHP script. It does not always work, nor should one expect it to work. Since TNG is currenly setup with / for footer.html, it is easier to work with it that way. If you are experienced with writing PHP scripts, then go ahead and change it. You will also need to change: TNG Admin CP -> Setup -> Configuration -> General Settings -> Site Design and Definition -> Custom Footer value. This will allow for footer.php instead of footer.html

I know this doesn't quite answer your question as to why the error occurred, but the long and short of it is that html and php are neither identical nor interchangeable..

Regards,
T. McGuire
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theresel
post Sep 23 2008, 02:28 PM
Post #14


Advanced Member


Group: Members
Posts: 37
Joined: 11-April 07
Member No.: 2,791



QUOTE(nimebe @ Feb 7 2008, 01:47 AM) *

This may be more of what you're looking for. For some reason this sounded like a good idea so I wrote a script to do it. This script compares the most recent changedate fields from the people, family, and media tables in the db. It then prints out the newest date from those returned. You can see it in action on any of my tng pages:

http://www.flintfamilyhistory.com/e107_plu...IL/surnames.php

All you need to do is upload the lastupdated.php file to your tng directory. Then add this code to the page you want the last modified line to display:

CODE

include('lastupdated.php');


The include line must happen on a page in which a tng db connection has already been made. If you include the file and it doesn't work you probably need to add the following code to the top of the file you're trying to include the lastupdated.php into:

CODE

include("begin.php");
include($cms[tngpath] . "genlib.php");
$textpart = "whatsnew";
include($cms[tngpath] . "getlang.php");
include($cms[tngpath] . "$mylanguage/text.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;


To add this to all of your tng files you can add the include line in the begin.php or footer.php (rename footer.html and change in admin) file.

I tried to do this all as a single sql query, but I couldn't figure that out.

Download From: http://www.flintfamilyhistory.com/download.php?view.5


I really like your script and it is working perfectly for my site, but is there a way to incorporate text from my customtext.php instead of using the text already in it? I've tried different scenarios but it didn't work.

Thanks.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Jim W
post Apr 23 2009, 06:15 PM
Post #15


Newbie


Group: Members
Posts: 4
Joined: 26-April 08
Member No.: 7,796



How do you change the background color? I inserted the Date Last Updated script on my index.php page and it makes a dark blue background behind it. I want to change it to the cream color to match template #2. Thanks!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
thewillistree
post Apr 28 2009, 10:20 AM
Post #16


Advanced Member


Group: Members
Posts: 336
Joined: 14-May 08
From: Wakefield, West Yorkshire, UK
Member No.: 8,093



Thanks for this great script - which I've added to my new Home Page [ http://www.thewillistree.me.uk/gen2/index.php ]. I have one small query: how can I center the text? I'm not sure where to place the <center> tags...

QUOTE(nimebe @ Feb 7 2008, 06:47 AM) *

This may be more of what you're looking for. For some reason this sounded like a good idea so I wrote a script to do it. This script compares the most recent changedate fields from the people, family, and media tables in the db. It then prints out the newest date from those returned. You can see it in action on any of my tng pages:

http://www.flintfamilyhistory.com/e107_plu...IL/surnames.php

All you need to do is upload the lastupdated.php file to your tng directory. Then add this code to the page you want the last modified line to display:

CODE

include('lastupdated.php');


The include line must happen on a page in which a tng db connection has already been made. If you include the file and it doesn't work you probably need to add the following code to the top of the file you're trying to include the lastupdated.php into:

CODE

include("begin.php");
include($cms[tngpath] . "genlib.php");
$textpart = "whatsnew";
include($cms[tngpath] . "getlang.php");
include($cms[tngpath] . "$mylanguage/text.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;


To add this to all of your tng files you can add the include line in the begin.php or footer.php (rename footer.html and change in admin) file.

I tried to do this all as a single sql query, but I couldn't figure that out.

Download From: http://www.flintfamilyhistory.com/download.php?view.5

User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 3rd September 2010 - 05:06 AM