Reputation: 49
I ma using grails 2.1.1 and developing a twitter clone application. When a user has posted a post, my application shows a list of those posts with the user's photo, his/her Full Name and username, created post and time the post was created. When I click on the username of the user who created the post (which is actually a g:link), I need to get redirected to that specific user's profile, not the active user's profile. Below is my postentries.gsp code which shows all the posts of those users whom current active user is following...
<div class="container well span8">
<div class="postImage">
<div class="span1">
<g:if test="${post.user.profile.photo}">
<img src="${createLink(controller: 'image', action: 'renderImage', id: post.user.username)}" class="img-rounded"/>
</g:if>
</div>
</div>
<div class="postEntry">
<div class="postText">
<div class="span8">
**<g:link controller="post" action="profile"><b>${post.user.profile.fullName}</b>@(${post.user.username})</g:link>**
${post.content}
</div>
<div class="postDate">
<h:dateFromNow date="${post.createdOn}"/>
</div>
</div>
</div>
</div>
Below is profile.gsp code
<html>
<head>
<meta name="layout" content="bootstrap"/>
<title>${user.profile.fullName}'s Profile Page</title>
</head>
<body>
<div class="container well span4" id="sidebar">
</div>
<div class="container well span8">
<div class="span3"></div>
<div class="container-fluid well text-center span6">
<div class="row-fluid span1">
<g:if test="${user.profile.photo}">
<img src="${createLink(controller: 'image', action: 'renderImage', id: user.username)}" class="img-rounded"/>
</g:if>
</div>
<div class="row-fluid">
<h3>${user.profile.fullName}</h3>
<h4>@${user.username}</h4>
<h5>${user.profile.country}</h5>
</div>
<div class="span3"></div>
</div>
</div>
</body>
</html>
The problem is that when I click on the username's g:link, I always redirected to active user's profile which I do not want.
Upvotes: 0
Views: 143
Reputation: 11663
you need to specify the id
of the profile you want in your postentries.gsp
**<g:link controller="post" action="profile" id="${post?.user?.profile.id}">
<b>${post.user.profile.fullName}</b>@(${post.user.username})</g:link>**
Upvotes: 0