Page 1 of 2
{LAST UPDATED} Site/Section
Posted: Fri 15. Apr 2005, 08:22
by jsw_nz
Had a requirement to display info on the home page for last site wide update and last update for several sections. So I took existing code and tweaked it little. Placing get_last_update.php in frontend_render directory allows following tags to work:
Code: Select all
<?php
// {LAST UPDATED} Returns the last time site was updated
// {LAST UPDATED:categoryID} Returns the last time section was updated
function get_newest_update($template_default, $cat, $dbcon) {
$cat = intval($cat);
if($cat){
$appendString="Section Last Updated: ";
}else{
$appendString="Site Last Updated: ";
}
$cat = ($cat) ? 'article_cid='.intval($cat).' AND ' : '';
$sql = "SELECT article_id, article_title, article_cid, UNIX_TIMESTAMP(article_tstamp) AS article_date ".
"FROM ".DB_PREPEND."phpwcms_article WHERE ".$cat.
"article_public=1 AND article_aktiv=1 AND article_deleted=0 AND ".
"article_begin < NOW() AND article_end > NOW() ".
"ORDER BY article_tstamp DESC LIMIT 1";
$updated = "";
if($result = mysql_query($sql, $dbcon)) {
while ($row = mysql_fetch_row($result)) {
$update_date = html_specialchars(international_date_format
($template_default["date_language"], "j F Y", $row[3]));
$updated .= $appendString.$update_date;
}
mysql_free_result($result);
}
return $updated;
}
if(!( strpos($content["all"],'{LAST UPDATED:')===false ) ) {
$content["all"] = preg_replace('/\{LAST UPDATED:{0,1}(\d*)\}/e','get_newest_update($template_default["news"],"$1",$db);',$content["all"]);
}
?>
returns strings looking like these:
Site Last Updated: 15 April 2005
Section Last Updated: 11 April 2005
Posted: Fri 15. Apr 2005, 16:10
by isac
Very cool. thank you
Posted: Sat 16. Apr 2005, 01:47
by jsw_nz
Cheers Isac,
Basically the code is a simplified derivation of the get_new_articles() in front.func.inc.php. Unfortunately the $appendString needs to be hard-coded to your language requirement, which I think is Portuguese -

). Ideally this string could reside in the inc_lang/backend folder, but for purposes of declaring the entire tag inside the frontend_render folder, this may be more work than it is worth. The date returned is also hard coded "j F Y", although is does use the "date_language" parameter.
Real thanks goes to OliG...again...for providing the frontend_render scheme, making such additions very easy.
Posted: Tue 19. Apr 2005, 08:58
by trip
Hi jsw_nz
please post your REPTAG on the dev forum on the following area
--...--/index.php/board,1.0.html
please note the formatting of finished REPTAGS for easy info for other users...
see this for an example
--...--/index.php/topic,95.0.html
regards
TriP
Posted: Tue 26. Apr 2005, 12:06
by brans
I have added the tag to our list
Posted: Tue 26. Apr 2005, 13:39
by pepe
Hallo jsw_nz,
ich habe den code nach der Vorgabe eingebunden, aber ohne Erfolg.
Es wird kein Datum angezeigt und alle Umlaute ( ä ü ö Ä Ö Ü ) sind verschwunden?
Was kann ich tun?
I have put in the code following the example, but without success.
No date is announced and all "Umlaute" vowel mutations? ( ä ö ü Ä Ö Ü ) have disappeared?
What can I do?
Posted: Tue 26. Apr 2005, 15:04
by jsw_nz
Hi Pepe,
Not sure why it is not returning German results?
I changed language settings in both
conf.inc.php & conf.template_default.inc.php myself
and had same issue
So while you hard code
Site last updated:
Section last updated:
to german equivalents....
might want to change:
Code: Select all
$update_date = html_specialchars(international_date_format
($template_default["date_language"], "j F Y", $row[3]));
to:
Code: Select all
$update_date = html_specialchars(international_date_format("DE", "j F Y", $row[3]));
...got to be a reason for this 'date_language' parameter quirk....will get back....I might have stripped out a necessary parameter. Just sent Oliver an email, since this code draws on his get_new_articles () method.

Posted: Wed 27. Apr 2005, 22:53
by jsw_nz
That date parameter comes from line 209 of conf.template_default.inc.php:
Code: Select all
$template_default["news"]["date_language"]
so I changed the date parameter to the global setting for language,
which will require no edits (conf.inc.php)
This should be the easiest way to implement on single language site. Thinking about impementing a language parameter for multi-language sites. Will run this idea past Pappnase. Thanks to some help from Cyrano, I was able to locate a bug in the code, so I am posting this modification.
To get "
Site Last Updated" info now use
{LAST UPDATED:0}
instead of {LAST UPDATED}
So here is the newly edited snippet:
Code: Select all
<?php
// {LAST UPDATED:0} Returns the last time site was updated
// {LAST UPDATED:X} Returns the last time section X was updated
// Where X is = PhpWcms Category ID Integer
// SAMPLE USAGE:
// {LAST UPDATED:0} >> Site Last Updated: 12 April 2005
// {LAST UPDATED:4} >> Section Last Updated: 10 April 2005
function get_newest_update($language, $cat, $dbcon) {
$cat = intval($cat);
if($cat!=0){
$appendString="Section Last Updated: ";
}else{
$appendString="Site Last Updated: ";
}
$cat = ($cat!=0) ? 'article_cid='.intval($cat).' AND ' : '';
$sql = "SELECT article_id, article_title, article_cid, UNIX_TIMESTAMP(article_tstamp) AS article_date ".
"FROM ".DB_PREPEND."phpwcms_article WHERE ".$cat.
"article_public=1 AND article_aktiv=1 AND article_deleted=0 AND ".
"article_begin < NOW() AND article_end > NOW() ".
"ORDER BY article_tstamp DESC LIMIT 1";
$updated = "";
if($result = mysql_query($sql, $dbcon)) {
while ($row = mysql_fetch_row($result)) {
$update_date = html_specialchars(international_date_format($language, "j F Y", $row[3]));
$updated .= $appendString.$update_date;
}
mysql_free_result($result);
}
return $updated;
}
if(!( strpos($content["all"],'{LAST UPDATED:')===false ) ) {
$content["all"] = preg_replace('/\{LAST UPDATED:{0,1}(\d*)\}/e','get_newest_update($phpwcms["default_lang"],"$1",$db);',$content["all"]);
}
?>
Brans, Trip I have updated dev listing as well.
Cheers,

Posted: Thu 28. Apr 2005, 08:35
by trip
Posted: Thu 28. Apr 2005, 14:33
by cyrano
Hi John,
I added your new script,
{LAST UPDATED:0}works, {LAST UPDATED:categoryID} shown as Tag is.
hmm, will try and play a little bit.
Posted: Fri 29. Apr 2005, 12:39
by jsw_nz
Hi Cyrano,
The CategoryID should end up being an integer in your final implementation, so for example:
//for last update site wide, code would be
{LAST UPDATED:0}
//last update for category ID 4, code would be
{LAST UPDATED:4}
I ran these on my localhost and they returned these strings, respectively:
Site Last Updated: Friday 29 April 2005
Section Last Updated: Friday 15 April 2005
So give this a go.....all best
Great set of new Italian pix
Posted: Fri 29. Apr 2005, 12:58
by cyrano
Cheers John,
ah OK, I thought the script will find by itselfs the category ID and changes/display last edited entry.
Ok, so then it will work :-)
New italian photos? haven't updated them since i went back from italy.
Love the blue boat pix.
All the best
Posted: Fri 29. Apr 2005, 23:48
by jsw_nz
Hi Cyrano,
I updated the comments inside the code to make it a little clearer.
Code: Select all
// {LAST UPDATED:X} Returns the last time section X was updated
// Where X is = PhpWcms Category ID Integer
Can understand your confusion.
My apologies.
With regards to pix, yes I was referring to those you did a few months back at that lake resort. Very nice....also the Venice photos are really awesome. Looking forward to your next batch. All best....

Posted: Wed 20. Jul 2005, 17:32
by Tooms
Okay, with this mod it's possible to show the date of the last updated section and the whole website. Is it also possible to show the last update of a specific article? For example:
Last Changes: 2005/07/09
The documentation
http://www.phpwcms-docu.de uses this RT at the right side of the bottom. How can I realize this?
Posted: Thu 21. Jul 2005, 01:28
by jsw_nz
Hi Tooms,
Welcome to the forums:
With regards to providing the last update of an article use:
{DATE_ARTICLE}
To display dates in other languages you must edit: config/phpwcms/conf.template_default.inc.php
$template_default["date"]["language"]="EN"; default
http://www.phpwcms-docu.de/index.php?article_tags
With regards to providing the date when article was created use:
{WAK_ARTICLE_CREATED}
(custom_rep_tag): for instructions see:
--...--/index.php/topic,74.0.html
hope this helps
