- Posts: 61
COMMUNITY FORUM
[SOLVED] Avatar link to profile
- eastkilla
-
Topic Author
- Offline
- Senior Member
Less
More
11 years 2 months ago #125392
by eastkilla
[SOLVED] Avatar link to profile was created by eastkilla
Hi all,
In comments list, I would like to link user's avatar to their profiles like the link in author name.
In item.php, I tried this :
<?php if($comment->userImage): ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" target="_blank" rel="nofollow"><img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" /></a>
<?php endif; ?>
It works but now when I click on athor name link, I have Error: 404
Thanks for help
In comments list, I would like to link user's avatar to their profiles like the link in author name.
In item.php, I tried this :
<?php if($comment->userImage): ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" target="_blank" rel="nofollow"><img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" /></a>
<?php endif; ?>
It works but now when I click on athor name link, I have Error: 404
Thanks for help
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 2 months ago #125393
by Lefteris
Replied by Lefteris on topic Re: Avatar link to profile
Hi. It's because you are checking against the image and not the link. Guests do not have a link. Try something like this:
<?php if(!empty($comment->userLink)): ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" target="_blank" rel="nofollow"><img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" /></a>
<?php endif; ?>
Please Log in or Create an account to join the conversation.
- eastkilla
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
11 years 2 months ago #125394
by eastkilla
Replied by eastkilla on topic Re: Avatar link to profile
Hi Lefteris Kavadas,
I try your solution, it works for image profil link, but I always have the same problem when I click on user link, I have error 404 :(
I try your solution, it works for image profil link, but I always have the same problem when I click on user link, I have error 404 :(
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 2 months ago #125395
by Lefteris
Replied by Lefteris on topic Re: Avatar link to profile
You need to remove your custom code. Not all users have a profile page. That's why i gave you this code. Since you are not familiar with programming keep only the original code and just add mine code to make avatars linkable.
Please Log in or Create an account to join the conversation.
- eastkilla
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
11 years 2 months ago #125396
by eastkilla
Replied by eastkilla on topic Re: Avatar link to profile
Hi thanks for your help,
I have removed my custom code and add yours like this :
I have removed my custom code and add yours like this :
Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 2 months ago #125397
by Lefteris
Replied by Lefteris on topic Re: Avatar link to profile
What's the URL that gives 404? Maybe the user has been deleted or is blocked.
Please Log in or Create an account to join the conversation.
- eastkilla
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
11 years 2 months ago #125398
by eastkilla
Replied by eastkilla on topic Re: Avatar link to profile
User isn't deleted or blocked, same problem with all users.
Error: 404 - page not found
You may not be able to visit this page because of:
an out-of-date bookmark/favourite
a search engine that has an out-of-date listing for this site
a mistyped address
you have no access to this page
The requested resource was not found.
An error has occurred while processing your request.
Error: 404 - page not found
You may not be able to visit this page because of:
an out-of-date bookmark/favourite
a search engine that has an out-of-date listing for this site
a mistyped address
you have no access to this page
The requested resource was not found.
An error has occurred while processing your request.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 2 months ago #125399
by Lefteris
Replied by Lefteris on topic Re: Avatar link to profile
What's the URL?
Please Log in or Create an account to join the conversation.
- eastkilla
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
11 years 2 months ago #125400
by eastkilla
Replied by eastkilla on topic Re: Avatar link to profile
http://localhost/mysite/index.php/component/k2%20view=itemlist%20task=user%20id=565:user1/
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 2 months ago #125401
by Lefteris
Replied by Lefteris on topic Re: Avatar link to profile
OK probably the URL clean up function is executed twice. Try this:
<!-- Item user comments -->
<h3 class="itemCommentsCounter">
<span><?php echo $this->item->numOfComments; ?></span> <?php echo ($this->item->numOfComments>1) ? JText::_('K2_COMMENTS') : JText::_('K2_COMMENT'); ?>
</h3>
<ul class="itemCommentsList">
<?php foreach ($this->item->comments as $key=>$comment): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; echo (!$this->item->created_by_alias && $comment->userID==$this->item->created_by) ? " authorResponse" : ""; echo($comment->published) ? '':' unpublishedComment'; ?>">
<?php
$userName = JFilterOutput::cleanText($comment->userName);
if (!empty($comment->userLink))
{
$userLink = JFilterOutput::cleanText($comment->userLink);
}
?>
<?php if(!empty($comment->userLink)): ?>
<a href="<?php echo $userLink; ?>" target="_blank" rel="nofollow"><img src="<?php echo $comment->userImage; ?>" alt="<?php echo $userName; ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" /></a>
<?php endif; ?>
<span class="commentDate"><?php echo JHTML::_('date', $comment->commentDate, JText::_('K2_DATE_FORMAT_LC2')); ?></span>
<span class="commentAuthorName">
<?php if(!empty($comment->userLink)): ?>
<a href="<?php echo $userLink; ?>" title="<?php echo $userName; ?>" target="_blank" rel="nofollow"><?php echo $comment->userName; ?></a>
<?php else: ?>
<?php echo $comment->userName; ?>
<?php endif; ?>
</span>
Please Log in or Create an account to join the conversation.
- eastkilla
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 61
11 years 2 months ago #125402
by eastkilla
Replied by eastkilla on topic Re: Avatar link to profile
Woooow,
K2 = best support ever !
Thanks a lot Lefteris Kavadas. It works very well !!!
K2 = best support ever !
Thanks a lot Lefteris Kavadas. It works very well !!!
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 2 months ago #125403
by Lefteris
Replied by Lefteris on topic Re: Avatar link to profile
You are welcome.
Please Log in or Create an account to join the conversation.