Widget by usergroup by using a conditional in template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vskylabv
    Senior Member
    • Feb 2009
    • 210
    • 3.8.x

    [CMS] Widget by usergroup by using a conditional in template

    Since no mod exist to make CMS font page widgets by usergroup, I want to add a conditional tag to activate/deactivate widgets entirely depending on their usergroup using a conditional tag by template editing.

    Where can I add this? What code would I do? Which template?
    Last edited by vskylabv; Fri 14 Jan '11, 7:14pm.
    Art of Travel Blogging : The Travel Blogging Community for Beginners and Professionals
  • Lynne
    Former vBulletin Support
    • Oct 2004
    • 26255

    #2
    To find the template to modify, do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code. (Sometimes the template is the one mentioned at the very top of the page source.)

    Once you have the template, add something like:
    HTML Code:
    <vb:if condition="is_member_of($bbuserinfo, x, y, z)">code to only show to usergroups x. y. and z</vb:if>

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to vbulletin.org
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools &lt;- awesome site for html/css help

    Comment

    • vskylabv
      Senior Member
      • Feb 2009
      • 210
      • 3.8.x

      #3
      I've edited vbcms_widget_column and added

      <vb:if condition="$widgets AND is_member_of($bbuserinfo, 10, 6)">
      <vb:each from="widgets" value="widget"><li>{vb:raw widget}</li></vb:each>
      <vb:else>
      <li class="hidden"></li>
      </vb:else>
      </vb:if>

      However it simply clears out the whole content page for anyone outside of those groups.

      I've just learned editing vbcms_widget_sectionnavext_page will remove the contents of the widget area but what I'd like to do is remove the table as well so the content page can be flush and full.
      Last edited by vskylabv; Sat 15 Jan '11, 6:18pm.
      Art of Travel Blogging : The Travel Blogging Community for Beginners and Professionals

      Comment

      • Lynne
        Former vBulletin Support
        • Oct 2004
        • 26255

        #4
        Originally posted by vskylabv
        I've just learned editing vbcms_widget_sectionnavext_page will remove the contents of the widget area but what I'd like to do is remove the table as well so the content page can be flush and full.
        That will not happen unless you modify the CSS for the page. There is probably a div there that is set to be xxx wide. Just because there is no content doesn't mean the div just disappears unless you do something to make it disappear (like modify the CSS).

        Please don't PM or VM me for support - I only help out in the threads.
        vBulletin Manual & vBulletin 4.0 Code Documentation (API)
        Want help modifying your vbulletin forum? Head on over to vbulletin.org
        If I post CSS and you don't know where it goes, throw it into the additional.css template.

        W3Schools &lt;- awesome site for html/css help

        Comment

        • vskylabv
          Senior Member
          • Feb 2009
          • 210
          • 3.8.x

          #5
          Hm, but I'd only want the CSS to disappear if it's a guest.
          Art of Travel Blogging : The Travel Blogging Community for Beginners and Professionals

          Comment

          • Lynne
            Former vBulletin Support
            • Oct 2004
            • 26255

            #6
            You can write CSS to only show, or not show, for guests. You'll need to put it in an actual html template (not one of the .css templates) though or in a plugin.

            Please don't PM or VM me for support - I only help out in the threads.
            vBulletin Manual & vBulletin 4.0 Code Documentation (API)
            Want help modifying your vbulletin forum? Head on over to vbulletin.org
            If I post CSS and you don't know where it goes, throw it into the additional.css template.

            W3Schools &lt;- awesome site for html/css help

            Comment

            • vskylabv
              Senior Member
              • Feb 2009
              • 210
              • 3.8.x

              #7
              I think I need to be walked through a little bit more. I'm sorry. I can't get this to work.

              I tried on vbcms_grid_2
              <div id="doc3" class="yui-tvb-l2">
              <div id="bd">
              <div id="yui-main">
              <div class="yui-b">
              <div class="yui-u yui-panel">
              <ul class="list_no_decoration widget_list" id="widgetlist_column1">$column[1]</ul>
              </div>
              </div>
              </div>
              <vb:if condition="is_member_of($bbuserinfo, 400)">
              <div class="yui-b yui-sidebar">
              <ul class="list_no_decoration widget_list" id="widgetlist_column2">$column[2]</ul>
              </div>
              </vb:if>
              </div>
              </div>

              Gives me a blank page with simply the text $column[2]
              Art of Travel Blogging : The Travel Blogging Community for Beginners and Professionals

              Comment

              • Lynne
                Former vBulletin Support
                • Oct 2004
                • 26255

                #8
                You cannot remove a column from the grid. I said you can write CSS to remove it it (basically set parts to display:none). You need to put the CSS in the main page, like in the headinclude part, and put conditions around it.

                This forum is not really the place to be getting such specific help with modifying your code. If you need more specific help, you really need to post over on vbulletin.org, the modification site.

                Please don't PM or VM me for support - I only help out in the threads.
                vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                Want help modifying your vbulletin forum? Head on over to vbulletin.org
                If I post CSS and you don't know where it goes, throw it into the additional.css template.

                W3Schools &lt;- awesome site for html/css help

                Comment

                • malmazan
                  Senior Member
                  • Jan 2006
                  • 974
                  • 4.2.X

                  #9
                  You would add a conditional on the template for thos. The name of the template is under "configure" for every widget.

                  If you need different conditions for the same widget type, change the template name in "configure" (such as "vbcms_widget_recentthreads_page_registeredusers"), create a new template with that same name, copy the contents of the original template (in this case, "vbcms_widget_recentthreads_page") to the new one (in this case, "vbcms_widget_recentthreads_page_registeredusers") and add the conditionals to it
                  Vote for these issues:

                  Comment

                  Related Topics

                  Collapse

                  Working...