PDA

View Full Version : Display a forum block only to certain usergroups


pjkcards
08-20-2011, 01:06 AM
I'm having a hard time doing this.

I've used an HTML content type with this, and no luck:

<vb:if condition="is_member_of($bbuserinfo, 1, 2, 3, 4, 15, 17)">
text
</vb:if>


And I've also tried this with no luck (want to display to everyone but 16):

<vb:if condition="!is_member_of($bbuserinfo, 16)">
text
</vb:if>


Can I modify permissions anywhere else for forum blocks since this isn't working for some reason? Thanks.

kh99
08-20-2011, 12:23 PM
You can't use <vb:if... in html, only in a template. You could put your html in a template, make your widget PHP Direct Execution and use:

$templater = vB_Template::create('my_template');
$output = $templater->render();


or you could use this code without making a template

if (!is_member_of(vB::$vbulletin->userinfo, 16))
{
$output = "<div> This is my html
blah blah
";
}

or you could put your html in a template and

pjkcards
08-20-2011, 06:18 PM
You can't use <vb:if... in html, only in a template. You could put your html in a template, make your widget PHP Direct Execution and use:

$templater = vB_Template::create('my_template');
$output = $templater->render();


or you could use this code without making a template

if (!is_member_of(vB::$vbulletin->userinfo, 16))
{
$output = "<div> This is my html
blah blah
";
}

or you could put your html in a template and
Edit: I got it to work after playing with it a bit. It blocks all the content within the block, but it doesn't hide the block itself. How do I have it hide the block itself?

Thanks!

kh99
08-20-2011, 06:22 PM
Oops...yeah, I'm not sure what problem you're having exactly, but I just realized that it won't work like that because of the caching. I'm not sure if there's a way to write a PHP type block that doesn't cache. I'll look in to it...

--------------- Added 1313869007 at 1313869007 ---------------

OK - should have thought of this before, sorry. Anyway, go back to using a static html widget. Copy the contents of the template vbcms_widget_static_page and create a new widget with the same contents but surround it with the 'if' tags, like


<vb:if condition="!is_member_of($bbuserinfo, 16)">
<div class="cms_widget">
<div class="block">
<div class="cms_widget_header">
<h3><img src="{vb:stylevar imgdir_siteicons}/html.png" alt="" /> {vb:raw widget_title}</h3>
</div>
<div class="cms_widget_content_restore_widget_content">
{vb:raw static_html}
</div>
</div>
</div>
</vb:if>



Save it with some new name, then configure your widget and put that template in as the template name and your html in the html box.

malmazan
11-30-2011, 08:18 PM
Would it be possible to have a Latest Threads forum block where a usergroup was shown latest threads for some forums and another usergroup was shown latest threads for other forums?

kh99
11-30-2011, 09:21 PM
You would need code of some sort to make that work. I just reread this thread and realized that the original post asked about forum blocks and I was thinking widgets for some reason, so pjkcards, if you read this, sorry about that.