Tách permalink và sharing overlay trong bài viết

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
16,829
Được Like
12,687
Tách permalink và sharing overlay trong bài viết

Trước tiên, bạn cần phải tạo ra hai phrase mới.
Bạn có thể đặt tên tùy ý bạn muốn, miễn là bạn sử dụng cách đặt tên giống nhau trong các template.

Trong ví dụ này, các phrase là:
cta_share : Share
cta_share_this_post : Share this post


Bạn cũng cần phải chỉnh sửa một phrase có sẵn: permalink_for_post_x : Share Options for Post #{position}

Vào template permalink_for_post_x tìm:
Mã:
<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="{$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>

Thay bằng:
Mã:
<div class="publicControls">
    <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="!in_array({$visitor.user_id}, array(1445))">
    <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>
    </xen:hook>
    <a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase cta_share_this_post}" class="item control postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">{xen:phrase cta_share}</a>
    <a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
</div>

Kết quả:

permalink.png
share.png

Nhấp vào permalink bây giờ sẽ chỉ cố định thread trên URL đó.
Nhấp vào liên kết Share sẽ xuất hiện overlay với văn bản bản "Share Options for Post #".

share-options.png

Chúc các bạn thành công.


Nguồn: xenforo.com​
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mobile/Zalo: 0906081284

Telegram: anhanhxf

Chỉ nhận web nội dung lành mạnh

Nhà Tài Trợ

Mút Xốp Không Gian
Mút Sofa Không Gian
Top Bottom