Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1145
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Hiding blocks from admin

Started by Mick., January 03, 2010, 01:11:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mick.

Is there a way to hide blocks from admin but able to show to members and guests?

Nathaniel

#1
At the moment no.

But with the edit below it should be possible.

Code ("Find (Sources/Subs-Portal.php)") Select
if (allowedTo('sp_admin'))
return true;


Code ("Replace") Select
global $context;
if (allowedTo('sp_admin'))
{
if ($type == 'block' && $context['current_action'] != 'admin' && $id == 1)
return false;
else
return true;
}


Change the '1' to the id of the block that you don't want admin to be able to see. You can find the id of a block from the url when you are editing it.

Edit: Updated so that you can still edit the block in the admin panel.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Mick.

Wow!,.....  excellent. Thank you.

You have no idea how many times ive been wanting to do this.   I like to show some blocks to guests only but not members. ....but i saw them too and that bugged me.


Say,........ what if i wanted to add another block?   add another number?

like this?  if ($type == 'block' && $id == 1,23,22,45 )??

Nathaniel

No, that is not valid PHP syntax. Use the code below:
if ($type == 'block' && in_array($id, array(1,23,22,45)))
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Mick.

Thank you.

Do you mind splittin' this topic to "feature requests"?   I think it may be useful as if i make a block with a welcome message to guests only, i shouldnt see it if dont want to and obviously regular members wont see it either.   Maybe adding this feature to pages as well?

Thanx again,
Mick.

Nathaniel

This is already a feature request that has been added to the ProjectTracker: http://simpleportal.net/index.php?issue=275

Marking as solved.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Mick.

It gives a fatal error when viewing the block in admin..

Fatal error: Function name must be a string in /home/******/public_html/Sources/PortalAdminBlocks.php on line 243

ccbtimewiz

if (($type == 'block') && (in_array($id, array(1, 23, 22, 45))) || ((!empty($_GET['action'])) && ($_GET['action'] !== 'admin')))

Try that instead.

Mick.

Quote from: ccbtimewiz on January 10, 2010, 07:51:11 PM
if (($type == 'block') && (in_array($id, array(1, 23, 22, 45))) || ((!empty($_GET['action'])) && ($_GET['action'] !== 'admin')))

Try that instead.

That code turns OFF all the blocks from the forums :(

Nathaniel

Try the code below:
if ($type == 'block' && in_array($id, array(1, 23, 22, 45)) && !(!empty($_GET['action'] && $_GET['action'] == 'admin'))
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Mick.

I get a parse error:


Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ')' in /home/*******/public_html/Sources/Subs-Portal.php on line 595

ShadowMaster


if ($type == 'block' && in_array($id, array(1, 23, 22, 45)) && !(!empty($_GET['action'] && $_GET['action'] == 'admin')))


Missing a closing brace.

Mick.

I get same error.



Im using the code in Reply #3 in which it works good but i cannot see the blocks in admin to edit.   The only way i see them if revert the code to its original state.

Nathaniel

Apologies for the wait on this issue, try the code below:

if ($type == 'block' && in_array($id, array(1, 23, 22, 45)) && !(!empty($_GET['action']) && $_GET['action'] == 'admin'))
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Mick.

Quote from: Nathaniel on February 03, 2010, 06:49:42 PM
Apologies for the wait on this issue, try the code below:

if ($type == 'block' && in_array($id, array(1, 23, 22, 45)) && !(!empty($_GET['action']) && $_GET['action'] == 'admin'))

Excellent!   This worked.

Nothingness

Ok so it works but if I join a group where it had blocks to view...this method still override other permissions.

If it doesn't make sense here's the thread: http://simpleportal.net/index.php?topic=6109.msg35792#msg35792

QuoteEdit: Updated so that you can still edit the block in the admin panel.
I don't see the option to edit if in the blocks on the admin panel...


"Do you wallow in self-pity, or do you learn to use the gifts God gave you and command fear and respect, and defend against those who would do us harm"

Sudhakar

Is this feature available on 2.4
- Thanks & Regards,
Sudhakar, IT Acumens