Welcome to the [HSX] website!

Been Gaming since 2003

Community Driven Site

Gaming, Web Development, and Support

  

 
Main Menu
 
DFG
 Home
 Join our Clan
 [HSX] Roster
 Forums
 News
 Downloads
 News Letter
 Video tutorials
 Supporters
 Uploads
 F.A.Q
· FAQ
· Docs
· Forums FAQ
 [HS] History
 Site Map
 Write a Review
 Image Repo
 WhoIs
 Twitch ID Finder
 Logout
DFG
DFG DFG DFG

 
[HSX] Donations
 
DFG
Donation
This here is a combined total of what we need to keep us going each month.

5 %

Donate

End DateMar 01
Target$100.00
Below Target$95.45
CurrencyUSD

Donators This Month
Feb 04
Wolf
$4.55
DFG
DFG DFG DFG

 
Search our Site
 
DFG DFG
DFG DFG DFG

 
Theme Management
 
DFG
DFG
DFG DFG DFG

 
Survey
 
DFG What is your favorite game to play ATM?

WarThunder
World of Tanks
H1Z1
MechWarrior Online
ARK
WarFace
SWTOR
BattleField serier
COD Series
Diablo
Armored Warfare



Results
Polls

Votes 992
Comments: 0
DFG
DFG DFG DFG

 
Honey Pot
 
DFG
Bots in the pot!
We have [1889] bots stopped!

DFG
DFG DFG DFG

     
DFG
 
Forum Index Members Search Usergroups
Ranks Staff Statistics Forum FAQ
Board Rules Edit your profile Login, Check Messages Log in
 


Search for at

Forum groups causing blocks to show more any once?
Post new topic Reply to topic printer-friendly view List users that have viewed this topic Thank Post Forum Index Nuke Blocks / Modules Support
View previous topic View next topic
PostPosted: Wed Jul 18, 2018 10:11 pm Reply with quote
coRpSE
!!WARNING!!
Long post, don't skim, take time to read or don't read at all.


Here is what I am going to go over in this post, (in order),
  1. Explanation of whats happening and why.
  2. Send you to a video tutorial I did about forum permissions which I do talk about groups in it. (just  note, in the video I don't think i mentioned this, but if you set up groups like I said in there, this wouldn't be really an issue.).
  3. Little rant on how annoyed I am over this, mostly with those that lead me to believe they understood what i was talking about when they actually had no clue what I was talking about.
  4. Message to all that ask for my help.
  5. The code and what to edit
  6. How my code works, and explanation. Video just added.


Have you ran into a situation where you went to add a block onto your site, but you only wanted specific groups to see it, to you went in and set the block to groups only, and you selected a few groups, and after doing that, you find that there is multiple blocks now showing on your home page?

Well, if this has happened to you, and you came to me before and asked about it, then I probably told you to edit your groups to make it easier. I still stand by that. I don't get why a clan would set up something like, Leader, lieutenant, and members, and not put the leaders and lieutenant into the member group. Just say everyone in the clan was in the member group, then just say they got promoted to lieutenant, leave them in the member group, just add them to the lieutenant group. That way is you want something to be shown only to members, all you have to do is set the item to the members and that's it.

I do go over this in my forum permissions video tutorial.
Please login to see this link
Get registered or Log in


Well, I coded a workaround because some people that ask for my help choose to ignore it, or just didn't understand me, and when it effects them, they don't understand why even though they were told about it. I am not mentioning names, but, in the last week, this has popped up 4 times. Yes, that is right, four times. What I find strange is I haven't had anyone ask me about this issue for maybe a year, then I get it four times in 1 week.

Here is essentially what your would see if you run into this problem:
Expand

But from your admin panel it just was there once.
Expand

Well, it comes to light only when trying to set a block only for specific groups to see. Otherwise this goes unseen. If you set up the groups with careful planning knowing that this could happen, its easy to avoid, but, if you had no knowledge of this happening, it is easy to cause this issue with setting of the groups.
Expand

Well, finally I got around to coding a quick fix for this and I will explain my fix and how it works below. You can see the actual diffchecker here:
Check it out here:
Please login to see this link
Get registered or Log in


Here is the code to fix this issue:

Open up your public_html/mainfile.php

Find:

PHP:  [ Select all ]

        if (empty($blockrow[$i]['bkey'])) {
 
           if ( ($view == '0' || $view == '1') ||
 
              ( ($view == '3' AND is_user()) ) ||
 
              $view == '4' AND is_admin()) ||
 
              ( ($view == '2' AND !is_user())) ) {
 
               render_blocks($side$blockrow[$i]);
 
           } else {
 
               if (substr($viewstrlen($view)-1) == '-') {
 
                   $ingroups explode('-'$view);
 
                   if (is_array($ingroups)) {
 
                       foreach ($ingroups as $group) {
 
                           if (isset($userinfo['groups'][($group)])) {
 
                               render_blocks($side$blockrow[$i]);
 
                           }
 
                       }
 
                   }
 
               }
 
           }
 
       }
 
   }
 
   return;

 
Replace with:

PHP:  [ Select all ]

if (empty($blockrow[$i]['bkey'])) {
 
           if ( ($view == '0' || $view == '1') ||
 
              ( ($view == '3' AND is_user()) ) ||
 
              $view == '4' AND is_admin()) ||
 
              ( ($view == '2' AND !is_user())) ) {
 
               render_blocks($side$blockrow[$i]);
 
           } else {
 
               if (substr($viewstrlen($view)-1) == '-') {
 
                   $ingroups explode('-'$view);
 
                   if (is_array($ingroups)) {
                        
$cnt 0;
 
                       foreach ($ingroups as $group) {
 
                           if (isset($userinfo['groups'][($group)])) {
 
                               $cnt++;
                     
         }
                         
 }
                    if (
$cnt != 0){
                    
render_blocks($side$blockrow[$i]);
 
                       }
 
                   }
 
               }
 
           }
 
       }
 
   }
 
   return;

 
Save & Close


Now, you may see that I am having you replace more than the code that is necessary, and that's because I wanted to have you replace a whole section because it less likely that you may mess something up, especially with the count of the closing }'s.

Now, how does this work? Well, its simple. before hand, the code would check to see how many groups were called, and depending on how many time your appeared, would show the block once per group, so if you were in 4 groups, you would see it 4 times. Now, my code still uses the loop they had, but instead, does some simple math..

My code:

PHP:  [ Select all ]

                    if (is_array($ingroups)) {
                        
$cnt 0;
 
                       foreach ($ingroups as $group) {
 
                           if (isset($userinfo['groups'][($group)])) {
 
                               $cnt++;
                     
         }
                         
 }
                    if (
$cnt != 0){
                    
render_blocks($side$blockrow[$i]);
 
                       }
 
                   

 
First thing you will see is $cnt = 0;. What I am doing there is setting a variable that I created to be 0. So, at that point, if I wanted to display that variable using a echo or something, it would just show the number 0. Now, the next line down is the foreach, that is the loop that is taking the array of all the groups and looping thought each one.

The next line down is checking to see if you belong to the group that this block should be shown to. If you do, then the, next line down adds a 1 to the variable I created before that was equal to 0. So, each time the $cnt++; is run though the loop, lets say 3 times, then it added a "1" three times, (0+1+1+1=3).

So, the last part of my code is this:
if ($cnt != 0)
which is saying, it the variable $cnt does NOT equal to 0, then show the block once. So it doesn't matter how may groups you belong in, as long as your count is over 0 to be able to see it, then you will, otherwise, you wont see it.

Simple fix. I know there are other ways that this could have been accomplished, and short of a rewrite of sorts, this was the easiest way. So if your looking at putting this in, then the instructions are above, and exactly how the code works has also been explained.

Here is a video I finally got made:

[Watch this video on YouTube]

Learn more about Comparison Operators:
Please login to see this link
Get registered or Log in


Learn more about Incrementing / Decrementing Operators:
Please login to see this link
Get registered or Log in

Top Dog
Nuke Dev / Coder

Groups Top Dog
Nuke Dev / Coder
Posts 2374
Joined Jan 12, 2012
Status Offline
View user's profile Send coRpSE a private message Visit user's website Find all posts by coRpSE

PostPosted: Thu Jul 26, 2018 1:00 am Reply with quote
SoCo
Yeah, sorry bud about fucking up. You know I am not grat at listening and following instructions. Heck, I'm lucky that my wife has not left me yet. Thanks again for fixing our site again and I will try following instructions a bit better

NOOB!!!

Groups NOOB!!!
Posts 4
Joined Jul 26, 2018
Status Offline
View user's profile Send SoCo a private message Find all posts by SoCo

PostPosted: Thu Jul 26, 2018 1:11 am Reply with quote
coRpSE
It's no problem, The day I wrote this "originally", I was having a bad day, but I also couldn't believe that I had 3 clans that had the same issue, and you and one other I talked to directly and helped on TS. Granted the other one did also just have some internal issues with their clan and there "web" guy.

But like I said to you, if you still don't understand what I am talking about, even after I explain, ask questions. It's the only way you or anyone reading this thread is going to learn. I know for a fact that I am going to run into these issues again, since this is not the first time. I actually banned a member of our clan from doing any work on his PC. He couldn't even install a mod or a game without me being connected. I just got tired of fixing his PC. lol...


 

Top Dog
Nuke Dev / Coder

Groups Top Dog
Nuke Dev / Coder
Posts 2374
Joined Jan 12, 2012
Status Offline
View user's profile Send coRpSE a private message Visit user's website Find all posts by coRpSE

 
PostPosted: Thu Jul 26, 2018 1:18 am Reply with quote
SoCo
Yeah, my bad.

Well, thanks again for what you did for us and keep up what your doing for this community. We need more of you to keep doing this. you know I would help if I knew what I was doing.


 

NOOB!!!

Groups NOOB!!!
Posts 4
Joined Jul 26, 2018
Status Offline
View user's profile Send SoCo a private message Find all posts by SoCo

PostPosted: Thu Jul 26, 2018 12:05 pm Reply with quote
coRpSE
n/p


 

Top Dog
Nuke Dev / Coder

Groups Top Dog
Nuke Dev / Coder
Posts 2374
Joined Jan 12, 2012
Status Offline
View user's profile Send coRpSE a private message Visit user's website Find all posts by coRpSE

Display posts from previous:
Post new topic Reply to topic printer-friendly view List users that have viewed this topic Thank Post All times are UTC - 7 Hours [DST enabled]
Page 1 of 1


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001, 2019 phpBB Group
DFG
DFG DFG DFG
Forums ©
Copyright © HeadShotDomain 2016 By: coRpSE
SimpleBlack V2 By: Killigan
Powered By: Evolution-Xtreme