News:

Wondering if this will always be free?  See why free is better.

Main Menu

Hide Categories Based On URL/Site Alias

Started by MiY4Gi, August 10, 2012, 04:48:11 PM

Previous topic - Next topic

MiY4Gi

How can I go about restricting forum user privileges based on the URL of the current page? I use different URL aliases for my forum and I want each alias to serve different content, such as boards, categories, menu items, etc. Specifically, I want the main site to hide certain categories, and then have those hidden categories displayed at a different site alias/subdomain. I just can't figure out how to hide categories from the main site purely based on the site's URL.

E.g. myforum.tld would display the forum categories 1 and 2 (where 3 and 4 are hidden), while za.myforum.tld would display the forum categories 1, 2, 3 and 4.

I assume I'll need to create a new variable which looks at the current URL, and if the URL matches a certain predefined pattern, then if(variable) would return true, or something along those lines. I'm not really sure what to do, so I'm just thinking up random suggestions that feel like they might work.

Is there already a SMF function that can check the current URL?
Check out my new website, MyAnimeClub.net. I plan to create the largest anime community, and most fun and user-friendly anime forum in the world. It's still in the development stage though.

MiY4Gi

Nevermind. I did it using my theme.

Open: /Themes/YOUR_THEME/BoardIndex.template.php

Find:

Code (find) Select

foreach ($context['categories'] as $category)
{


Code (add after) Select

        if($_SERVER['SERVER_NAME'] == 'myanimeclub.net' && in_array($category['id'], array(2,3))) continue;


Note that the above code is what I use on my forum (SMF 2.0.2) so you'll need to replace myanimeclub.net with your site's domain, and the 2,3 in array(2,3) with the ID's of the categories you'd like to hide at the site domain you specified.
Check out my new website, MyAnimeClub.net. I plan to create the largest anime community, and most fun and user-friendly anime forum in the world. It's still in the development stage though.

Advertisement: