Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: tech9 on May 19, 2020, 04:51:57 PM

Title: Hide boards on index only?
Post by: tech9 on May 19, 2020, 04:51:57 PM
I know this has been asked before many years ago but unless I missed something nobody ever came up with a simple solution for this?

Anyways what I want to do is to hide a category and it's board from displaying to members on the home page (index) but I want to add a custom like to the board in the top navigation menu and when it's clicked members will be able to see board and post in board.

Is this possible or do I need to make a plugin request?

Thanks!
Title: Re: Hide boards on index only?
Post by: Looking on May 19, 2020, 04:53:38 PM
Sounds like custom coding to me.
Title: Re: Hide boards on index only?
Post by: Arantor on May 19, 2020, 05:37:28 PM
You could make a board that no-one except admins can see, put the boards you want to hide as sub-boards of that board, and then use the ad management mod (or a portal) to put something in to show people whatever it is you want them to see.
Title: Re: Hide boards on index only?
Post by: Antechinus on May 19, 2020, 05:48:27 PM
Should be simple enough. It just needs either a conditional in the template, or a simple display: none; in the CSS, to hide the relevant category.

Template conditional is theoretically better for performance than using CSS, but it probably wouldn't be noticeable in practice if we're only talking one board in the category. Menu link would be done like any other custom menu link (extra button in Subs.php array).
Title: Re: Hide boards on index only?
Post by: tech9 on May 19, 2020, 07:10:33 PM
Quote from: Antechinus on May 19, 2020, 05:48:27 PM
Template conditional is theoretically better for performance than using CSS,
So what code would I have to add to the template to hide a board by board ID and where exactly would I put the code in the template file? 

Thanks!
Title: Re: Hide boards on index only?
Post by: Antechinus on May 19, 2020, 07:25:32 PM
BoardIndex.template.php

foreach ($context['categories'] as $category)
{
// If theres no parent boards we can see, avoid showing an empty category (unless its collapsed)
if (empty($category['boards']) && !$category['is_collapsed'])


This should work:

foreach ($context['categories'] as $category)
{
// If theres no parent boards we can see, avoid showing an empty category (unless its collapsed)
if (empty($category['boards']) && !$category['is_collapsed'] && ($category['id'] != '3'))


Looks alright, but haven't tested it. Substitute the actual category number where it says '3'.
Title: Re: Hide boards on index only?
Post by: tech9 on May 19, 2020, 08:40:27 PM
Quote from: Antechinus on May 19, 2020, 07:25:32 PM
BoardIndex.template.php

foreach ($context['categories'] as $category)
{
// If theres no parent boards we can see, avoid showing an empty category (unless its collapsed)
if (empty($category['boards']) && !$category['is_collapsed'])


This should work:

foreach ($context['categories'] as $category)
{
// If theres no parent boards we can see, avoid showing an empty category (unless its collapsed)
if (empty($category['boards']) && !$category['is_collapsed'] && ($category['id'] != '3'))


Looks alright, but haven't tested it. Substitute the actual category number where it says '3'.
Oh so cool Thanks! 😊👍
I'll test it out later tonight and let you know if it is working.

I only have to use the bottom code you posted right?
(Not the one you posted in the top of the post)
Title: Re: Hide boards on index only?
Post by: Antechinus on May 19, 2020, 09:43:23 PM
Yup. The top one is the default code, so you know what to look for.
Title: Re: Hide boards on index only?
Post by: tech9 on May 21, 2020, 10:34:02 AM
Quote from: Antechinus on May 19, 2020, 09:43:23 PM
Yup. The top one is the default code, so you know what to look for.
I still haven't tested this code yet because the reason that I wanted the code in the first place was to hide the blog board that I created with the SMFblog plugin, but as it turns out that blog plugin doesn't work with SMF 2.0.17 anyways.

I tried pmxblog plugin too and it doesn't work either so I guess no blog plugins are currently available for 2.0.17. 😟
Title: Re: Hide boards on index only?
Post by: Antechinus on May 21, 2020, 06:00:35 PM
Have you tried using version emulation to install it? There's an "Advanced" link below the list of mods. Click that, and set the site to 2.0.15 temporarily. See if it installs without warnings then.
Title: Re: Hide boards on index only?
Post by: tech9 on May 22, 2020, 06:06:47 PM
Quote from: Antechinus on May 21, 2020, 06:00:35 PM
Have you tried using version emulation to install it? There's an "Advanced" link below the list of mods. Click that, and set the site to 2.0.15 temporarily. See if it installs without warnings then.
I tried that with smfblog and it still doesn't work. It installs fine but does not display blog posts on main blog list page. I contacted the plugin author on smfhacks and he said that he has no plans of updating the plugin.
Title: Re: Hide boards on index only?
Post by: drewactual on May 22, 2020, 08:52:32 PM
I love smf. Imho its the best forum out there with clean precise code.  If you want a blog, though, why don't you just WordPress it?

It can be drug into SMF with just a little work.  Check that... just some copy and paste because the work has been done.  Check out https://carolina-woodworkers.com ... it sounds similar to what you're trying to achieve?  That presentation is shockingly simple. You can also rely on WP for publishing your articles to subscribers and affiliates, which is something SMF can't do (without a lot of work).... I've got some work to do with the mobile version of that site, but on a PC its clean and stable.  Oh..... and there is a conditional for several items on it... go to a board and the top banner disappears as a for instance...
Title: Re: Hide boards on index only?
Post by: tech9 on May 22, 2020, 09:16:29 PM
Quote from: drewactual on May 22, 2020, 08:52:32 PM
I love smf. Imho its the best forum out there with clean precise code.  If you want a blog, though, why don't you just WordPress it?
I love Wordpress but for some reason whenever I install it on a host it takes forever for the index page to load and I can't deal with that.

Plus I was just looking for something light and simple that I could plug in to SMF. WordPress is a complete content management system on it's own.