author's signature

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
saltydog
Power Poster
Power Poster
Posts: 281
Joined: Fri Mar 04, 2005 9:06 am

author's signature

Post by saltydog »

I have 4 or 5 authors which are supplying the site with articles.
They all belong to an "authors" group which can just Add/Edit contents. What I would like to do is to have the author username printed on top or at the end of the article, so that people knows who has written it..
Is there any easy way. It should be easy, as authors are not code-experts and they should be able to add just a tag...
Thanks to all
Xorn725

Re: author's signature

Post by Xorn725 »

That should be fairly easy to do.  I'll see if I can come up with something tomorrow evening.  It's 1:00 AM now, so I need some sleep.
Xorn725

Re: author's signature

Post by Xorn725 »

Okay, so here is a basic plugin which will print out the username of the page owner.  I'll add the ability to select whether you print username or first & last tomorrow.  Heading out for a couple drinks now though.  Hope this helps.

Oh, you'll probably want to know how to use this.  This should work on 0.9.x and to use it, simply cut and paste the code below into a file named function.author.php in your /plugins directory.

Code: Select all

<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function smarty_cms_function_author($params, &$smarty) {
	global $gCms; 
	$thispage = $gCms->variables['page'];
	
	#Load current content
	$onecontent = ContentManager::LoadContentFromId($thispage, false);	

	#now we have the page, so let's find who owns it
	$owner = UserOperations::LoadUserByID($onecontent->Owner());
	
	echo "$owner->username";
}

function smarty_cms_help_function_author() {
        ?>
        <h3>What does this do?</h3>
        <p>Prints the username of the page owner.</p>
        <h3>How do I use it?</h3>
        <p>Just insert the tag into your template/page like: <code>{author}</code></p>
        <h3>What parameters does it take?</h3>
        <ul>
					<li>None yet, sorry.  I'll add some basic formatting in the next release.</li>
        </ul>
        </p>
        <?php
}

function smarty_cms_about_function_author() {
	?>
	<p>Author: Jason Burks <jburks725@gmail.com></p>
	<p>Version: 1.0 - March 5, 2005</p>
	<p>
	Change History:<br/>
	None
	</p>
	<?php
}
?>
stopsatgreen
Power Poster
Power Poster
Posts: 322
Joined: Sat Feb 04, 2006 1:24 am

Re: author's signature

Post by stopsatgreen »

Just like to say thanks for this very useful tag! Did the author ever manage to work in the extra options he mentioned? If not, is there anyone who'd be willing to take it on? Sorry, my PHP just isn't at that level :(
Post Reply

Return to “CMSMS Core”