Advertisement:

Author Topic: Hide boards on index only?  (Read 398 times)

Offline tech9

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
Hide boards on index only?
« 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!

Offline Looking

  • SMF Hero
  • ******
  • Posts: 2,456
  • SMF Customization
    • jeanborde on Facebook
    • SMF Custom Themes & Custom Coding
Re: Hide boards on index only?
« Reply #1 on: May 19, 2020, 04:53:38 PM »
Sounds like custom coding to me.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,310
Re: Hide boards on index only?
« Reply #2 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.

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,109
  • Master of BBC Abuse
Re: Hide boards on index only?
« Reply #3 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).

Offline tech9

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
Re: Hide boards on index only?
« Reply #4 on: May 19, 2020, 07:10:33 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!

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,109
  • Master of BBC Abuse
Re: Hide boards on index only?
« Reply #5 on: May 19, 2020, 07:25:32 PM »
BoardIndex.template.php

Code: [Select]
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:

Code: [Select]
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'.

Offline tech9

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
Re: Hide boards on index only?
« Reply #6 on: May 19, 2020, 08:40:27 PM »
BoardIndex.template.php

Code: [Select]
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:

Code: [Select]
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)

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,109
  • Master of BBC Abuse
Re: Hide boards on index only?
« Reply #7 on: May 19, 2020, 09:43:23 PM »
Yup. The top one is the default code, so you know what to look for.

Offline tech9

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
Re: Hide boards on index only?
« Reply #8 on: May 21, 2020, 10:34:02 AM »
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. 😟

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,109
  • Master of BBC Abuse
Re: Hide boards on index only?
« Reply #9 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.

Offline tech9

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
Re: Hide boards on index only?
« Reply #10 on: May 22, 2020, 06:06:47 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.

Offline drewactual

  • Sr. Member
  • ****
  • Posts: 833
    • College Football Fan Site CFB51
Re: Hide boards on index only?
« Reply #11 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...

Offline tech9

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
Re: Hide boards on index only?
« Reply #12 on: May 22, 2020, 09:16:29 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.