UDT - Last modified date and author name on page footer

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

UDT - Last modified date and author name on page footer

Post by blast2007 »

I need to put on every page last modified date and full author name (First, Last).

I can't found similar post on forum so I wrote this small piece of code. Just create a new UDT (for example page_footer)

Code: Select all

function datetime($syntax,$datetime) {
    $year = substr($datetime,0,4);
    $month = substr($datetime,5,2);
    $day = substr($datetime,8,2);
    $hour = substr($datetime,11,2);
    $min = substr($datetime,14,2);
    $sec = substr($datetime,17,2);
   
    return date($syntax,mktime($hour,$min,$sec,$month,$day,$year));
}


global $gCms;
$db =& $gCms->GetDb();
$thisPage = $gCms->variables['page_name'];

$query = "SELECT " . cms_db_prefix() . "content.modified_date" ."," . cms_db_prefix() ."users.first_name" . "," . cms_db_prefix() ."users.last_name FROM " . cms_db_prefix()."content LEFT JOIN ". cms_db_prefix()."users ON " . cms_db_prefix() . "content.last_modified_by =". cms_db_prefix() ."users.user_id WHERE content_alias=" . "'". $thisPage . "'"  ;

$row = $db->GetRow($query);

$dbresult = $db->Execute( $query);
if (!$dbresult)
{
    echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
else
{
echo "<div class=\"small\">";
echo  "Last modified date: ". datetime("d/m/Y h:m:s",$row['modified_date']) ."<br />";
echo "by: ".  $row['first_name']. ' '. $row['last_name']  ;
echo "</div>";
}
Then put {page_footer} on your template just after {content} tag.

Hope it helps.
Regards
blast
Last edited by blast2007 on Tue Mar 23, 2010 11:19 am, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: UDT - Last modified date and author name on page footer

Post by calguy1000 »

It never ceases to amaze me the amount of effort people will go to to not read documentation.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: UDT - Last modified date and author name on page footer

Post by Nullig »

Yeah, you coulda just used the {modified_date} tag.

You can read all about it, and many other useful tags, in the Admin Panel under Extensions/Tags.

Nullig
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: UDT - Last modified date and author name on page footer

Post by blast2007 »

I missed those tags. My bad!
Locked

Return to “Tips and Tricks”