1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Styling and Customization Questions' started by Coop1979, Apr 26, 2012.

  1. Coop1979

    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?
     
    Digital Doctor likes this.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> post

    Add the red code:

    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.
     
    Steve F, Brendon Meynell and Coop1979 like this.
  3. Coop1979

    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!

    Add the red code:
    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>
    
     
    alexD likes this.
  4. zooki

    zooki Active Member

    Interesting wonder if it works in 1.2
     
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    The code should work on 1.2.
     
  6. Carlos Oporto

    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.
     
  7. Coop1979

    Coop1979 Well-Known Member

    Just to confirm, this code works brilliantly on 1.3.2.
     
  8. RoldanLT

    RoldanLT Well-Known Member

    Very nice implementation (y)
    I have just created similar Template Modification.
    Above code is outdated because of Multi Quote :)
     

Share This Page