Simple Machines Community Forum

Archived Boards and Threads... => Archived Boards => SMF Feedback and Discussion => Topic started by: robbinsnike on November 23, 2009, 06:51:16 PM

Title: How Can I Hide Info Center From MEMBERS?
Post by: robbinsnike on November 23, 2009, 06:51:16 PM
I tried the Hide Info Center package but it only hid the info center for guests. How can I hide the info center completely from guests AND registered members?

I don't want anyone (besides me) to be able to access or see the info center.

How can I do this?

Thanks!
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on November 23, 2009, 07:03:35 PM
What version of SMF and what theme?

It's different depending on what you're using.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: robbinsnike on November 23, 2009, 08:31:02 PM
Thanks for the reply, sorry about that.

The version I am using is 1.1.10 and the theme is SMF Default Theme Core. I haven't tried any other themes yet.

Thanks.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on November 23, 2009, 08:33:14 PM
Who would it be visible to? Guests? Admins? Anyone?
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Chair on November 23, 2009, 11:39:46 PM
It normally is visible by everyone, but my guess is robbinsnike wants it viewed by Admins only.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on November 23, 2009, 11:45:04 PM
Probably, but I need him to clarify since it changes how I write the code.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on November 23, 2009, 11:46:29 PM
If you want it to be visible to only Admins, wrap the following context around the info center.

if ($context['user']['is_logged'] && ['user']['group_id'] == 1){ INFO CENTER }
That should be the proper context, not had to use something like that for quite a while now.

Labradoodle-360
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on November 23, 2009, 11:49:55 PM
if($context['user']['is_admin']) would be better.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on November 23, 2009, 11:54:50 PM
Arantor - haha, very true. Got used to adding if global mod, etc. forgot about the context is_admin.

That's the better way to go definitely.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on November 23, 2009, 11:56:18 PM
Don't forget that checking group_id is only good for their primary group.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on November 23, 2009, 11:59:38 PM
Correct ;)
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: robbinsnike on November 24, 2009, 12:13:01 AM
Yes, I would want it to be visible only to me/admin, no other users or guests.

Thanks everyone, this seems like a great community!
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: robbinsnike on November 24, 2009, 12:17:03 AM
Sorry, I am really new at this...

What file do I put this in and where exactly in the file do I put it? "if($context['user']['is_admin'])"

And is that all I need to put?

Thanks!
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on November 24, 2009, 12:41:55 AM
No, I was being slightly flippant, expanding upon what Labradoodle had put.

Themes/default/BoardIndex.template.php
Code (find) Select
// Here's where the "Info Center" starts...

Code (before that, add) Select
if($context['user']['is_admin']) {

Just need to make sure that { is ended though, so also...

Code (find) Select
echo '
</table>
</div>
</div>';
}


Code (replace) Select
echo '
</table>
</div>
</div>';
}
}
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: robbinsnike on November 24, 2009, 01:17:40 AM
Thanks very much, worked perfect!
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on November 24, 2009, 01:18:33 AM
Good to know! Please consider using the Mark Topic Solved link to flag this topic is all done :)
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 09, 2009, 01:35:02 PM
Hi, I've tried to change the code as described above, BUT in the default theme and there it doesn't work. What should I change to make this work on the default theme as well ?

Thanks !!
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 01:54:49 PM
Same code should work.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 01:56:11 PM
Are you running 1.1.11?
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 09, 2009, 02:04:38 PM
Running 2.0 RC2
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 02:18:18 PM
That would be why. Hold on please
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 02:23:45 PM
./Themes/default/Boardindex.template.php

Find:

// Here's where the "Info Center" starts...


Add Before:

if($context['user']['is_admin']) {


Find:

echo '
</div>
</div></div>


Replace with:

echo '
</div>
</div></div>';
}
echo '

That should work for you.

Labradoodle-360
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 02:26:57 PM
Sorry, left out the bottom. Ignore the second edit and do this edit in ./Themes/default/Boardindex.template.php as well as the first:

Find:

echo '
<span class="lowerframe"><span></span></span>';


Add After:

}
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 09, 2009, 02:50:46 PM
Works great! Thank you so much !!  ;D
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 09, 2009, 02:55:45 PM
I've just noticed the bottom of the board is separated from the main part after applying the code, is it possible to fix this somehow?

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg215.imageshack.us%2Fimg215%2F5084%2F55283981.png&hash=4d881cc619a0e134840e7fc937771f87d2e6c315)
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 03:23:29 PM
Can you screenshot the whole page please?
Quote from: JasonDD on December 09, 2009, 02:55:45 PM
I've just noticed the bottom of the board is separated from the main part after applying the code, is it possible to fix this somehow?

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg215.imageshack.us%2Fimg215%2F5084%2F55283981.png&hash=4d881cc619a0e134840e7fc937771f87d2e6c315)
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 09, 2009, 04:22:03 PM
Sure

http://img26.imageshack.us/img26/4882/62867031.png

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg26.imageshack.us%2Fimg26%2F4882%2F62867031.png&hash=517d2aca80c52e777f93f72ae5709b82164e6bc5)
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 04:32:06 PM
I just tested the edits, again with SMF 2.0 RC2 and it works.

Just make sure you follow my second post for the second edit...here are the proper edits again:

./Themes/default/BoardIndex.template.php

Find: // Here's where the "Info Center" starts...
Add Before: if ($context['user']['is_admin']){

Find: // Info center collapse object.
Add Before }
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on December 09, 2009, 05:05:27 PM
Can I make a simpler suggestion to all that?

In 2.0's BoardIndex.template.php, the info_center is a separate template entirely. Drop the call to it and add a div with appropriate styling in its place.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 05:13:26 PM
I would think adding one line and one character to close the one line is more simple.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on December 09, 2009, 05:16:50 PM
I'd put the if in front of the call to template_info_center then fix the layout issues is simpler, since your method won't always do it correctly, but hey, what do I know.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 05:18:46 PM
I just updated the edits for 2.0, following your edits from 1.1 earlier in this thread.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on December 09, 2009, 05:21:26 PM
And the layout is often still broken as a result because the divs that handle the edge are not covered - as indicated earlier.

/me would point out he already published a mod somewhere in Coding Discussion to deal with this in 2.0 RC1.2 and didn't realise a 2.0 RC2 version for just this reason.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 09, 2009, 05:27:12 PM
to Labradoodle-360

I followed your second post as well, unfortunately with no luck though. I even copied a fresh Boardindex file and edited it but that didn't solve it either  :-\

Quote from: Arantor on December 09, 2009, 05:16:50 PM
I'd put the if in front of the call to template_info_center then fix the layout issues is simpler, since your method won't always do it correctly, but hey, what do I know.

Could you please tell me Arantor how to do that ?

Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 05:29:06 PM
Simply find:function template_info_center()
{


Add Before:if ($context['user']['is_admin']){

Find:}
?>

Add Before:}

Labradoodle-360
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on December 09, 2009, 05:31:21 PM
NO. That will BREAK your index.template.php file.

Code (find) Select
template_info_center();

Code (add before it) Select
if ($context['user']['is_admin'])

As for fixing up the template as mentioned earlier, haven't done that in a while, not sure off hand how to do it as I don't have a copy of RC2 handy to try it on.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 05:32:36 PM
What is the real difference? ???
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Arantor on December 09, 2009, 05:35:23 PM
Yours stops the function being declared meaning that when it is called in template_main, PHP throws an undefined function error for non admins. Mine stops it being called - but it's still declared.

Try both - as an admin and non admin user.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 09, 2009, 05:52:00 PM
Thanks guys,

I tried one more option - what Labradoodle-360 suggested in the first post - without the edit in the second post. It actually worked so that the board is not separated, although I'm not sure if it displays correctly (There seems to be more white space between those frames). Take a look :

http://img46.imageshack.us/img46/9549/92416762.png

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg46.imageshack.us%2Fimg46%2F9549%2F92416762.png&hash=6fe0d90d5365a9705a90c2aafa004d43280350c8)
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 06:48:56 PM
It isn't, exactly what I said in my next post. I left out the bottom slice spans. Take a look at the spans right below where you add } to.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 09, 2009, 06:49:34 PM
Also, I'd definitely take into consideration what Arantor said about where I added the edits. I would follow his instructions.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 10, 2009, 06:27:07 AM
I did what Arantor suggested, but is it possible to somehow fix the layout issue in RC2? Or I'll have to wait for the next release?
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 10, 2009, 08:43:30 AM
Definitely not the best way to go about it, but it works.

Find:template_info_center();
Add Before:if ($context['user']['is_admin'])

Find: echo '
<span class="lowerframe"><span></span></span>';

Replace with:
if ($context['user']['is_admin']){
echo '
<span class="lowerframe"><span></span></span>';
}
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: JasonDD on December 10, 2009, 12:25:57 PM
As for the second part of the edit I only found this piece of code


echo '
</div>
</div></div>
<span class="lowerframe"><span></span></span>';

So I replaced it with:

if ($context['user']['is_admin']){
echo '
</div>
</div></div>
<span class="lowerframe"><span></span></span>';
}


The layout issue is still there though
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on December 10, 2009, 12:30:19 PM
You shouldn't see any lower section if you're a guest or even member with that code.
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Sudhakar Arjunan on April 15, 2012, 09:11:55 AM
This mod supported me to hide info center from guest and members

http://custom.simplemachines.org/mods/index.php?mod=1335
Title: Re: How Can I Hide Info Center From MEMBERS?
Post by: Matthew K. on April 15, 2012, 01:34:57 PM
Or try "Info Center Permissions" which is supported on v2.0.x and works well.