XF 2.0 Login to view full content of thread?

Emre

Well-known member
Guest site thread Please login to view full content of thread how can I do it? :X3:

Demo;
2018-03-22_20-08-04.webp

Reading 200/300 characters. ? :unsure:
 
in post_macros template find (in line 66)
HTML:
                            <article class="message-body js-selectToQuote">
                                <xf:ad position="post_above_content" arg-post="{$post}" />
                                {{ bb_code($post.message, 'post', $post) }}
                                <div class="js-selectToQuoteEnd">&nbsp;</div>
                                <xf:ad position="post_below_content" arg-post="{$post}" />
                            </article>
Replace with this
HTML:
                            <article class="message-body js-selectToQuote">
                                <xf:ad position="post_above_content" arg-post="{$post}" />
                                <xf:if is="!$xf.visitor.user_id">
                                    <xf:set var="$snippetPost" value="{{ snippet($post.message, 300) }}" />
                                    {{  bb_code($snippetPost, 'post', $post)  }}
                                    <xf:if is="$snippetPost != $post.message">
                                        <div class="blockMessage blockMessage--important blockMessage--iconic">
                                            Please login to view full content
                                        </div>
                                    </xf:if>
                                <xf:else/>
                                    {{ bb_code($post.message, 'post', $post) }}
                                </xf:if>
                                <div class="js-selectToQuoteEnd">&nbsp;</div>
                                <xf:ad position="post_below_content" arg-post="{$post}" />
                            </article>
 
@DL6 , What I want to do is;
  1. One post content view shows 300 characters. (Done) (y)
    2018-03-22_21-11-14.webp
    Link view: Look Please (Hide done) different url content open? Look please; View (Not hidden!) (n)

  2. Post reply guest view.
    2018-03-22_21-13-25.webp
    More than 300 characters. Not hidden and open :X3:
Do you understand? :unsure:
 
Ok, now replace with this in post_macros template
HTML:
                            <article class="message-body js-selectToQuote">
                                <xf:ad position="post_above_content" arg-post="{$post}" />
                                <xf:if is="!$xf.visitor.user_id">
                                    <xf:set var="$snippetPost" value="{{ snippet($post.message, 300) }}" />
                                    {{  bb_code($snippetPost, 'post', $post)  }}
                                    <div class="blockMessage blockMessage--important blockMessage--iconic">
                                        Please login to view full content
                                    </div>
                                <xf:else/>
                                    {{ bb_code($post.message, 'post', $post) }}
                                </xf:if>
                                <div class="js-selectToQuoteEnd">&nbsp;</div>
                                <xf:ad position="post_below_content" arg-post="{$post}" />
                            </article>
In thread_view template
find
HTML:
        <div class="block-body js-replyNewMessageContainer">
            <xf:foreach loop="$posts" value="$post">
                <xf:if is="$post.message_state == 'deleted'">
                    <xf:macro template="post_macros" name="post_deleted"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                <xf:else />
                    <xf:macro template="post_macros" name="post"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                </xf:if>
            </xf:foreach>
        </div>
    </div>
Replace with this
HTML:
        <div class="block-body js-replyNewMessageContainer">
            <xf:foreach loop="$posts" value="$post">
                <xf:if is="$post.message_state == 'deleted'">
                    <xf:macro template="post_macros" name="post_deleted"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                <xf:else />
                    <xf:if is="!$xf.visitor.user_id AND $post.isFirstPost() OR $xf.visitor.user_id">
                    <xf:macro template="post_macros" name="post"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                    </xf:if>
                </xf:if>
            </xf:foreach>
        </div>
    </div>

find
HTML:
        <xf:pagenav
            page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
            link="threads" data="{$thread}"
            wrapperclass="block-outer-main" />
Replace
HTML:
        <xf:if is="$xf.visitor.user_id">
        <xf:pagenav
            page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
            link="threads" data="{$thread}"
            wrapperclass="block-outer-main" />
        </xf:if>
find
HTML:
                <xf:pagenav
                    page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
                    link="threads" data="{$thread}"
                    wrapperclass="block-outer-main" />
replace
HTML:
                <xf:if is="$xf.visitor.user_id">
                <xf:pagenav
                    page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
                    link="threads" data="{$thread}"
                    wrapperclass="block-outer-main" />
                </xf:if>
 
Ok, now replace with this in post_macros template
HTML:
                            <article class="message-body js-selectToQuote">
                                <xf:ad position="post_above_content" arg-post="{$post}" />
                                <xf:if is="!$xf.visitor.user_id">
                                    <xf:set var="$snippetPost" value="{{ snippet($post.message, 300) }}" />
                                    {{  bb_code($snippetPost, 'post', $post)  }}
                                    <div class="blockMessage blockMessage--important blockMessage--iconic">
                                        Please login to view full content
                                    </div>
                                <xf:else/>
                                    {{ bb_code($post.message, 'post', $post) }}
                                </xf:if>
                                <div class="js-selectToQuoteEnd">&nbsp;</div>
                                <xf:ad position="post_below_content" arg-post="{$post}" />
                            </article>
In thread_view template
find
HTML:
        <div class="block-body js-replyNewMessageContainer">
            <xf:foreach loop="$posts" value="$post">
                <xf:if is="$post.message_state == 'deleted'">
                    <xf:macro template="post_macros" name="post_deleted"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                <xf:else />
                    <xf:macro template="post_macros" name="post"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                </xf:if>
            </xf:foreach>
        </div>
    </div>
Replace with this
HTML:
        <div class="block-body js-replyNewMessageContainer">
            <xf:foreach loop="$posts" value="$post">
                <xf:if is="$post.message_state == 'deleted'">
                    <xf:macro template="post_macros" name="post_deleted"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                <xf:else />
                    <xf:if is="!$xf.visitor.user_id AND $post.isFirstPost() OR $xf.visitor.user_id">
                    <xf:macro template="post_macros" name="post"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                    </xf:if>
                </xf:if>
            </xf:foreach>
        </div>
    </div>

find
HTML:
        <xf:pagenav
            page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
            link="threads" data="{$thread}"
            wrapperclass="block-outer-main" />
Replace
HTML:
        <xf:if is="$xf.visitor.user_id">
        <xf:pagenav
            page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
            link="threads" data="{$thread}"
            wrapperclass="block-outer-main" />
        </xf:if>
find
HTML:
                <xf:pagenav
                    page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
                    link="threads" data="{$thread}"
                    wrapperclass="block-outer-main" />
replace
HTML:
                <xf:if is="$xf.visitor.user_id">
                <xf:pagenav
                    page="{$page}" perpage="{$perPage}" total="{{ $thread.reply_count + 1 }}"
                    link="threads" data="{$thread}"
                    wrapperclass="block-outer-main" />
                </xf:if>
Hello,

Can I have your permission to make an add-on with this tutorial ? Of course with the credits in the thread/addon.json !

Regards, SyTry
 
Top Bottom