PDA

View Full Version : How do I hide the code box from guests?


HM666
01-15-2015, 05:51 AM
Hello how do I make it where you HAVE to be registered in order to view the html, php, quote & code boxes like it is here on vb.org? Is there a setting i can set or a mod out there already?

MarkFL
01-15-2015, 06:29 AM
One way would be to use a vb conditional in the respective templates. For example in the template "bbcode_code" replace:

{vb:raw code}

with:

<vb:if condition="$show['guest']">You must be registered and logged in to view code contents.<vb:else />{vb:raw code}</vb:if>

edit: I now realize you perhaps want to hide the entire boxes, rather than the content. If so then wrap all of the HTML in the templates with:

<vb:if condition="$show['member']">Pre-existing template HTML in here</vb:if>

HM666
01-15-2015, 08:06 AM
Yeah gotcha will give that a try later on after some sleep :)

--------------- Added 1421380866 at 1421380866 ---------------

Hmmmmmm did not work. It shows this message to everyone not just guests. And there was one that it did not work on at all. One thread/post it worked too well and will not show it to anyone and another thread/post ir did not do anything at all. :( Here's my code for the bbcode_code template please see if I missed something.

<div class="code_box_wrapper MHB_wrappers">
<div class="code_box_description">{vb:rawphrase code}:</div>
<div class="code_box"><pre id="code_select" class="code_box_text" ondblclick="selectText(this.id)" title="Double-Click To Select All Text."><vb:if condition="$show['guest']">You must be <a href="signup.php">registered</a> and logged in to view code contents.<vb:else />{vb:raw code}</vb:if></pre></div>
</div>
<script type="text/javascript">
var newid = GetNewId("code_select");
var el = document.getElementById(newid).parentNode;
el.style.maxHeight = code_height + 'px';
maxMinButton(newid,code_height,0);
</script>

HM666
02-29-2016, 10:25 AM
Revisiting this, I have noticed that on the CMS I have a problem. The code shows fine elsewhere but on the CMS the "CODE:" part is missing.

The code for my code box is...

<div class="code_box_wrapper MHB_wrappers">
<div class="code_box_description">{vb:rawphrase code}:</div>
<div class="code_box"><pre id="code_select" class="code_box_text" ondblclick="selectText(this.id)" title="Double-Click To Select All Text."><vb:if condition="$show['guest']">You must be <a href="signup.php">registered</a> and logged in to view code contents.<vb:else />{vb:raw code}</vb:if></pre></div>
</div>
<script type="text/javascript">
var newid = GetNewId("code_select");
var el = document.getElementById(newid).parentNode;
el.style.maxHeight = code_height + 'px';
maxMinButton(newid,code_height,0);
</script>

Any ideas why this is happening only in the CMS? On the forums, the posts are just fine and there are no problems.

MarkFL
02-29-2016, 11:53 AM
I would guess the CSS might have to be adjusted for the CMS.

HM666
02-29-2016, 06:15 PM
Yeah I tried a few adjustments. Its kinda weird and only happens in a few areas of the CMS I noticed upon more inspection. *SIGH*

MarkFL
02-29-2016, 07:01 PM
If you can post a link to a page where it occurs, I will see if I can figure out a solution. :)

HM666
02-29-2016, 08:54 PM
I would but now it seems to not be doing it. Maybe one of the things I did worked.....eventually LOL.