• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: UDT - Last modified date and author name on page footer
PostPosted: Thu Mar 18, 2010 1:05 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Aug 01, 2007 5:36 pm
Posts: 482
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:
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.

Top
 Profile  
 
 Post subject: Re: UDT - Last modified date and author name on page footer
PostPosted: Thu Mar 18, 2010 1:12 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 5832
Location: Fernie British Columbia, Canada
It never ceases to amaze me the amount of effort people will go to to not read documentation.

_________________
Follow me on twitter
For quality help follow these instructions:
a) Think about the problem for an hour
b) research the problem for an hour
c) spend 1/2 an hour explaining it and providing as much information as you can muster
(too much information is okay, not enough information may get your question ignored).
--
if you can't bother explaining your problem well, why should we bother helping with it.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: UDT - Last modified date and author name on page footer
PostPosted: Thu Mar 18, 2010 5:34 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Fri Feb 02, 2007 4:31 pm
Posts: 2395
Location: Comox Valley, BC
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

_________________
Come play in the Sandbox at my CMS Made Simple demo site: http://www.cmsmsdemo.com.


Top
 Profile  
 
 Post subject: Re: UDT - Last modified date and author name on page footer
PostPosted: Thu Mar 18, 2010 7:36 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Aug 01, 2007 5:36 pm
Posts: 482
I missed those tags. My bad!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner