IMPORTANT

FM Design is in read-only mode, please click here for more information.

Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Fri 08 Jun 2018, 11:02

» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28

» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15

» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11

» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24

» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58

» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50

» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22

» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12

» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10

» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51

» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11

» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19

» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34

» Numbering of messages in the topic
by SLGray Mon 04 Dec 2017, 22:40

Recent Tutorials
Top posting users this month

Who is online?
In total there are 10 users online :: 0 Registered, 0 Hidden and 10 Guests :: 2 Bots

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

Widget : Groups

View previous topic View next topic Go down

avatar
Ange Tuteur
Administrator
Gender : Male
Age : 22
Posts : 4733
Points : 9872
Reputation : 2366
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Mon 25 Apr 2016, 14:32

The groups widget allows you to see all the groups you belong to, as well as groups that you can join. It's handy if you don't feel like going to the groups page. Wink


Click to view demo

Notes :
1. The widget contains two sections ;
1.1 Group Memberships
- Shows the groups you currently belong to.
- This section is hidden if you don't belong to a group

1.2 Join a Group
- Shows the groups that you can join.
- This section is hidden if there are no groups to join

2. Group data is cached for 1 hour, so you wont see changes immediately unless you clear your cache.


Installation :

To install this widget go to Admin Panel > Modules > Forum widgets management and create a new widget with the following settings.

Titles : Groups
Use a table type : Your choice
Source :
Code:
<style type="text/css">#fa_group_panel { font-size:12px; font-family:arial, sans-serif; }
#fa_group_panel > div { margin:10px 3px; }
#fa_group_panel select { width:100%; }
#fa_group_memberships a { display:block; }
#fa_group_join dl { text-align:center; }
#fa_group_join dt { display:none; }
#fa_group_join dd { margin:0; }
.fa_group_title { font-weight:bold; color:#369; border-bottom:1px solid #369; padding-bottom:3px; margin:3px 0; }
.fa_group_button { color:#69C; background:transparent; border:1px solid #69C; border-radius:3px; padding:3px 6px; width:100%; }
.fa_group_button:hover { color:#FFF; background:#69C; }</style>

<div id="fa_group_panel">
  <div id="fa_group_status">
    <noscript><span style="color:#F00">Error : Please enable JavaScript to use this widget.</span></noscript>
  </div>
  <div id="fa_group_memberships"></div>
  <div id="fa_group_join"></div>
</div>

<script type="text/javascript">
(function() {
  var cache_time = 1*60*60*1000,

      lang = {
              join : 'Join a Group',
        memberships : 'Group Memberships',
            loading : 'Fetching group data...',
              error : 'There appears to be no groups to join or view.'
      },

      panel = document.getElementById('fa_group_panel'),
      status = document.getElementById('fa_group_status'),
      storage = window.localStorage;

  /* check if group data is already storage */
  if (storage && storage['faGroupData_u' + _userdata.user_id] && storage['faGroupData_exp_u' + _userdata.user_id] > +new Date - cache_time) {
    panel.innerHTML = storage['faGroupData_u' + _userdata.user_id];
  } else {
    status.innerHTML = lang.loading;

    /* get group data via AJAX */
    jQuery.get('/groups?change_version=prosilver', function(d) {
      var node = [
            document.getElementById('fa_group_memberships'),
            document.getElementById('fa_group_join')
          ];

          frag = document.createDocumentFragment(),

          join = jQuery('form:has(select[name="g"])', d)[0],
          membership = jQuery('.noList a[href^="/g"]', d),
          i = 0,
          j = membership.length;

      status.innerHTML = '';

      /* if the member has group memberships */
      if (j) {
        node[0].innerHTML = '<div class="fa_group_title">' + lang.memberships + '</div>';

        for (; i < j; i++) {
          membership[i].href = membership[i].href.replace(/\?change_version=prosilver/, '');
          frag.appendChild(membership[i]);
        }

        node[0].appendChild(frag);
      }

      /* if the member has groups left to join */
      if (join) {
        join.action = '/groups';
        jQuery('input[name="tt"]', join).remove();
        jQuery('input[type="submit"]', join).attr('class', 'fa_group_button');
        node[1].innerHTML = '<div class="fa_group_title">' + lang.join + '</div>';
        node[1].appendChild(join);
      }

      if (!j && !join) {
        status.innerHTML = lang.error;
      }

      if (storage) {
        storage['faGroupData_u' + _userdata.user_id] = panel.innerHTML;
        storage['faGroupData_exp_u' + _userdata.user_id] = +new Date;
      }
    });
  }
}());
</script>

Save the widget when you're finished and you'll be ready to add it to one of the columns on your forum and view your groups ! Cool

See the section below, if you want to make modifications to this widget. Wink


Modifications

Below are the modifications that can be made to this widget.


1. Cache Time
In the widget there should be a variable called cache_time, this controls the time the group data is cached. Edit this value if you want the cache time to be shorter or longer :
Code:
  var cache_time = 1*60*60*1000, // 1 hour


2. Language
If you want to translate or change any of the texts find the lang object in the widget :
Code:
      lang = {
              join : 'Join a Group',
        memberships : 'Group Memberships',
            loading : 'Fetching group data...',
              error : 'There appears to be no groups to join or view.'
      },
Feel free to change the texts to whatever you want. Wink


3. The Theme
You'll notice that the colors of the headers and buttons will be different from your forum. If you want to change these colors feel free to edit the stylesheet at the top of this widget. Smile
Code:
<style type="text/css">#fa_group_panel { font-size:12px; font-family:arial, sans-serif; }
#fa_group_panel > div { margin:10px 3px; }
#fa_group_panel select { width:100%; }
#fa_group_memberships a { display:block; }
#fa_group_join dl { text-align:center; }
#fa_group_join dt { display:none; }
#fa_group_join dd { margin:0; }
.fa_group_title { font-weight:bold; color:#369; border-bottom:1px solid #369; padding-bottom:3px; margin:3px 0; }
.fa_group_button { color:#69C; background:transparent; border:1px solid #69C; border-radius:3px; padding:3px 6px; width:100%; }
.fa_group_button:hover { color:#FFF; background:#69C; }</style>


That's all the modifications ! If you have any questions, comments, or find a bug feel free to leave a reply below. Enjoy ! Super hero


Notice
Tutorial written by Ange Tuteur.
Special thanks to the Beta Testers for testing this plugin.
Reproduction not permitted without consent from the author.

--------

Ange Tuteur
Tips and TricksContact Me

avatar
Guest
Guest

PostGuest on Sun 01 May 2016, 05:33

Is it possible not to make hidden usergroups appear in the group memberships?
avatar
Ange Tuteur
Administrator
Gender : Male
Age : 22
Posts : 4733
Points : 9872
Reputation : 2366
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Mon 02 May 2016, 06:47

Not really. If the group appears here it'll appear in the widget.

--------

Ange Tuteur
Tips and TricksContact Me

Sponsored content

PostSponsored content

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum