The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
3 posters

    Quote button for Guest

    TamDonCo
    TamDonCo
    Forumember


    Posts : 427
    Reputation : 2
    Language : English

    Solved Quote button for Guest

    Post by TamDonCo January 10th 2019, 10:18 pm

    Hi All

    Is anyway we enable quote button for Guest to quote ?


    Thanks


    Last edited by TamDonCo on January 11th 2019, 6:54 pm; edited 1 time in total
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    Solved Re: Quote button for Guest

    Post by SLGray January 10th 2019, 10:37 pm

    If guests are allowed to post on your forum, they should be able to see all the buttons in the topic.  Could you post a link to a topic that guests can reply to.



    Quote button for Guest Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Guest
    Guest


    Solved Re: Quote button for Guest

    Post by Guest January 10th 2019, 10:42 pm

    I did a test on my forum and the quote button doesn't appear even if guest posting is allowed. I can make a javascript code to add that functionality if you post your forum link and a link to a topic that guests can see here.
    TamDonCo
    TamDonCo
    Forumember


    Posts : 427
    Reputation : 2
    Language : English

    Solved Re: Quote button for Guest

    Post by TamDonCo January 10th 2019, 10:49 pm

    SLGray wrote:If guests are allowed to post on your forum, they should be able to see all the buttons in the topic.  Could you post a link to a topic that guests can reply to.

    Quote button like this

    Quote button for Guest 2019.01.10-16-47-13162cc49fa8fe74db

    http://www.nhomcho.com/t10597-ngo-biet-khi-yeu-la-au-kho
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    Solved Re: Quote button for Guest

    Post by SLGray January 10th 2019, 10:53 pm

    Guests are only allowed to post, but they do not have full access as members do.



    Quote button for Guest Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Guest
    Guest


    Solved Re: Quote button for Guest

    Post by Guest January 10th 2019, 10:54 pm

    Actually the links for quoting are active, but there are no buttons for them.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    Solved Re: Quote button for Guest

    Post by SLGray January 10th 2019, 11:01 pm

    Are you saying there is no image for the button?



    Quote button for Guest Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Guest
    Guest


    Solved Re: Quote button for Guest

    Post by Guest January 10th 2019, 11:05 pm

    When you click on the quote button on this forum for example, it redirects you to https://help.forumotion.com/post?p=POSTID&mode=quote, where POSTID is the id of the post you are quoting. If a guest can post, they can manually type that page in the bar and quote a post that way, despite the fact that no button appears on the topic page. I am working on a code that adds that button there.
    avatar
    Guest
    Guest


    Solved Re: Quote button for Guest

    Post by Guest January 10th 2019, 11:35 pm

    Add this code with placement on topics:
    Code:
    document.addEventListener("DOMContentLoaded", function(){
    if(_userdata.user_id===-1){
    var css=".button_guest_quote{float:right;background:#00689A;color:white !important;padding:5px;font-size:15px;}";
    var style=document.createElement("style");
    style.innerHTML=css;
    document.querySelector("head").appendChild(style);
    var posts=document.querySelectorAll(".post"), insafter=document.querySelectorAll("h2.topic-title"), len=posts.length, id, button;
    if(len!==0){
    for(var i=0;i<len;i++){
    id=parseInt(posts[i].getAttribute("id").match(/\d+/)[0]);
    if(id!==0){
    button=document.createElement("a");
    button.classList.add("button_guest_quote");
    button.innerHTML="Quote";
    button.setAttribute("href", "/post?p="+id+"&mode=quote");
    insafter[i].parentNode.insertBefore(button, insafter[i].nextSibling);
    }
    }
    }
    }
    })
    TamDonCo
    TamDonCo
    Forumember


    Posts : 427
    Reputation : 2
    Language : English

    Solved Re: Quote button for Guest

    Post by TamDonCo January 11th 2019, 5:26 am

    Menim

    Thank You

    I will try the code tomorrow
    TamDonCo
    TamDonCo
    Forumember


    Posts : 427
    Reputation : 2
    Language : English

    Solved Re: Quote button for Guest

    Post by TamDonCo January 11th 2019, 3:12 pm

    Thank You very much

    It works but 1 syntax error

    _userdata.user_id===-1

    remove extra "="
    avatar
    Guest
    Guest


    Solved Re: Quote button for Guest

    Post by Guest January 11th 2019, 6:29 pm

    Actually that code is correct both with 2 "=" and with 3 "=". With 2 "=" it compares the value of _userdata.user_id with -1(-1 meaning that the user is a guest). WIth 3 "=" it compares both the values and the types. In this case, there's no difference between them, but I usually use === because its generally safer than ==. For example, "2"==2 is true, but "2"===2 is false, because "2" is a string and 2 is an integer.

    Nonetheless, glad the code works. Smile
    TamDonCo
    TamDonCo
    Forumember


    Posts : 427
    Reputation : 2
    Language : English

    Solved Re: Quote button for Guest

    Post by TamDonCo January 11th 2019, 6:53 pm

    Menim wrote:Actually that code is correct both with 2 "=" and with 3 "=". With 2 "=" it compares the value of _userdata.user_id with -1(-1 meaning that the user is a guest). WIth 3 "=" it compares both the values and the types. In this case, there's no difference between them, but I usually use === because its generally safer than ==. For example, "2"==2 is true, but "2"===2 is false, because "2" is a string and 2 is an integer.

    Nonetheless, glad the code works. Smile

    Thank You very much
    Draxion
    Draxion
    Helper
    Helper


    Male Posts : 2518
    Reputation : 321
    Language : English
    Location : USA

    Solved Re: Quote button for Guest

    Post by Draxion January 11th 2019, 7:23 pm

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules

      Current date/time is November 13th 2024, 4:45 pm