Recent Topics

1 Jan 17, 2008 13:05    

My b2evolution Version: Not Entered

Bringing back another [url=http://forums.b2evolution.net/viewtopic.php?t=9397]oldie but a goodie[/url] ...

I would like to display the Assigned Author's name rather than author. I make a few posts for others, and would prefer to see their name, not my pseudonym.

Substituting $Item->assigned_user_ID for $Item->author in posts.main.php gave me a fatal error.

2 Jan 17, 2008 13:41

inc/items/model/_item.class.php ( approx 451 )

	/**
	 * Template function: display assignee of item
	 *
	 * @param string
	 * @param string
	 * @param string Output format, see {@link format_to_output()}
	 */
	function assigned_to( $before = '', $after = '', $format = 'htmlbody' )
	{
		if( $this->get_assigned_User() )
		{
			echo $before;
			$this->assigned_User->preferred_name( $format );
			echo $after;
		}
	}

So just replace $Item->author() with $Item->assigned_to( 'before', 'after' ) and all should be well with the world

¥

3 Jan 17, 2008 14:34

So, in your example I would always have to assign the post to someone, even myself, correct?

I can do that, but my preference would be the if /else Topanga had in the original post.

4 Jan 17, 2008 14:56

<?php
if( $Item->get_assigned_User() )
{ // we have an assigned user
  $the_author = $Item->assigned_User;
}
else
{ // we don't have an assigned user
  $Item->get_creator_user();
  $the_author = $Item->creator_User;
}
echo 'before'.$the_author->get_preferred_name( 'htmlbody' ),'after';
?>

Completely untested ;)

¥

5 Jan 17, 2008 15:38

To paraphrase Dr. Leonard McCoy, I feel safer about your guesses than most other people's facts.

Thank You.


Form is loading...