forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: skad4life on May 09, 2006, 12:45:06 am

Title: Commenters name links to members profile - but not for guests ?
Post by: skad4life on May 09, 2006, 12:45:06 am
Hi everyone!

My first post was about wanting to link the name of commenters to their profile. Nibbler posted an easy modification (http://forum.coppermine-gallery.net/index.php?topic=30995.msg143483#msg143483), 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:
Code: [Select]
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:
Code: [Select]
<a href="profile.php?uid={AUTHOR_ID}"><b>{MSG_AUTHOR}</b></a><a name="comment{MSG_ID}"></a>
I made this:
Code: [Select]
<?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
Title: Re: Commenters name links to members profile - but not for guests ?
Post by: Stramm on May 09, 2006, 09:43:39 am
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
Code: [Select]
        $params = array('{MSG_AUTHOR}' => $row['msg_author'],and replace with
Code: [Select]
($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
Title: Re: Commenters name links to members profile - but not for guests ?
Post by: skad4life on May 09, 2006, 10:27:20 pm
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 :)
Title: Re: Commenters name links to members profile - but not for guests ?
Post by: skad4life on May 15, 2006, 03:23:21 am
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
Code: [Select]
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
Title: Re: Commenters name links to members profile - but not for guests ?
Post by: Stramm on May 15, 2006, 08:56:29 am
ya, that's the problem if we both use modded versions ;)
it needs to be
Code: [Select]
($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>";
Title: Re: Commenters name links to members profile - but not for guests ?
Post by: skad4life on May 15, 2006, 05:33:58 pm
Awesome! One day I want to learn all this php and sql stuff - such a useful skill.
Thank you, thank you, Stramm!

Jael