The following will add children of the chosen frontpage board. As well as adding the board name to the subject line.
Example: http://www.teamgouranga.com
Admin Preview: See Attachments
Make sure to backup all files!
Show Children Hack
------------------
SQL Command:
INSERT INTO `smf_tp_settings` ( `id` , `name` , `value` )
VALUE ('', 'show_children_boards', '1');
[TPortal.php]
Find:
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
Replace With:
//-- START: Add Children Hack --//
if($context['TPortal']['show_children_boards']) {
$childrenIDs = "";
$childrenRequest = db_query("
SELECT ID_BOARD
FROM {$db_prefix}boards
WHERE ID_PARENT = $board");
while ($row = mysql_fetch_row($childrenRequest)) {
$childrenIDs .= " OR t.ID_BOARD = '".$row[0]."' ";
}
mysql_free_result($childrenRequest);
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, t.ID_BOARD
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE (t.ID_BOARD = $board $childrenIDs)
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
}
else {
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, t.ID_BOARD
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
}
//-- END: Add Children Hack --//
[TPortalAdmin.php]
Find:
elseif($what=='tp_allow_guestnews'){
db_query("UPDATE {$tp_prefix}settings SET value='$value' WHERE name='allow_guestnews'", __FILE__, __LINE__);
$go=6;
}
Add After:
//-- START: Show Childern Boards Hack --//
elseif($what=='tp_show_children_boards'){
db_query("UPDATE {$tp_prefix}settings SET value='$value' WHERE name='show_children_boards'", __FILE__, __LINE__);
$go=6;
}
//-- END: Show Childern Boards Hack --//
[TPortalAdmin.template.php]
Find:
<td>
<input name="tp_front_type" type="radio" value="forum_only" ' , $context['TPortal']['front_type']=='forum_only' ? 'checked' : '' , '> '.$txt['tp-onlyforum'].'<br />
<input name="tp_front_type" type="radio" value="forum_articles" ' , $context['TPortal']['front_type']=='forum_articles' ? 'checked' : '' , '> '.$txt['tp-bothforum'].'<br />
<input name="tp_front_type" type="radio" value="articles_only" ' , $context['TPortal']['front_type']=='articles_only' ? 'checked' : '' , '> '.$txt['tp-onlyarticles'].'<br />
<input name="tp_front_type" type="radio" value="single_page" ' , $context['TPortal']['front_type']=='single_page' ? 'checked' : '' , '> '.$txt['tp-singlepage'].'<br />
<input name="tp_front_type" type="radio" value="frontblock" ' , $context['TPortal']['front_type']=='frontblock' ? 'checked' : '' , '> '.$txt['tp-frontblocks'].'<br />
<input name="tp_front_type" type="radio" value="boardindex" ' , $context['TPortal']['front_type']=='boardindex' ? 'checked' : '' , '> '.$txt['tp-boardindex'].'<br />
</td></tr>
Add After:
<tr class="windowbg2">
<td align="right" width="45%">'.$txt['tp-showchildrenboards'].'</td>
<td>
<input name="tp_show_children_boards" type="radio" value="0" ' , $context['TPortal']['show_children_boards']==0 ? 'checked' : '' , '> '.$txt['tp-no'].'
<input name="tp_show_children_boards" type="radio" value="1" ' , $context['TPortal']['show_children_boards']==1 ? 'checked' : '' , '> '.$txt['tp-yes'].'
</td>
</tr>
Show Board Name
---------------
SQL Command:
INSERT INTO `smf_tp_settings` ( `id` , `name` , `value` )
VALUE ('', 'show_board_name', '1');
[TPortal.php]
Find:
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
$return = array();
Add After:
//-- START: Board Name Hack --//
$nameRequest = db_query("
SELECT ID_BOARD, name
FROM {$db_prefix}boards");
$boardNames = array();
if($context['TPortal']['show_board_name']) {
while ($row = mysql_fetch_assoc($nameRequest)) {
$boardNames[$row['ID_BOARD']] = $row['name'];
}
}
else {
$boardNames[$row['ID_BOARD']] = $row['ID_BOARD'];
}
mysql_free_result($nameRequest);
//-- END: Board Name Hack --//
Find:
'is_last' => false,
Add After:
//-- START: Board Name Hack --//
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $boardNames[$row['ID_BOARD']],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $boardNames[$row['ID_BOARD']] . '</a>:'
)
//-- END: Board Name Hack --//
Find:
echo '
<table border="0" width="100%" align="center" class="ssi_table">
<tr>
<td>', $news['icon'], ' <b>', $news['subject'], '</b><span class="smaller"><br />', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '<br /><br /></span></td>
</tr>
<tr>
<td>', $news['body'], '<br /><br /></td>
</tr>
<tr>
<td>', $news['link'], ' | ', $news['new_comment'], '</td>
</tr>
</table>
<br />';
Replace With:
//-- START: Board Name Hack --//
echo '
<table border="0" width="100%" align="center" class="ssi_table">
<tr>
<td>', $news['icon'], ' <b>';
if($context['TPortal']['show_board_name']) {
echo $news['board']['link'], ': ';
}
echo $news['subject'], '</b><span class="smaller"><br />', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '<br /><br /></span></td>
</tr>
<tr>
<td>', $news['body'], '<br /><br /></td>
</tr>
<tr>
<td>', $news['link'], ' | ', $news['new_comment'], '</td>
</tr>
</table>
<br />';
//-- END: Board Name Hack --//
[TPortalAdmin.php]
Find:
elseif($what=='tp_allow_guestnews'){
db_query("UPDATE {$tp_prefix}settings SET value='$value' WHERE name='allow_guestnews'", __FILE__, __LINE__);
$go=6;
}
After Add:
//-- START: Show Board Names Hack --//
elseif($what=='tp_show_board_name'){
db_query("UPDATE {$tp_prefix}settings SET value='$value' WHERE name='show_board_name'", __FILE__, __LINE__);
$go=6;
}
//-- END: Show Board Names Hack --//
[TPortal.template.php]
Find:
if($news['is_last']=='theme' || $news['is_last']==false || $news['is_last']=='title')
echo '
<div class="' , $news['icon']=='noicon' ? 'titlebg' : 'catbg' ,'" style="padding: 6px;">' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ' ,' <a href="' .$news['href']. '">' .$news['subject']. '</a></div>';
else
echo '
<div style="padding: 6px;"> ' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ' ,' <a href="' .$news['href']. '">' .$news['subject']. '</a></div>';
Replace With:
//-- Show Board Name Hack --//
if($news['is_last']=='theme' || $news['is_last']==false || $news['is_last']=='title') {
echo '
<div class="' , $news['icon']=='noicon' ? 'titlebg' : 'catbg' ,'" style="padding: 6px;">' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ' ,' <a href="' .$news['href']. '">';
if($context['TPortal']['show_board_name'])
echo ' ' . $news['board']['link'];
echo $news['subject']. '</a></div>';
}
else {
echo '
<div style="padding: 6px;"> ' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ' ,' <a href="' .$news['href']. '">';
if($context['TPortal']['show_board_name'])
echo ' ' . $news['board']['link'];
echo $news['subject']. '</a></div>';
}
//--Show Board Name Hack --//
Find:
if($news['is_last']=='theme' || $news['is_last']==false || $news['is_last']=='title')
echo '
<div class="' , $news['icon']=='noicon' ? 'titlebg' : 'catbg' ,'" style="padding: 6px;">' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ' ,' <a href="' .$news['href']. '">' .$news['subject']. '</a>';
else
echo '
<div style="padding: 6px;"> ' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ' ,' <a href="' .$news['href']. '">' .$news['subject']. '</a>';
Replace With:
//-- Show Board Name Hack --//
if($news['is_last']=='theme' || $news['is_last']==false || $news['is_last']=='title') {
echo '
<div class="' , $news['icon']=='noicon' ? 'titlebg' : 'catbg' ,'" style="padding: 6px;">' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ';
if($context['TPortal']['show_board_name'])
echo ' ' . $news['board']['link'];
echo ' <a href="' .$news['href']. '">' .$news['subject']. '</a>';
}
else {
echo '
<div style="padding: 6px;"> ' , $news['icon']!='noicon' ? $news['icon'] : '<img src="'.$settings['images_url'].'/TParticle.gif" alt="*" style="margin: 0px;" align="middle" /> ';
if($context['TPortal']['show_board_name'])
echo ' ' . $news['board']['link'];
echo ' <a href="' .$news['href']. '">'.$news['subject']. '</a>';
}
//-- Show Board Name Hack --//
[TPortalAdmin.template.php]
Find:
<td>
<input name="tp_front_type" type="radio" value="forum_only" ' , $context['TPortal']['front_type']=='forum_only' ? 'checked' : '' , '> '.$txt['tp-onlyforum'].'<br />
<input name="tp_front_type" type="radio" value="forum_articles" ' , $context['TPortal']['front_type']=='forum_articles' ? 'checked' : '' , '> '.$txt['tp-bothforum'].'<br />
<input name="tp_front_type" type="radio" value="articles_only" ' , $context['TPortal']['front_type']=='articles_only' ? 'checked' : '' , '> '.$txt['tp-onlyarticles'].'<br />
<input name="tp_front_type" type="radio" value="single_page" ' , $context['TPortal']['front_type']=='single_page' ? 'checked' : '' , '> '.$txt['tp-singlepage'].'<br />
<input name="tp_front_type" type="radio" value="frontblock" ' , $context['TPortal']['front_type']=='frontblock' ? 'checked' : '' , '> '.$txt['tp-frontblocks'].'<br />
<input name="tp_front_type" type="radio" value="boardindex" ' , $context['TPortal']['front_type']=='boardindex' ? 'checked' : '' , '> '.$txt['tp-boardindex'].'<br />
</td></tr>
Add After:
<tr class="windowbg2">
<td align="right" width="45%">'.$txt['tp-showboardname'].'</td>
<td>
<input name="tp_show_board_name" type="radio" value="0" ' , $context['TPortal']['show_board_name']==0 ? 'checked' : '' , '> '.$txt['tp-no'].'
<input name="tp_show_board_name" type="radio" value="1" ' , $context['TPortal']['show_board_name']==1 ? 'checked' : '' , '> '.$txt['tp-yes'].'
</td>
</tr>
Known Bugs:
------------
8: Undefined index: board
File: /home/gouranga/public_html/smf/Themes/TeamGourangaV1/TPortal.template.php (eval?)
Line: 105
It has to do with using $news['board']['link'] I have been struggling with this and any help would be great.
[attachment deleted by admin]
<<Reserved for added comments the the above>>
To Do:
- Add permissions checking when displaying boards.
Nice. I wish Bloc would allow the selection of board/board & all childboards/ or just certain childboards for frontpage.
Very nice hack. Great for sites using TP for Blogging. I think I asked for this months back.
Great work.
Xadio,
Am I correct to assume that post from the child boards will only show up on the frontpage for users that have access to that board? If so this rocks, and is one of the final steps in determining how I will set up my new gaming community site.
Quote from: MentalMuscle on March 02, 2006, 08:25:56 PM
Xadio,
Am I correct to assume that post from the child boards will only show up on the frontpage for users that have access to that board? If so this rocks, and is one of the final steps in determining how I will set up my new gaming community site.
That's a good question. I didn't code anything to check whether the user has permission to view the board. However, I can look into that feature. Any special requests that you might want added to that feature?
//Just tested and no it doesn't cover it. I will work on constructing it.
Xadio,
Have you had a chance to figure this out?
Quote from: MentalMuscle on March 22, 2006, 02:44:30 PM
Xadio,
Have you had a chance to figure this out?
No, unfortunately I have been really busy with school, but over spring break (this Friday) I will be able to look at it. I'll keep you update then. :)
Just re-hashing this topic if anyone wants to take a stab at it. When I have some time I will be trying myself.
The object would be to have child boards provide the frontpage news content, and based on the permissions of a member they would see news from one child board or another. Not news from all of them unless they had rights to view all of them.
This combined with member based theming would allow TP to provide unique content as well as a unique feel to each member.
Quote from: MentalMuscle on April 21, 2006, 08:49:39 PM
Just re-hashing this topic if anyone wants to take a stab at it. When I have some time I will be trying myself.
The object would be to have child boards provide the frontpage news content, and based on the permissions of a member they would see news from one child board or another. Not news from all of them unless they had rights to view all of them.
This combined with member based theming would allow TP to provide unique content as well as a unique feel to each member.
One day I will get to this, but basically all that is needed is to add an if loop on top of my code that checks if the user has permissions to view that board. If he/she does then retrieve data, else don't.
What happended eventually wit this proposal?
The code doesn't work with my installation (SMF 1.1.4 TP 0.9.8 default theme).
This Topic is almost two years old so the code is most likely outdated and should not be used.
Topic locked.