Commenters name links to members profile - but not for guests ? Commenters name links to members profile - but not for guests ?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Commenters name links to members profile - but not for guests ?

Started by skad4life, May 09, 2006, 12:45:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

skad4life

Hi everyone!

My first post was about wanting to link the name of commenters to their profile. Nibbler posted an easy modification, and it worked great. So now that I'm almost done with my gallery and manually inserting previous comments by users who were all guests, I noticed that the guests name's are also hyperlinks that don't link to an existing profile (obviously).

What I would like to do is make an if/else command just like on the "Last Comments" page, where only registered users names link to a profile.

This is the code/function for the Last Comments page:
if ($row['author_id']) {
                $caption .= '<span class="thumb_caption"><a href ="profile.php?uid='.$row['author_id'].'">'.$row['msg_author'].'</a>: '.$msg_body.'</span>';
            } else {
                    $caption .= '<span class="thumb_caption">'.$row['msg_author'].': '.$msg_body.'</span>';
            }


So I thought I'd be clever (not having much of a clue), and copied those lines into my theme.php right where the comment html is.
Out of this:
<a href="profile.php?uid={AUTHOR_ID}"><b>{MSG_AUTHOR}</b></a><a name="comment{MSG_ID}"></a>

I made this:
<?php
        if (
$row['author_id']) {
                
$caption .= '<a href="profile.php?uid='.$row['author_id'].'"><b>'.$row['msg_author'].'</b></a><a name="'.$comment['MSG_ID'].'"></a>';

            } else {
                
$caption .= ''.$row['msg_author'].'<a name="'.$comment['MSG_ID'].'"></a>';
            }
?>


You're probably shaking your head, and yes, all I got was an error. I know it's something like that, but only if it was that easy.
Could someone tell me what it should be, and can it even go right inbetween the html or do I have to make a function out of it and go a different route?

Thank you!
Jael

Stramm

I do not exactly know Nibbler's modifications... I just can tell you mine

you need to copy function theme_html_comments from themes/sample/theme.php to the theme you're actually using.

now find
        $params = array('{MSG_AUTHOR}' => $row['msg_author'],
and replace with
($row['author_id'] == 0 ) ? $profile_lnk = stripslashes($row['msg_author']): $profile_lnk = "<a href=\"profile.php?uid={AUTHOR_ID}\">".stripslashes($row['msg_author'])."</a>";

        $params = array('{MSG_AUTHOR}' => $profile_lnk,


edit: forgotten to mention... this requires an unmodified function theme_html_comments and $template_image_comments. If you do not have made other changes than the clickable commenter names, just delete function theme_html_comments and $template_image_comments from your theme.php before you start modding

skad4life

Hi Stramm, and thank you for your reply!

That worked perfectly, now I'm all set. I thank you very much for your help, all of you are awesome!

Jael :)

skad4life

I don't know if I can still post in this thread, but something came up.

I made a new gallery today, and wanted to modify the commenters links as described above. As the output I just got
http://www.pixelportal.net/skantasm/photos/profile.php?uid={AUTHOR_ID} which is obviously not a working link.

So I thought that was odd and decided to just copy the code from the other site, since it was working there. To my surprise it wasn't working there anymore either, same link. I started from scratch, just as described, three times now. I even uninstalled my one plugin (Display Fields, only using it on the new site), and cleared the entire theme.php, then copied only function theme_html_comments and $template_image_comments in it, then modified the specified part.

I haven't been working on the first site for a few days now, and I don't remember changing anything. Plus, it's not working on the fresh install either. Should there be something else, that needs to go with it? I'm confused.

Thank you in advance.
Jael

Stramm

ya, that's the problem if we both use modded versions ;)
it needs to be
($row['author_id'] == 0 ) ? $profile_lnk = stripslashes($row['msg_author']): $profile_lnk = "<a href=\"profile.php?uid={$row['author_id']}\">".stripslashes($row['msg_author'])."</a>";

skad4life

Awesome! One day I want to learn all this php and sql stuff - such a useful skill.
Thank you, thank you, Stramm!

Jael