how can i Hide content with tags? - Posted (2774 Views)
Starting Member
Icaro
Posts: 3
3
hi:

Im new for snitz, i implemented lots of mods without problems but im looking for an specific mod that hides some of the content inside a post (a link or a text) by using [hide][/hide] tags, so when a non logged user is viewing the post he will only see a MSG saying "Hidden Content, Please Log in"

I tried to do it myself but i couldnt make it work, i added some lines on inc_func_common.asp i think it have to do something with:

if mlev > 0 then... but i dont know what the following line should be

I was thinking also about a feature that unhides the content (of a topic) only when you post a reply...
Any ideas on how can i do this?
thanks in advance.<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Average Member
cripto9t
Posts: 881
881
Look through this thread
http://forum.snitz.com/forum/topic.asp?ARCHIVE=true&TOPIC_ID=56099&SearchTerms=hide<
    _-/Cripto9t\-_
Posted
Starting Member
Icaro
Posts: 3
3
Thanks for your help! Thats what i was looking for...<
Posted
Senior Member
muzishun
Posts: 1079
1079
To help consolidate and give you a couple more options, here are three different hide tags that I use on my forum. They are for three different purposes.
[spoiler][/spoiler] This one creates a box around the spoiler text with a button that shows or hides the content of the box dynamically. For longer sections of a page that you want to hide, and for times you want to have other forum code within your hidden text.
[spoiler2][/spoiler2] This one is mostly for hiding a few lines of text. Just creates a shaded box where the text is the same color as the background.
[hidden][/hidden] This one has a check from topic.asp that, if the user isn't logged in (or if a guest visits the page), the text within these tags is replaced with a message that the user needs to log in to see the hidden text.
[modnote][/modnote] Basically the same as the one above, but text is hidden from normal users and guests. Useful for moderators and Admins to make notes to each other about posts.
I can provide you with the code I use for these if you want. Most of it has been posted here in the past, so you should be able to find it with some searching (and also at the link cripto9t mentioned above).<
Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
Posted
Forum Moderator
AnonJr
Posts: 5768
5768
go ahead and post it all in one spot smile - makes it easier to point people to a central location as opposed to "this topic has this bit, and that one has that bit, oh, and that one has part of what you need..." wink<
Posted
Senior Member
bobby131313
Posts: 1163
1163
Posted
Senior Member
muzishun
Posts: 1079
1079
In inc_func_common.asp, find the extratags function and replace it with this (or just add the spoiler parts to your function) and add the two functions beneath it:

Code:

function extratags(fString)
fString = doCode(fString, "[spoiler2]", "[/spoiler2]", "<span class=""spoiler"">Spoiler:</span><div class=""spoiler""><kbd>", "</kbd></div>")
fString = doCode(fString, "[spoiler]", "[/spoiler]", "<div style=""margin:1em auto; width: 90%;"">" & vbNewline & " <div><strong>Spoiler:</strong> <input type=""button"" value=""Show"" style=""width:45px;font-size:10px;margin:0px;padding:0px;"" onclick=""if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }"" /></div>" & vbNewline & " <div style=""margin: 0px; padding: 6px; border: 1px inset;"">" & vbNewline & " <div style=""display: none;"">" & vbNewline, " </div>" & vbNewline & " </div>" & vbNewline & "</div>" & vbNewline)
extratags = fString
end function


function HideText(txt,mode)
If mode = 1 Then
Set regEx = New RegExp
regEx.Pattern = "\[hidden.*?\/hidden\]"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(txt)
HideText = regEx.Replace(txt, "<p><strong>You must log in to see this text.</strong></p>")
Else 'mode = 2
txt = Replace(txt,"[hidden]","")
txt = Replace(txt,"[/hidden]","")
HideText = txt
End If
end function


function ModNoteText(txt,mode)
Set regEx = New RegExp
regEx.Pattern = "\[modnote.*?\/modnote\]"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(txt)
If mode = 1 Then 'User is an admin
ModNoteText = txt
Else 'mode = 2
ModNoteText = regEx.Replace(txt, "")
End If
end function

Then, in topic.asp, do a search for the following text: "if Request.QueryString("SearchTerms") <> """. This should happen twice, and it's at the parts of topic.asp that display the text for the posts. Here's how I've got these working with the nested If..Then statements. You may or may not need to tweak it for your own forums.
Code:

			if Request.QueryString("SearchTerms") <> "" then
If mlev = 0 Then
Response.Write ModNoteText(HideText(SearchHiLite(formatStr(Reply_Content)),1),2)
Else
If mlev > 2 Then 'User is a mod or admin
Response.Write ModNoteText(HideText(SearchHiLite(formatStr(Reply_Content)),2),1)
Else
Response.Write ModNoteText(HideText(SearchHiLite(formatStr(Reply_Content)),2),2)
End If
End If
else
If mlev = 0 Then
Response.Write ModNoteText(HideText(formatStr(Reply_Content),1),2)
Else
If mlev > 2 Then 'User is a mod or admin
Response.Write ModNoteText(HideText(formatStr(Reply_Content),2),1)
Else
Response.Write ModNoteText(HideText(formatStr(Reply_Content),2),2)
End If
End If
end if
and
Code:

		if Request.QueryString("SearchTerms") <> "" then
If mlev = 0 Then
Response.Write ModNoteText(HideText(SearchHiLite(formatStr(Topic_Message)),1),2)
Else
If mlev > 2 Then 'User is a mod or admin
Response.Write ModNoteText(HideText(SearchHiLite(formatStr(Topic_Message)),2),1)
Else
Response.Write ModNoteText(HideText(SearchHiLite(formatStr(Topic_Message)),2),2)
End If
End If
else
If mlev = 0 Then
Response.Write ModNoteText(HideText(formatStr(Topic_Message),1),2)
Else
If mlev > 2 Then 'User is a mod or admin
Response.Write ModNoteText(HideText(formatStr(Topic_Message),2),1)
Else
Response.Write ModNoteText(HideText(formatStr(Topic_Message),2),2)
End If
End If
end if

Lastly, wherever you have your CSS information (mine is in a separate CSS file, but the base Snitz has it in inc_header.asp), add the following CSS info.
Code:

/* This is for the spoiler tag. */
div.spoiler {margin: 0 5%; border: 1px dashed <%=ReplaceColorWithHex(strPageBGColor)%>; background-color: <%=ReplaceColorWithHex(strHeadCellColor)%>; color: inherit;}
kbd {font-style: normal; font-weight: normal; display: block; color: <%=ReplaceColorWithHex(strHeadCellColor)%>; background-color: inherit;}
span.spoiler {font-style: normal; font-weight: normal; font-size: <%=ReplaceSizeWithPt(strFooterFontSize)%>; display: block; margin: 0 5%;}
/********************************/
Again, you'll probably have to tweak this to work with your individual forums. I've got a couple functions that translate the forum values for font sizes and colors into something that will validate and work across different browsers.
If there are any questions, ask away!
Edit: Flippin' forum code. I forgot there was a spoiler tag on this forum... I couldn't figure out for the life of me why the text wasn't showing up right in the post. Fixed now.<
Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
Posted
Forum Moderator
AnonJr
Posts: 5768
5768
Thanks. I've got it bookmarked for when I need to point someone to it later on. bigsmile
Actually, now that I thin about it, I'll probably add the [modnote] tag to my forums.<
Posted
Advanced Member
Etymon
Posts: 2396
2396
You guys ... my wife has an art site where some of the gals sometimes post anatomically correct images for reference when working on sculptures, so I think I will add a [COPPA][/COPPA] tag to my forums. This will hide "member-deemed" adult content from children who are also members and also from non-forum members.
This will not only be for images but also for adult language and humor. I'll try to figure a way to have the members include this tag when posting as well as educate them on the benefits of becoming more "child-friendly" when making posts.
I'd like to see the SmileManager Plus for Snitz 3.4 (http://forum.snitz.com/forum/topic.asp?ARCHIVE=true&TOPIC_ID=33807) be adapted to custom posting tags like we are talking about in this topic. I'm not available for it at the moment but would be willing to give it a go later as I have time. Anyone interested in helping to see if it is feasible or even possible? <
Posted
Senior Member
muzishun
Posts: 1079
1079
I like the idea of a COPPA tag, and I don't really think it would be that hard. The only thing that I see becoming a problem is when you start to have too many tags and your users can't figure out which way is up. I've been thinking about reworking the way post.asp is layed out as well as redoing the forum code tutorial page to address some of these issues as I add mods to my forum.<
Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
Posted
Starting Member
Icaro
Posts: 3
3
Wow!!!smile... thanks a lot muzishun, i've been trying to implement that reference code but it seems to work only with the response.write line and not on the post itself but with your help, it should be a lot more easier.
Maybe you should publish this on www.snitzbitz.com

Thanks!...<
You Must enter a message