Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: MarkJ - elokuu 09, 2014, 06:50:08 AP

Otsikko: Removing Blocks From Groups
Kirjoitti: MarkJ - elokuu 09, 2014, 06:50:08 AP
I have setup an Adults Group to display just certain boards.  The right side of the site has recent post and topic blocks that alter to suit - in that they don't display other stuff only stuff related to the Adult group - great; trouble is I have other blocks for Arcade - Top Posters - Random Member of the day - and these look out of place.  Is there code I can run to remove these when viewing the Adults Group?  I can see how to do this on the recent posts and topics as the exclude boards can be altered but not on these blocks.
Otsikko: Re: Removing Blocks From Groups
Kirjoitti: ARG01 - elokuu 09, 2014, 01:11:04 IP
Sounds like you are using a portal. Yes?
Otsikko: Re: Removing Blocks From Groups
Kirjoitti: MarkJ - elokuu 09, 2014, 01:33:01 IP
Lainaus käyttäjältä: SimpMode - elokuu 09, 2014, 01:11:04 IP
Sounds like you are using a portal. Yes?

Not really but I have incorporated bits of code from the portal to achieve the right side column, other than that I have added blocks by using the SSI.php file.

http://toffs.club/index.php
Otsikko: Re: Removing Blocks From Groups
Kirjoitti: ARG01 - elokuu 09, 2014, 01:47:14 IP
I don't know what you have in the SSI.php file but cant you just remove those blocks from the code? Or maybe someone with more SSI.php knowledge than I possess could assist you.  ;)
Otsikko: Re: Removing Blocks From Groups
Kirjoitti: MarkJ - elokuu 09, 2014, 02:22:29 IP
Lainaus käyttäjältä: SimpMode - elokuu 09, 2014, 01:47:14 IP
I don't know what you have in the SSI.php file but cant you just remove those blocks from the code? Or maybe someone with more SSI.php knowledge than I possess could assist you. <$1alt="" title="" onresizestart="return false;" id="smiley__$2" style="padding: 0 3px 0 3px;" />

What is happening is I have made it possible to view ADULT Boards on their own - Groups and Permissions etc - so when users are only viewing the ADULT Boards they are still using the same side column.  On the recent posts and topics I have added to the exclude and include arrays, along with different SSI.php files to display different content when a user is either viewing DAILY Boards - DAILY plus ADULT and also just ADULT on it's own..  The arcade block - top poster block and random member of the day blocks though haven't any control so they display at all times, which is messing up my ADULT Boards display as the right side panel is way overlong.  If I could work out how to apply the same control to the problem blocks that exist on the recent posts / topic blocks I could solve it.
Otsikko: Re: Removing Blocks From Groups
Kirjoitti: MarkJ - elokuu 09, 2014, 07:58:09 IP
I had to fall back on my own knowledge of php as I'm not familiar with the forum code yet.

For anyone wanting to do the same - hide blocks (or anything for that matter) then perhaps this code will come  in handy.

I placed the blocks I didn't want to show when a member was logged into a particular group - in this case group 11 only (ADULT) inside a display none div like this ...

// Code To Hide Blocks When User Views ADULT Board Only - Start Display None Div

if (!empty($context['user']['id']))

$member_id = $context['user']['id'];

$sql="SELECT id_group,additional_groups FROM `smf_members` where id_member = '$member_id' ";
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))  {

$id_group = $row['id_group'];
$additional_groups = $row['additional_groups'];
}

if ($id_group=='11' && $additional_groups=='') {
echo '<div style="display:none;">';
}

// End Of Display None Div

echo '<h3 class="catbg" style="padding-left: 5px; margin-top: 5px;">Top Topics</h3>';
echo '';ssi_topTopicsViews($num_recent = 6); echo '';

echo '<h3 class="catbg" style="padding-left: 5px; margin-top: 5px;">Top Boards</h3>';
echo '';ssi_topBoards($num_recent = 4); echo '';

echo '<h3 class="catbg" style="padding-left: 5px; margin-top: 5px;">Top Posters</h3>';
echo '';ssi_topPoster($num_recent = 4); echo '';

echo '<h3 class="catbg" style="padding-left: 5px; margin-top: 5px;">Arcade</h3>';
echo '<table border="0" class="ssi_table" style="width: 245px; font-size: 90%; border: 1px solid #DDDDDD; background: #F6F6F6; padding: 10px;" cellspacing="0px"><tr><td>';
echo '';ssi_arcade(); echo '';
        echo '</td></tr></table>';

echo '<h3 class="catbg" style="padding-left: 5px; margin-top: 5px;">Member Of The Day!</h3>';
echo '';ssi_randomMember('day'); echo '';

// Code To Hide Blocks When User Views ADULT Board Only - Closing Div

if (!empty($context['user']['id']))

$member_id = $context['user']['id'];

$sql="SELECT id_group,additional_groups FROM `smf_members` where id_member = '$member_id' ";
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))  {

$id_group = $row['id_group'];
$additional_groups = $row['additional_groups'];
}

if ($id_group=='11' && $additional_groups=='') {
echo '</div>';
}

// End Of Code - Closing Div

As you can see when a member chooses just the ADULT Board in groups (additional group ID of 11) then the above code matches the id_group and additional_group ids.  If they are a match - 11 & 'empty' - then the div is created and the blocks in-between the opening and closing divs disappear from view  :) .
Otsikko: Re: Removing Blocks From Groups
Kirjoitti: margarett - elokuu 10, 2014, 12:06:57 AP
Just some suggestions:
$sql="SELECT * FROM `smf_members` where real_name = '$member_name' ";
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))  {

-you should use $smcFunc
-you should not SELECT *, fetch only the fields you require ;)
-you should use user ID in the WHERE clause, instead of name ;)
Otsikko: Re: Removing Blocks From Groups
Kirjoitti: MarkJ - elokuu 10, 2014, 01:33:00 AP
Lainaus käyttäjältä: margarett - elokuu 10, 2014, 12:06:57 AP
Just some suggestions:
$sql="SELECT * FROM `smf_members` where real_name = '$member_name' ";
$result = mysql_query($sql);

while($row = mysql_fetch_array($result))  {

-you should use $smcFunc
-you should not SELECT *, fetch only the fields you require  :)
-you should use user ID in the WHERE clause, instead of name  :)

Thanks - will alter the code.