Customizing SMF > Now Available
Displaying only one Category
A.M.A:
Yup yours is much better .. I guess you could use the tree link modification without any problem. Right?
mytreo:
--- Quote from: A.M.A on January 20, 2005, 04:56:05 PM ---Yup yours is much better
--- End quote ---
Wholly inspired by you though, I wouldn't have known where to start otherwise but as I began messing with your code it all came together. I love SMF :D :D
--- Quote ---I guess you could use the tree link modification without any problem. Right?
--- End quote ---
Yes right, it works just the same.
Chris
aaronsnet:
Anyone have a hack for the classic "BoardIndex.template.php" instead of the default?
thanks!
A.M.A:
please check mytreo's method It does not need any template modifications so it will work with any theme.
Gobo:
--- Quote from: mytreo on January 20, 2005, 01:38:59 PM ---Great thread, I needed to do the same and after reading this and messing aorund I have found a way to improve it so I'll share it here with you :)
This new method doesn't just hide the layer it actually changes the database query to only select the category that you want.
Pros:
1) the db query size is only as big as it needs to be, above you are still building ALL the categories into the array, then just hideing them from view
2) works in all browsers
3) the hidden categories disappear completely and no white space remains
4) you don't need to edit the template file
Cons:
1) Not really a con, but you need to edit the boardindex.php file NOT the template file.
How to do it:
Open BoardIndex.php and find the query at the top:
--- Code: --- // Find all boards and categories, as well as related information.
$result_boards = db_query("
SELECT
c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.description,
b.numPosts, b.numTopics, b.ID_PARENT,
IFNULL(mem.memberName, m.posterName) AS posterName, m.posterTime, m.subject, m.ID_TOPIC,
IFNULL(mem.realName, m.posterName) AS realName," . (!$user_info['is_guest'] ? "
(IFNULL(lb.logTime, 0) >= b.lastUpdated) AS isRead, c.canCollapse,
IFNULL(cc.ID_MEMBER, 0) AS isCollapsed" : ' 1 AS isRead') . ",
IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, m.ID_MSG,
IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR, mem2.realName AS modRealName
FROM {$db_prefix}categories AS c, {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}collapsed_categories AS cc ON (cc.ID_CAT = c.ID_CAT AND cc.ID_MEMBER = $ID_MEMBER)" : '') . "
LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)
WHERE $user_info[query_see_board]
AND b.ID_CAT = c.ID_CAT
AND b.childLevel <= 1
ORDER BY c.catOrder, b.childLevel, b.boardOrder", __FILE__, __LINE__);
--- End code ---
replace with our new query:
--- Code: --- // Find all boards and categories, as well as related information.
$result_boards = db_query("
SELECT
c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.description,
b.numPosts, b.numTopics, b.ID_PARENT,
IFNULL(mem.memberName, m.posterName) AS posterName, m.posterTime, m.subject, m.ID_TOPIC,
IFNULL(mem.realName, m.posterName) AS realName," . (!$user_info['is_guest'] ? "
(IFNULL(lb.logTime, 0) >= b.lastUpdated) AS isRead, c.canCollapse,
IFNULL(cc.ID_MEMBER, 0) AS isCollapsed" : ' 1 AS isRead') . ",
IFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, m.ID_MSG,
IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR, mem2.realName AS modRealName
FROM {$db_prefix}categories AS c, {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}collapsed_categories AS cc ON (cc.ID_CAT = c.ID_CAT AND cc.ID_MEMBER = $ID_MEMBER)" : '') . "
LEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)
WHERE $user_info[query_see_board]
" . (isset($_REQUEST['catogid']) ? "
AND c.ID_CAT = {$_REQUEST['catogid']}" : '') . "
AND b.ID_CAT = c.ID_CAT
AND b.childLevel <= 1
ORDER BY c.catOrder, b.childLevel, b.boardOrder", __FILE__, __LINE__);
--- End code ---
That's all!! Just point at index.php?catogid=X where X is the category you wish to view :D
Example here: Just see the Star Developer Category at mytreo.net (catogid=4)
You can add links to the pages in the same way as you did above by editing the template file, or also by using that clever trick above in Load.php to change the linktree.
Hope someone else finds this useful. :)
Chris
--- End quote ---
hi
im getting this error
Unknown column 'lb.logTime' in 'field list'
File: /home/.cash/akulion/path-to-peace.net/forum/Sources/BoardIndex.php
Line: 85
im using smf 1.1rc2 with TP
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version