Page 1 of 1

Remove author name from beneath pichure in Userprofile plug

Posted: Tue May 09, 2006 7:07 am
by MichaelParent
Hi everyone :)

I'm using the Userprofiles plugin to display an image(avatar) of the author of each entry. I'd like to display only the avatar and no additional information. I checked the box in the plugin control page, which got rid of everything except the name and the picture. Is there any way I can get rid of the name as well?

Thanks.

Re: Remove author name from beneath pichure in Userprofile p

Posted: Tue May 09, 2006 9:15 am
by garvinhicking
Hi!

I believe you could do that with CSS and putting the name as "display:none". Do you have our URL where I can see your current output?

Regards,
Garvin

getting rid of the name under the avatar

Posted: Tue May 09, 2006 2:43 pm
by MichaelParent
Hi Garvin :)

Here's the url...don't mind the mess ;) It's very much a "work in progress"

http://bestsharewaregames.com/serendipity/

Its not the author's name after the "posted by:" that I want to get rid of, it's the name that the Userprofiles plugin is automatically putting under the avatar image at the right of every entry.

Thanks

Re: getting rid of the name under the avatar

Posted: Tue May 09, 2006 3:10 pm
by garvinhicking
Hi!

Actually, you are right, you cannot really change it, not even with CSS. So the plugin file needs patching.

I opened the serendipity_event_userprofiles.php file and searched for "<br>". There you find this two times:

Code: Select all

'<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . htmlspecialchars($authorname) . '" /><br>' . htmlspecialchars($authorname) . '</div>';
You can now either remove that to this:

Code: Select all

'<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . htmlspecialchars($authorname) . '" /></div>';
or, as I did to this:

Code: Select all

'<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . htmlspecialchars($authorname) . '" /><br /><span>' . htmlspecialchars($authorname) . '</span></div>';
And then you can put into your style.css this code:

Code: Select all

.serendipity_authorpic span { display: none}
HTH,
Garvin

Perfect :) Thanks yet again Garvin!

Posted: Wed May 10, 2006 7:33 am
by MichaelParent
That did the trick. I think that was just too easy for you, so here's a trickier question. Would it be possible to make it so that the authors avatar was a link to their homepage that the user could somehow specify?

How could i set it up so that the user(author) or myself could associate a hoempage with them, and make their avatar into a link to that homepage?


thanks :)

Re: Perfect :) Thanks yet again Garvin!

Posted: Wed May 10, 2006 11:00 am
by garvinhicking
Hi!

Hm, indeed this would be harder to do.

Since you are already using the userprofiles plugin, you will see that for each author you can define birthdays, homepage URLs and so on. Now you just need a function that fetches this information and displays it for you.

Doing this is done within the same piece of code, which you replace to this:

Code: Select all

                    if (serendipity_db_bool($this->get_config('gravatar'))) {
                        $img = 'http://www.gravatar.com/avatar.php?'
                                . 'default=' . $this->get_config('gravatar_default','80')
                                . '&gravatar_id=' . md5($eventData['email'])
                                . '&size=' . $this->get_config('gravatar_size','80')
                                . '&border=&rating=' . $this->get_config('gravatar_rating','R');
                        $profile = $this->getConfigVars($eventData['authorid']);
                        $this->found_images[$author] = '<div class="serendipity_authorpic"><a href="' . $profile['url'] . '"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . htmlspecialchars($authorname) . '" /></a><br /><span>' . htmlspecialchars($authorname) . '</span></div>';
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } elseif (isset($this->found_images[$author])) {
                        // Author image was already found previously. Display it.
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } elseif ($img = serendipity_getTemplateFile('img/' . preg_replace('@[^a-z0-9]@i', '_', $author) . '.' . $this->get_config('extension'))) {
                        // Author image exists, save it in cache and display it.
                        $profile = $this->getConfigVars($eventData['authorid']);
                        $this->found_images[$author] = '<div class="serendipity_authorpic"><a href="' . $profile['url'] . '"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . htmlspecialchars($authorname) . '" /></a><br /><span>' .htmlspecialchars($authorname) . '</span></div>';
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } else {
                         // No image found, do not try again in next article.
                        $this->found_images[$author] = '';
                    }
Note how I added

Code: Select all

                        $profile = $this->getConfigVars($eventData['authorid']);
inside there and added a

Code: Select all

<a href="' . $profile['url'] . '">...</a>
to it.

Regards,
Garvin

...A problem :(

Posted: Wed May 10, 2006 6:01 pm
by MichaelParent
Hi Garvin,

Thanks much for your amazing support. I've replaced tat part of the code in the userprofile event file but now, when I check my sight, Internet explorer seems to think its a security risk?! Even when I set my security settings to low, it still refuses to show the author(user) avatars. :(


I'm using internet explorer 6.0.2900.2180.xpsp
and serendipity 8.2

Did I do something wrong? Do I need to change the plugin version of userprofile as well?

thanks for your time :)

Re: ...A problem :(

Posted: Wed May 10, 2006 6:07 pm
by garvinhicking
Hi!

Hm, I guess then you made a mistake in the HTML code? Can you tell me the URL where you get that security error?

When I call http://bestsharewaregames.com/serendipity/ I don'T see any error messages there...

Maybe you missed some closing "> or other characters...

Best regards,
Garvin

Yup. It was something I did :)

Posted: Wed May 10, 2006 10:39 pm
by MichaelParent
I downloaded the latest version of the userprofile plugin from Spartacus, then carefully followed your steps again, and it worked perfectly this time. In other words, I didn't screw it up this time ;)

Thanks again Garvin! :)

Re: Yup. It was something I did :)

Posted: Thu May 11, 2006 10:24 am
by garvinhicking
Hi!

Yay, great to hear that. Have fun!

Regards,
Garvin