SimplePortal

Customization => Custom Coding => Topic started by: Hoodie on March 10, 2012, 10:07:31 PM

Title: Board Name in BoardNews
Post 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"
Title: Re: Board Name in BoardNews
Post by: Hoodie on April 06, 2012, 11:36:46 PM
Bump..  Anyone have any ides on how to implement this?
Title: Re: Board Name in BoardNews
Post by: AngelinaBelle on April 09, 2012, 11:07:02 PM
PortalBlocks.php will be a good place to start.
Can you see where the HTML for boardnews is emitted?
Title: Re: Board Name in BoardNews
Post by: Hoodie on April 16, 2012, 10:44:18 PM
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..
Title: Re: Board Name in BoardNews
Post by: AngelinaBelle on April 17, 2012, 12:51:49 PM
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)
Code: [Select]
   $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
Code: (find) [Select]
      $return[] = array(
         'id' => $row['id_topic'],

Code: (replace) [Select]
      $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
Title: Re: Board Name in BoardNews
Post by: Hoodie on April 28, 2012, 07:25:20 PM
The 2nd SQL query is like that already it seems..  So I skipped that step..

On a blank install, this is what I did..
Code: (find) [Select]
$return[] = array(
'id' => $row['id_topic'],
'message_id' => $row['id_msg'],

Code: (replace) [Select]
$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:

Code: (find) [Select]
echo '
<div class="middletext">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';

Code: (replace) [Select]
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:

Code: [Select]
8: Undefined index: board_name
File: C:/www/Fanz/Sources/PortalBlocks.php
Line: 1399
Title: Re: Board Name in BoardNews
Post by: Hoodie on April 28, 2012, 07:42:06 PM
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?
Title: Re: Board Name in BoardNews
Post by: AngelinaBelle on April 30, 2012, 12:15:57 PM
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.

Code: [Select]
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.
SimplePortal 2.3.8 © 2008-2024, SimplePortal