1 arthur Sep 28, 2006 06:24
3 filthio Nov 29, 2006 20:02
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.
4 topanga Nov 29, 2006 20:55
Have you tried the code ?
5 filthio Nov 30, 2006 00:32
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.
6 topanga Nov 30, 2006 00:42
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(),'' );
7 filthio Nov 30, 2006 01:10
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?
8 topanga Nov 30, 2006 01:34
<?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
9 filthio Nov 30, 2006 12:31
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.
10 topanga Nov 30, 2006 12:48
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...
11 filthio Nov 30, 2006 13:26
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!
12 baileyjs May 03, 2007 19:59
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?
13 topanga May 04, 2007 08:49
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.
14 austriaco Oct 12, 2007 16:43
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
15 abcd May 07, 2010 18:20
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
16 abcd May 07, 2010 19:43
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 ?
17 yabba May 09, 2010 19:22
It'd go anywhere in you $MainList loop
¥
18 abcd May 10, 2010 22:37
¥åßßå 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.
19 yabba May 11, 2010 19:00
/skin/your_skin/ mixture which may include any or all of these :
index.main.php
posts.main.php
single.main.php
page.main.php
¥
20 baileyjs May 13, 2010 18:44
¥åßßå;
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)
21 yabba May 13, 2010 22:18
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 )
¥
22 baileyjs May 17, 2010 19:59
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.
23 yabba May 17, 2010 20:20
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
¥
24 baileyjs May 17, 2010 21:43
OK then... let me try this allllllllll over again.
25 baileyjs May 17, 2010 22:03
First a bit of confusion to clear up.
It's NOT /blog/inc/MODEL/items/
It's /blog/inc/items/model/
26 baileyjs May 17, 2010 22:08
and I find no such line of code. *sigh*.
27 yabba May 17, 2010 22:26
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'] );
¥
28 abcd May 18, 2010 01:28
¥åßßå 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]
29 baileyjs May 20, 2010 20:31
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.
30 yabba May 20, 2010 21:04
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