2 topanga Sep 28, 2006 08:21

I thought this post gave the answer to my problem, but seemingly not. I just want to change the attributed author to an existing post. I can change the author in the workflow section when editing a post no problem, but this does not change the author name which shows up under the post. Have i got the wrong end of the stick here?
Example: in the last few posts on [url=http://naturenet.net/blogs]my blog[/url] - all should be The Virtual Ranger but two are HM The Cat as I logged in with the wrong name. Dolt.
Have you tried the code ?
Hi again Topanga - always my saviour... :)
Code? What code? Sorry, I'm sure it will be something obvious, but I don't know which code. You'll need to expand on that.
Show the assigned author of the article. If no author is assigned, display the creator of the article. Show the Prefered Name (Identity Shown) with a link to all the articles of that person
<?php
$Item->get_creator_User();
if( $Item->assigned_user_ID )
{
$the_author = $UserCache->get_by_ID( $Item->assigned_user_ID );
}
else
{
$the_author = $Item->Author;
}
echo '<a href="'.url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='.$the_author->ID).'" title="Browse all articles from '.$the_author->get_preferred_name().'"><img src="rsc/icon_16_author.gif" border="0"></a>';
?>
And once you did that, you want the messageform-link to go to the right user, right ?
$the_author->msgform_link( $Blog->get('msgformurl'),' ',' ','#','Send an e-mail to '.$the_author->get_preferred_name(),'' );
Oh, that code! :oops:
Thankyou. I tried it, but no luck yet. When entered into the code in my template _main.php at the bottom of the post it comes up with a blank when entered verbatim. I've fiddled with it but can't get anything more useful than that. Sadly my php skills are not yet up to working out why. At present I've reverted it to the original.
Actually, I don't want a link to all posts and I don't want a msgform. All I am after is a plain string showing the assigned author's name. Is there a variable I can use directly?
<?php
$Item->get_creator_User();
if( $Item->assigned_user_ID )
{
$the_author = $UserCache->get_by_ID( $Item->assigned_user_ID );
}
else
{
$the_author = $Item->Author;
}
echo '$the_author->get_preferred_name()';
?>
or without the quotes in the echo line
Thanks Topanga, the code did the job exactly.
The quotes were not necessary for me, as you suggested might be the case, but otherwise it worked without any modification.
I'd say this is so useful a feature, and so simple, that it ought to be put forward for inclusion.
Nice one.
And still this is exactly what was in the manual.
So I suggest you to alter the manual and add this feature to it..
Put it under the existing code and explain what this does and why someone would need it
Pay it forward to other people...
Thanks again. I have [url=http://manual.b2evolution.net/Assigned_author]updated the docs[/url] as you suggest.
I look forward to the day when I'm able to 'pay it forward' here - I do my bit in a slightly different way [url=http://www.naturenet.net/ask/index.php]elsewhere[/url] for now, I like to think!
I think I'm missing somehing that's probably quite obvious here. I've put this code into my stub:
<?php
$Item->get_creator_User();
if( $Item->assigned_user_ID )
{
$the_author = $UserCache->get_by_ID( $Item->assigned_user_ID );
}
else
{
$the_author = $Item->Author;
}
echo '<a href="'.url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='.$the_author->ID).'" title="Browse all articles from '.$the_author->get_preferred_name().'">'.$the_author->get_preferred_name().'</a>';
?>
It shows the name as I hoped. However, when I click on the name to get a list of the "author's" posts I don't see any posts. Instead I get
Author(s): 7
Sorry, there is no post to display...
While it's true this user has not created any posts, I have assigned several to this name so I expected them to display. Am I wrong in my expectation?
You are not wrong in your expectations.
But the system does not - yet - workin like that.
An assigned user is not a author. When you assign a post to someone, the original author stays the same.
So it would be nice if somebody could come up with a function that shows all posts from a user sho is either the author or the assigned author.
That function already exists, sort of.
In blogs/inc/MODEL/items/_itemlist.class.php around or at line 235, there is this bit of code:
// Restrict to selected authors:
$this->ItemQuery->where_author( $author );
One just have to change it as follows:
// Restrict to selected authors or assignees:
$this->ItemQuery->where_author_assignee( $author );
Now you can select authors or assignees with the ?auhor=n parameter
Topanga wrote:
Show the assigned author of the article. If no author is assigned, display the creator of the article. Show the Prefered Name (Identity Shown) with a link to all the articles of that person
<?php $Item->get_creator_User(); if( $Item->assigned_user_ID ) { $the_author = $UserCache->get_by_ID( $Item->assigned_user_ID ); } else { $the_author = $Item->Author; } echo '<a href="'.url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='.$the_author->ID).'" title="Browse all articles from '.$the_author->get_preferred_name().'"><img src="rsc/icon_16_author.gif" border="0"></a>'; ?>
And once you did that, you want the messageform-link to go to the right user, right ?
$the_author->msgform_link( $Blog->get('msgformurl'),' ',' ','#','Send an e-mail to '.$the_author->get_preferred_name(),'' );
I would like to know in which file I should have the above codes .
Thanks to all !
I use version 3.3.3
Austriaco wrote:
That function already exists, sort of.
In blogs/inc/MODEL/items/_itemlist.class.php around or at line 235, there is this bit of code:
// Restrict to selected authors: $this->ItemQuery->where_author( $author );
One just have to change it as follows:
// Restrict to selected authors or assignees: $this->ItemQuery->where_author_assignee( $author );
Now you can select authors or assignees with the ?auhor=n parameter
I open /blogs/inc/MODEL/items/_itemlist.class.php around or at line 235 but I can't find the above code? May be because of version 3.3.3 is not the same ?
It'd go anywhere in you $MainList loop
¥
¥åßßå wrote:
It'd go anywhere in you $MainList loop
¥
Thanks ¥ ! But sorry, can you tell me more precisely that $MainList loop in which php file ?
Thanks again.
/skin/your_skin/ mixture which may include any or all of these :
index.main.php
posts.main.php
single.main.php
page.main.php
¥
¥åßßå;
Call me dense, but I still don't get where this should go. For instance, Evocamp comes with all four of the files you mention. Posts, Single and Page all have the following lines ...
<?php
// Display message if no post:
display_if_empty();
while( $Item = & mainlist_get_item() )
{ // For each blog post:
... which I will assume is what you mean by "$MainList loop"
Do I put that line in all three files? And where specifically in there does it go? (Example is from posts.main.php lines 98-103)
Line 104 onwards ( up to "} // end post loop" ... or whatever it says ) and it needs to go in every file you want it to be displayed in ( probably just posts.main && single.main )
¥
Well, that didn't work as hoped. When I added the code to posts.main I got
"Fatal error: Using $this when not in object context in /var/www/html/wtnh.tv/blogs/skins/mytv9star/posts.main.php on line 92"
Lines 85-103 in posts.main are as follows:
<?php
// Display message if no post:
display_if_empty();
while( $Item = & mainlist_get_item() )
{
// Restrict to selected authors or assignees:
$this->ItemQuery->where_author_assignee( $author );
// For each blog post:
// ---------------------- ITEM BLOCK INCLUDED HERE ------------------------
skin_include( '_item_block.inc.php', array(
'content_mode' => 'auto', // 'auto' will auto select depending on $disp-detail
'image_size' => 'fit-400x320',
) );
// ----------------------------END ITEM BLOCK ----------------------------
}
?>
I have that code in similar spots in single.main and page.name, but I noticed no difference -- the author's name and not the assigned user's name appeared.
Sorry, my "change this file" was based on the code I wrote .... austriaco's code needs to go in :
Austriaco wrote:
That function already exists, sort of.
In blogs/inc/MODEL/items/_itemlist.class.php around or at line 235
¥
OK then... let me try this allllllllll over again.
First a bit of confusion to clear up.
It's NOT /blog/inc/MODEL/items/
It's /blog/inc/items/model/
and I find no such line of code. *sigh*.
Weirdly, looks like that code is already in 3.x.x
inc/items/model/_itemlistlight.class.php
$this->ItemQuery->where_author( $this->filters['authors'] );
$this->ItemQuery->where_assignees( $this->filters['assignees'] );
$this->ItemQuery->where_author_assignee( $this->filters['author_assignee'] );
¥
¥åßßå wrote:
Weirdly, looks like that code is already in 3.x.x
inc/items/model/_itemlistlight.class.php
$this->ItemQuery->where_author( $this->filters['authors'] ); $this->ItemQuery->where_assignees( $this->filters['assignees'] ); $this->ItemQuery->where_author_assignee( $this->filters['author_assignee'] );
¥
Hi ¥ ,
I need this function for long time but nobody can help me .
The above code I already found it but I think this code apply only for filters and search . While creating or editing a post, how and where the creator can assign to another name ?
Thanks [/i]
It's irritating to know that it's already in there, yet no 3x skin I tried seems to take advantage of displaying assigned user names. Having to go into the database and manually change user names is a pain in the arse, but because of the way I use B2 I have to do it on a daily basis.
Changing author in admin is doable from a plugin. You'd need to ask topanga if she has a copy of the plugin though.
¥
That is allready standard in the 1.8.x versions.
Under a post you can choose the 'assigned' author..
Showing the assigned author under the article is explained here : http://manual.b2evolution.net/Assigned_author