Quote button for Guest

Go down

Solved Quote button for Guest

Post by TamDonCo on Thu Jan 10 2019, 23:18

Hi All

Is anyway we enable quote button for Guest to quote ?


Thanks


Last edited by TamDonCo on Fri Jan 11 2019, 19:54; edited 1 time in total
TamDonCo
TamDonCo
Forumember

Posts : 391
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by SLGray on Thu Jan 10 2019, 23:37

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.



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

Male Posts : 45327
Reputation : 3193
Language : English
Location : United States

https://help.forumotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by Guest on Thu Jan 10 2019, 23:42

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.
avatar
Guest
Guest


Back to top Go down

Solved Re: Quote button for Guest

Post by TamDonCo on Thu Jan 10 2019, 23:49

@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



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

Posts : 391
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by SLGray on Thu Jan 10 2019, 23:53

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



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

Male Posts : 45327
Reputation : 3193
Language : English
Location : United States

https://help.forumotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by Guest on Thu Jan 10 2019, 23:54

Actually the links for quoting are active, but there are no buttons for them.
avatar
Guest
Guest


Back to top Go down

Solved Re: Quote button for Guest

Post by SLGray on Fri Jan 11 2019, 00:01

Are you saying there is no image for the button?



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

Male Posts : 45327
Reputation : 3193
Language : English
Location : United States

https://help.forumotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by Guest on Fri Jan 11 2019, 00:05

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


Back to top Go down

Solved Re: Quote button for Guest

Post by Guest on Fri Jan 11 2019, 00:35

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);
}
}
}
}
})
avatar
Guest
Guest


Back to top Go down

Solved Re: Quote button for Guest

Post by TamDonCo on Fri Jan 11 2019, 06:26

Menim

Thank You

I will try the code tomorrow
TamDonCo
TamDonCo
Forumember

Posts : 391
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by TamDonCo on Fri Jan 11 2019, 16:12

Thank You very much

It works but 1 syntax error

_userdata.user_id===-1

remove extra "="
TamDonCo
TamDonCo
Forumember

Posts : 391
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by Guest on Fri Jan 11 2019, 19:29

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
avatar
Guest
Guest


Back to top Go down

Solved Re: Quote button for Guest

Post by TamDonCo on Fri Jan 11 2019, 19:53

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
TamDonCo
TamDonCo
Forumember

Posts : 391
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

Solved Re: Quote button for Guest

Post by Draxion on Fri Jan 11 2019, 20:23

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


NEVER provide your founder's account or email
Please provide forum's URL when dealing with design and appearance issues
Don't forget to mark the topic as when the issue is resolved. This helps the staff greatly.
PM Support is prohibited!
TOS | General Rules | FAQ | Tricks & Tips | Latest Updates | Introduce Yourself

Draxion
Draxion
Support Moderator
Support Moderator

Male Posts : 2259
Reputation : 284
Language : English
Location : USA

http://www.draxionsgameden.com/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum