Recent Topics

Browse all posts by author by clicking on their name

Started by on Mar 04, 2008 – Contents updated: Mar 04, 2008

1 Mar 04, 2008 18:06    

How can I make it so that at the bottom of a blog when it lists the Author's name, their name is linked to a page that will show all posts by that author?
I'm using 2.4.0-rc2 with nautica_2l

2 Mar 04, 2008 19:38

I've been able to edit the index.main.php file to the following:

$Item->author( array(
							'before'    => ', ' . T_('by') . ' <strong><a href="' . url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='. $Item->get('creator_user_ID') ) . '" title="' . T_('Browse all posts by') . $Item->author() . '">',
							'after'     => '</a></strong>',
						) );

But now I see the author's name, unlinked, followed with "By Author's name" and that second one goes to a link of all of the author's blogs. It looks like this:
Candace Smith , by [link]Candace Smith,[/link]
What am I doing that's making the name show up twice?

3 Mar 04, 2008 20:31

I'll ask a dumb question just to make sure: you don't have the Item->author bit duplicated do you? Because your code looks like it should work as expected (and thanks for that by the way ;) ), but apparently you're having duplication happen.

Hey try moving that block of code to either the top or bottom of the post - where-ever it happens to not be right now. That ought to prove if your code is somehow duplicating the author name or if the unlinked version is coming from somewhere else.

4 Mar 04, 2008 20:41

$Item->author is going to spit out author. So there's no need to have $Item->author as well on the 'before' array value. There is your duplication.

Good luck

5 Mar 04, 2008 20:50

Good catch Afwas! I tried thinking through the code but kept seeing

green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green green

and figured aw heck it looks pretty good I better take my meds and a shower ;)

6 Mar 04, 2008 21:03

All I see is:

tiny small illegable smaller tinier


That's another problem, isn't it?

7 Mar 10, 2008 16:59

I tried to take it out, but I'm getting white screens. I don't see how I have the Item->author in there twice, because the 'before' is the opening a href tag and the after is the close. I don't have anything besides the "by" "strong" and "a href" Let me separate it out a bit, and if you could, let me know what the code should be with the Item->author removed.

$Item->author( array(

'before'    => ', ' . T_('by') . ' <strong>
<a href="' . url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='. $Item->get('creator_user_ID') ) . '" title="' . T_('Browse all posts by') . $Item->author() . '">',

'after'     => '</a></strong>',
						) );

8 Mar 10, 2008 17:04

moregood wrote:

[code]$Item->author( array(

'before' => ', ' . T_('by') . ' <strong>
<a href="' . url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='. $Item->get('creator_user_ID') ) . '" title="' . T_('Browse all posts by') . $Item->author() . '">',

'after' => '</a></strong>',
) );

Both are going to spit out the author.

9 Mar 10, 2008 17:29

If I take either of them out, I get a white screen. It's the first occurrence that I need to take out. The second one is linked to all posts by the author like it should be.

10 Mar 10, 2008 23:39

<?php
$Item->author( array(
'before'    => T_('by ') . '<strong><a href="' . url_add_param( $Blog->get( 'blogurl', 'htmlattr' ),
   'author='. $Item->get('creator_user_ID') ) . '" title="' . T_('Browse all posts by this author') . '">',
'after'     => '</a></strong>',
) );
?>

you don't have to specify the author name in the title, since they are mousing over the author name to see it. If you want to, look into how to display creator_user_firstname, and creator_user_lastname (it's not like the latter, because i just tried it out) right in that section.

11 Mar 11, 2008 15:46

Thanks brandonh! FWIW I suggest working this code with "preferred name" as the goal because there is ALWAYS a preferred name - even when there is not a first or last or nick name. Note that the only name someone must have is a login name, which will be the preferred name when nothing else is available and chosen.

12 Mar 11, 2008 15:58

very true. I always forget details like that, because i manually create all my users with a first and last name, and i disabled editing anything except for the nickname and password.

13 Mar 24, 2008 14:33

Thanks for the code. But what do we change if we want to link to the author's blog homepage?

This links like this .../index.php?author=4
But I would prefer ../index.php?blog=5

14 Apr 03, 2008 00:07

Thanks for the code. But what do we change if we want to link to the author's blog homepage?

This links like this .../index.php?author=4
But I would prefer ../index.php?blog=5

Depending on the number of bloggers you have, you may want to try something like:


<?php
$poster = $Item->get('creator_user_ID');
switch ($poster)
{
case 1:
$blogID = [blogID of user with UserID 1];
break;
case 2:
similar statement;
break;
default:
$blogID = [maybe you would put the blogid of the homepage here just in case something freaks out];
}

$Item->author( array(
'before'    => T_('by ') . '<strong><a href="' . url_add_param( $Blog->get( 'blogurl', 'htmlattr' ),
   'blog='. $blogID . '" title="' . T_('View the blog homepage of this author') . '">',
'after'     => '</a></strong>',
) );

?>

hope that helps. probably an easier way, but i noticed no one has responded for some time. there may be a way to 'extract' the blogID of the blog in which the post was originally posted, but i haven't researched that far.


Form is loading...

Secure CMS – This forum is powered by b2evolution CMS, a complete engine for your website.