Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Topic started by: Gardain on September 14, 2009, 03:18:57 PM

Title: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 03:18:57 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 04:02:39 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 04:10:20 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 04:40:16 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 04:50:12 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 05:08:32 PM
Im currently using 2.0 RC1.2

Would you mind letting me know what i need to edit (or if there are any referancess)
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 05:40:28 PM
What board numbers do you want to hide from the main board index?
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 05:43:20 PM
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 .
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 06:48:59 PM
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?
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 07:04:04 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 07:07:20 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 07:46:11 PM
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
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 07:48:58 PM
Not really, no. You have to either show or not show a board, or provide links to the boards you're not showing.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 07:56:44 PM
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?

Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 08:07:13 PM
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 (http://www.simplemachines.org/community/index.php?topic=335614.0) 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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 08:17:53 PM
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
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 08:19:08 PM
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' => '',
)
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 08:21:59 PM
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.
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 08:24:18 PM
Anything in the error log relating to an undefined index, perchance?
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 08:26:16 PM
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']) ? '' : '
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 08:29:23 PM
And when following the tip did you use $settings or $context? My code uses $context because that's the proper place the variable should have been added, not $settings.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 08:38:39 PM
it slipped from my attention it seems. Sorry for that. Ive changed it to context but im still receving the same error on the log  as well as seeing all the categories at once.

// Action and board are both empty... BoardIndex!
if (empty($board) && empty($topic))
{

$context['is_board_index'] = true;
require_once($sourcedir . '/BoardIndex.php');
return 'BoardIndex';

}
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 08:40:39 PM
Really not having a good time of this, am I? Oh well.

      WHERE ' . (!empty($context['is_board_index'] && $context['is_board_index']) ? 'b.id_board IN (44,45) AND ' : '') . '{query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 08:43:16 PM
Im sure it started to get in to your nerves. If after this- still there is problem. Ill give it a rest for the night and bump the tread latter on.


Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ')' in /Sources/Subs-BoardIndex.php on line 74
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 09:04:46 PM
It's funny; I've been running this almost exact code between you and someone else in 2.x Support, and this one's my screw-up (which I fixed there just now too!)

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

/me shouldn't try coding at gone 1am. At least not while coding two other projects at the same time.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 09:11:30 PM
There is no error on the log.

But - still i see all the other boards.

Ok for now i rest my case. Thanks for your effort. Until now i managed without this feature - i think i can survive few more days. Ill bump the tread tomarow. ill be up all night doing few other things. Ill check the tread just in case.

Here is the final code that ive submited on my sub-boardindex
      WHERE ' . ((!empty($context['is_board_index']) && $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' => '',
      )


Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 09:17:39 PM
Is it listed as $settings or $context in index.php?
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 09:18:28 PM
The code
// Action and board are both empty... BoardIndex!
if (empty($board) && empty($topic))
{

$context['is_board_index'] = true;
require_once($sourcedir . '/BoardIndex.php');
return 'BoardIndex';

}

Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 09:20:09 PM
Anything in the error logs about this?
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 09:24:13 PM
no error filled.
Im refreshing as i look through pages.
But the log is currently empty

Ps: the first few codes did work on hiding the boards. (if you remember) But than the rest of the boards were not appearing . Maybe there might be an alternative way to access the boards which i can use.


Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 09:25:20 PM
It's got to be a conditionally applied statement to hide the boards while you're on the board index, and not elsewhere.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 09:28:52 PM
Quote from: Arantor on September 14, 2009, 09:25:20 PM
It's got to be a conditionally applied statement to hide the boards while you're on the board index, and not elsewhere.

I didnt understand this but to answer the part with the index. Yes. Those boards should be hidden in index while i may have access to them from external link.

Ps: You said (at the begining) your code was hiding the boards. Now we are going the other way around. May be if you give the code with the boards numbers that should be hidden, ill enter them one by one and give that a try
Title: Re: Advanced Category options - Category management and displaying
Post by: Arantor on September 14, 2009, 09:48:03 PM
The problem is that the code I used was from a mod whose purpose was to hide the boards fully. This needs to be more permissive but it's late and I'm not sure what's wrong with it.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 14, 2009, 09:54:56 PM
Ok than. Thanks again.
Ill hopefully bump the tread tomarow or the day after.
Till than I hope any one reading this and has idea also would like to share with us.
Title: Re: Advanced Category options - Category management and displaying
Post by: Gardain on September 22, 2009, 02:49:49 PM
So - is there anyone that has any idea on the problem??