News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Advanced Category options - Category management and displaying

Started by Gardain, September 14, 2009, 03:18:57 PM

Previous topic - Next topic

Gardain

This mod will do the following

*when clicked on its name - it will only display the category and the boards under it. (like view single category mod)

*There will be a admin panel for the mod. Which you can link the categories if you like.
Meaning
QuoteCategories are as following
Hiphop (cat1)
Rnb (cat2)
Metal (cat3)
Rock. (cat4)

As you can see you can relate cat1 and 2 while Cat3 with 4.  So now we can choose cat 1 and 2 tobe displayed while 3 and 4 should not be displayed. (which you can choose from admin panel) .

This can either be achieved with Grand Category kinda way which youll link those categories to a main grand category called CAT A.
Thus when clicked on CAT A , it will sho category 1 and 2.  Same case with cat3 and 4 with CAT B .

Something like this.

Gardain

It came to my attention that instead of maybe going heavy with categories. Such request ive mentioned above could be achieved through the boards and child boards.

Its seems you can go up to 4 or 5 steps of child boards under one another. So maybe with help of a mod which enabls you to show only child boards , you can achieve a category hierachy kind of effect.

Arantor

There is actually no real limit AFAIK on boards/child boards. I believe in testing one of the team created 64 levels of child boards on one occasion.

It could be done through a customised theme, sure. I doubt it will be a generic mod though, since it seems too specific to a site IMO.

Gardain

So through playng and trying here and there, i managed to achieve what i wanted with child boards.

Now ill like to know if there is possiblity to hide the categories or boards just from the main index. So while members can access these boards and write and stuff , they will not be able to see the main category or the board holding these boards.

So at the end ill provide custom link buttons that will go straigh to the sub/child boards.

Arantor

The simplest route for that would be to modify BoardIndex.php (or Subs-BoardIndex.php) - depending on what version of SMF you're doing. I actually do something a lot like this in a mod I have currently pending, actually.

Gardain

Im currently using 2.0 RC1.2

Would you mind letting me know what i need to edit (or if there are any referancess)

Arantor

What board numbers do you want to hide from the main board index?

Gardain

Well there are a lot.

Mainly what i want to do is - make only the NEWS board (and the category holding it) to appear in front page.
The rest will appear when clicked on them.
Should i write the numbers or the names?

PS: Ive found this mod
http://custom.simplemachines.org/mods/index.php?mod=1736
Which removes child boards appearing in the main page.

Though not exactly what i want- still better than nothing.
Also its not smf2.x .

Arantor

Well, I'd need the board numbers - but if it's just a few/single board to display only, the number of that on its own would probably be easier; it's easier to include a few rather than exclude many if that makes sense?

Gardain

this i the category
c=6

These are the boards
44.0
45.0

I want these to "appear " while the rest being hidden. If you also require the suppose hidden ones. it will take time to name them. But mostly not. They are under some "main" boards there fore im sure hiding the main boards would simply solve the problem.

Arantor

If you look early on in Subs-BoardIndex.php, you'll see a block of code like so:

WHERE {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
'blank_string' => '',
)


If you alter it to the following:
WHERE b.id_board IN ({array_int:visible_boards}) AND {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
'blank_string' => '',
'visible_boards' => array(44,45),
)


It will show boards 44 and 45 on the main page (and category 6 as that's the category they're in, presumably) but should display nothing else.

Gardain

This worked like a charm but now i cannot access the other boards (though i have their links.)

Im tryin to open the board that holds the other boards. But they do not appear. Could this be because maybe they are told not appear.

is there a way to say which levels of boards should not appear while the rest should
if yu like - i can link you the board in order for you to understand

Arantor

Not really, no. You have to either show or not show a board, or provide links to the boards you're not showing.

Gardain

Ok. Here is the deal.

QuoteCat1 -
Board 1
board 2

Cat2 -
Board 3
--Board 4
--board 5
--board 6

So I want to hide the Board 3 from appearing in the index so ill get this look.

QuoteCat1 -
Board 1
board 2

But i have the links and i prvide them on the top of the forum. So externally - i provide the links for Board 3 so the rest of the boards can be seen which is in the board 3.

So in this mentality - if board 3 is "hidden from the index" - it should apper when i "go to its adress". But it does not.  Ive check the url and the url is not index but board. (which goes "/index.php?board=61.0")

So what do you suggest?


Arantor

Argh, I forgot about that, that routine is called in plenty of other places, not just the board index.

Solution: add the tip from here to give you a $context['is_board_index'] variable, except they refer to it there as $settings[...]. Just call it $context instead of $settings.

Then replace: WHERE b.id_board IN ({array_int:visible_boards}) AND {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
'blank_string' => '',
'visible_boards' => array(44,45),
)


With:
WHERE {string:partial_hide} {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
'blank_string' => '',
'partial_hide' => $context['is_board_index'] ? 'b.id_board IN (44,45) AND ' : '',
)


What this is saying is limit it to boards 44 and 45 on the board index only.

Gardain

Im receiving an error which is

Quote
Database Error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1=1' at line 21
File: Sources/Subs-BoardIndex.php
Line: 83

Arantor

Argh, I keep forgetting about the string parser escaping things.

Use:
WHERE ' . ($context['is_board_index'] ? 'b.id_board IN (44,45) AND ' : '') . '{query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
'blank_string' => '',
)

Gardain

I dont wanna tire you :D
But now , all the boards are visible.
Hmm.

Ps: When im done. Ill make the first post of this topic a guide for achiving what im trying to do.
many thankses Arantor.

Arantor

Anything in the error log relating to an undefined index, perchance?

Gardain

This is the log
Quotehttp:index.php?action=forum

8: Undefined index: is_board_index

File:Sources/Subs-BoardIndex.php
Line: 74

on line 74
      WHERE ' . ($context['is_board_index'] ? 'b.id_board IN (44,45) AND ' : '') . '{query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '

Advertisement: