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.

Quote button for Guest

3 posters

Go down

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

Posts : 427
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

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.
SLGray
SLGray
Administrator
Administrator

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

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

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


Back to top Go down

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

Posts : 427
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

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.
SLGray
SLGray
Administrator
Administrator

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

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

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


Back to top Go down

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.
SLGray
SLGray
Administrator
Administrator

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

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

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


Back to top Go down

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


Back to top Go down

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

http://nhomcho.forummotion.com/

Back to top Go down

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

Posts : 427
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

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


Back to top Go down

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

Posts : 427
Reputation : 2
Language : English

http://nhomcho.forummotion.com/

Back to top Go down

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
Draxion
Draxion
Helper
Helper

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

https://www.talesoftellene.com/

Back to top Go down

Back to top

- Similar topics

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