Show "Like" for guests; click opens login/registration overlay?

Coop1979

Well-known member
Here's an idea that ran through my head while doing some testing on my XenForo installation. Why not show the "Like" button (link) to guests, but have the click either open a login/registration overlay like in this add-on, or jump you to the top of the page by opening the drop-down login/registration "drawer".

Does anyone have any idea how to do this?
 

Jake Bunce

XenForo moderator
Staff member
Admin CP -> Appearance -> Templates -> post

Add the red code:

Rich (BB code):
			<div class="publicControls">
				<a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
				<xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
				<xen:if is="{$post.canLike}">
					<a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
				</xen:if>
				<xen:if is="!{$post.canLike}">
					<a href="{xen:link login}" class="item control OverlayTrigger"><span></span>{xen:phrase like}</a>
				</xen:if>
				<xen:if is="{$canReply}">
					<a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}" data-postUrl="{xen:link posts/quote, $post}" class="ReplyQuote item control reply" title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
				</xen:if>
				</xen:hook>
			</div>
Now guests will see a Like link in posts that spawns a login / register overlay.
 

Coop1979

Well-known member
Awesome, thanks so much, Jake. I've also used your code to add a "Reply" link as well (see code below). Works great!

Admin CP -> Appearance -> Templates -> post
Add the red code:
Rich (BB code):
<div class="publicControls">
<a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
<xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
<xen:if is="{$post.canLike}">
<a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
</xen:if>
<xen:if is="!{$post.canLike}">
<a href="{xen:link login}" class="item control OverlayTrigger"><span></span>{xen:phrase like}</a>
</xen:if>
<xen:if is="{$canReply}">
<a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}" data-postUrl="{xen:link posts/quote, $post}" class="ReplyQuote item control reply" title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
</xen:if>
<xen:if is="!{$canReply}">
<a href="{xen:link login}" class="item control OverlayTrigger"><span></span>{xen:phrase reply}</a>
</xen:if>
</xen:hook>
</div>
 

Carlos Oporto

New member
I confirm this code it's working in 1.2, already implemented on the site with the like and reply. Also I added a small opacity background color to the overlay so it looks nicer.
 

rdn

Well-known member
Awesome, thanks so much, Jake. I've also used your code to add a "Reply" link as well (see code below). Works great!


Add the red code:
Rich (BB code):
<div class="publicControls">
<a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
<xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
<xen:if is="{$post.canLike}">
<a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
</xen:if>
<xen:if is="!{$post.canLike}">
<a href="{xen:link login}" class="item control OverlayTrigger"><span></span>{xen:phrase like}</a>
</xen:if>
<xen:if is="{$canReply}">
<a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}" data-postUrl="{xen:link posts/quote, $post}" class="ReplyQuote item control reply" title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
</xen:if>
<xen:if is="!{$canReply}">
<a href="{xen:link login}" class="item control OverlayTrigger"><span></span>{xen:phrase reply}</a>
</xen:if>
</xen:hook>
</div>
Very nice implementation (y)
I have just created similar Template Modification.
Above code is outdated because of Multi Quote :)
 
Top