Announcement

Collapse
No announcement yet.

Widget permissions?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Widget permissions?

    How do you set viewing permissions for widgets?
    I want to restrict certain widgets to members only.

    TiA,
    Bryan

  • #2
    There is no inherit Widget permissions in the system. However you can assign custom templates to individual widgets. Within those custom templates, you can surround the HTML code in a conditional that checks the usergroup. For example:

    HTML Code:
    <vb:if conditional="is_member_of($bbuserinfo, X,Y,Z)">
    ... widget code here...
    </vb:if>
    If they aren't in the usergroups that are represented by X, Y, and Z then the code will be empty and nothing will be shown.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      Thanks, Wayne.
      That's what I thought, and had tried, but it doesn't seem to work.
      With that code in place, I can log out, and the widget is still visible.
      Bryan

      Comment


      • #4
        Originally posted by Spillage View Post
        Thanks, Wayne.
        That's what I thought, and had tried, but it doesn't seem to work.
        With that code in place, I can log out, and the widget is still visible.
        Would have to see the code you're using and the settings for your widget.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API - Full / Mobile
        Vote for your favorite feature requests and the bugs you want to see fixed.

        Comment


        • #5
          I'm using a Static HTML widget.
          It contains;
          Code:
          <vb:if conditional="is_member_of($bbuserinfo, 2,5,6,7,12,13)">
          <script type="text/javascript" src="http://ji.revolvermaps.com/r.js"></script><script type="text/javascript">rm_f1st('0','212','true','false','000000','8mg13fu8x4l','true','ff0000');</script><noscript><applet codebase="http://ri.revolvermaps.com/j" code="core.RE" width="212" height="212" archive="g.jar"><param name="cabbase" value="g.cab" /><param name="r" value="true" /><param name="n" value="false" /><param name="i" value="8mg13fu8x4l" /><param name="m" value="0" /><param name="s" value="212" /><param name="c" value="ff0000" /><param name="v" value="true" /><param name="b" value="000000" /><param name="rfc" value="true" /></applet></noscript>
          </vb:if>
          Bryan

          Comment


          • #6
            Originally posted by Spillage View Post
            I'm using a Static HTML widget.
            It contains;
            Code:
            <vb:if conditional="is_member_of($bbuserinfo, 2,5,6,7,12,13)">
            <script type="text/javascript" src="http://ji.revolvermaps.com/r.js"></script><script type="text/javascript">rm_f1st('0','212','true','false','000000','8mg13fu8x4l','true','ff0000');</script><noscript><applet codebase="http://ri.revolvermaps.com/j" code="core.RE" width="212" height="212" archive="g.jar"><param name="cabbase" value="g.cab" /><param name="r" value="true" /><param name="n" value="false" /><param name="i" value="8mg13fu8x4l" /><param name="m" value="0" /><param name="s" value="212" /><param name="c" value="ff0000" /><param name="v" value="true" /><param name="b" value="000000" /><param name="rfc" value="true" /></applet></noscript>
            </vb:if>
            You can't use conditionals in the content of the widget. You need to use a custom template.

            So at the bottom of your widget it should say:
            Template Name - vbcms_widget_static_page

            So looking at that template in the style manager you get this code:
            HTML Code:
            <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 widget_content">
                    {vb:raw static_html}
                    </div>
                </div>
            </div>
            So you would copy this code and select "Add New Template" from the Style Manager dropdown.

            In this new template you're going to give it a name. Say something like: vbcms_widget_static_page_custom1

            Then your code would be:
            HTML Code:
            <vb:if conditional="is_member_of($bbuserinfo, 2,5,6,7,12,13)">
            <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 widget_content">
                    {vb:raw static_html}
                    </div>
                </div>
            </div>
            </vb:if>
            So now in your widget, the code you would enter would be this:
            HTML Code:
            <script type="text/javascript" src="http://ji.revolvermaps.com/r.js"></script><script type="text/javascript">rm_f1st('0','212','true','false','000000','8mg13fu8x4l','true','ff0000');</script><noscript><applet codebase="http://ri.revolvermaps.com/j" code="core.RE" width="212" height="212" archive="g.jar"><param name="cabbase" value="g.cab" /><param name="r" value="true" /><param name="n" value="false" /><param name="i" value="8mg13fu8x4l" /><param name="m" value="0" /><param name="s" value="212" /><param name="c" value="ff0000" /><param name="v" value="true" /><param name="b" value="000000" /><param name="rfc" value="true" /></applet></noscript>
            And you would set the template name to: vbcms_widget_static_page_custom1
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API - Full / Mobile
            Vote for your favorite feature requests and the bugs you want to see fixed.

            Comment


            • #7
              Arrrh, I see.

              When saving the template, I get the following error;
              The following error occurred when attempting to evaluate this template:

              Parse error: syntax error, unexpected ')' in /var/www/vhosts/nscale.net/httpdocs/forums/includes/adminfunctions_template.php(5217) : eval()'d code on line 1

              This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
              Why would the ")" be unexpected on line #1?
              Bryan

              Comment


              • #8
                Sorry.. Change conditional to condition.

                HTML Code:
                <vb:if condition="is_member_of($bbuserinfo, 2,5,6,7,12,13)">
                <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 widget_content">
                        {vb:raw static_html}
                        </div>
                    </div>
                </div>
                </vb:if>
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud demonstration site.
                vBulletin 5 API - Full / Mobile
                Vote for your favorite feature requests and the bugs you want to see fixed.

                Comment


                • #9
                  That did it.

                  Thank you for your assistance.
                  Your time is greatly appreciated.

                  All the best for the festive season.
                  Bryan

                  Comment

                  widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                  Working...
                  X