SimplePortal
Customization => Custom Coding => Topic started by: Hoodie on March 10, 2012, 10:07:31 PM
-
Is there a way for me to input the Board Name into the BoardNews block within the post?
As in "Posted In General Discussion"
-
Bump.. Anyone have any ides on how to implement this?
-
PortalBlocks.php will be a good place to start.
Can you see where the HTML for boardnews is emitted?
-
I've done quite a few edits to PortalBlocks.php to make the boardnews show to my liking.. I can't figure out how to pull the board name from the forum into that area though..
-
Good. So now all you need to do is grab the board name.
With sp_recent, this is easier, because SimplePortal gets ssi_recentPosts or ssi_recentTopics to do all the heavy lifting.
But the second SQL statement in sp_boardNews, the one that actually brings back the content, doesn't even bother with the boards table.
So, to do this, you need to actually modify the SQL statement.
And here's how. I'm going to give you the basic idea, but then I'm going to have to log out of here and get some other stuff done. You will have some debugging to do. OK?
find the 2nd SQL query. Make it to be (please check for bugs)
$request = $smcFunc['db_query']('', '
SELECT t.id_first_msg
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE ' . (empty($board) ? '{query_see_board}
AND t.id_first_msg >= {int:min_msg_id}' : 't.id_board IN ({array_int:current_board})') . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '') . '
AND (t.locked != {int:locked} OR m.icon != {string:icon})
ORDER BY t.id_first_msg DESC
LIMIT {int:limit}',
array(
'current_board' => $board,
'min_msg_id' => $modSettings['maxMsgID'] - 45 * min($limit, 5),
'is_approved' => 1,
'locked' => 1,
'icon' => 'moved',
'limit' => $limit,
)
And then, below that, stuff the board_name into your array of information
$return[] = array(
'id' => $row['id_topic'],
$return[] = array(
'board' => array ('name' => $row['board_name']),
'id' => $row['id_topic'],
And you'll have the value you want in $return[$k]['board']['name']
Or something like that... Please check carefully for bugs
-
The 2nd SQL query is like that already it seems.. So I skipped that step..
On a blank install, this is what I did..
$return[] = array(
'id' => $row['id_topic'],
'message_id' => $row['id_msg'],
$return[] = array(
'id' => $row['id_topic'],
'board' => array (
'name' => $row['board_name'],
),
'message_id' => $row['id_msg'],
And to make it display in the post:
echo '
<div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
echo '
<div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], ' in $news['board']['name'] | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
I get the following error:
8: Undefined index: board_name
File: C:/www/Fanz/Sources/PortalBlocks.php
Line: 1399
-
Trying to learn more of how this works, I went into my phpMyAdmin and the row, board_name isn't there.. id_board is which will tell me what board it's coming from but it won't tell me the name of the board to be able to display that and the link for it..
So there would need to be a way to pull the board name from the boards table using the board_id from the post itself.. Any way to do this?
-
The bug was that I left out the stuff I had meant to add to that second SQL query -- all the part about board_name! That was a test for the reader. No, actually, it was a mistake. I was in a hurry, and I am sorry.
SELECT t.id_first_msg, b.name as board_name
I learned to look for b.name by looking through SSI.php until I found that in one of the functions there. I was just looking for "board" in SSI.php until I found a function that had a SQL statement for the boards table.