News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Forum Front Page...Thing

Started by draco18s, January 28, 2005, 12:32:49 AM

Previous topic - Next topic

draco18s

Or the Home page, or index or whatever it's called.
I guess this is also a Mod Request.
Anyway as I know about as much php as I do Japanese, I'm not much at editing the forum code, so I'm wondering if someone's already done (well, I know is been done, but I need the php, hot the html it creates) what I'm looking to do:
Make the index page a kind of Front End to the forum, so that it isn't the forum itself, but rather like a news/updates page and that the all the buttons that appear on the forums also appear here (plus one to link to the top level of the forums, what is the current index page).  The news items that would appear would be linked to a board ("Site Updates" or something) and would display the first post in the topics there and have links to the threads.  Obviously only admins would be able to start topics, but any non-guest allowed to reply to them.

Thanks.

OvermindDL1

Yea, basically describing a dumbed down version of mine.  Mine is not finished enough to be releasd (and work has slowed down since college started back up) but I could hard code in the modules you want.  How do you want it to layout, look like, etc...  Mabye some drawings or three?

draco18s

*Shrugs*
Well, the forum layout is just that of the default that comes with the download of SMF.  Something close to that would be fine.
The forum itself is for my dorm wing, so it isn't going to be high tech or anything.  I don't expect to be running it more than six months myself.  After that I'd be donating it to the Wing and who ever the RA was would be the admin.
I'll see about getting a drawing done.

draco18s

#3
Something like...

Basically, there is the newsbox fader you can put on the forum main page.  Each news entry would have its own box and there wouldn't be the boards listed.  You'd click on the forum link up top (which I forgot to draw) to get to those.  Clicking Home anywhere on the forum would bring you back to this page (which shouldn't require any coding as it is the index page and Home buttons already link there).

And thanks for helping.

Edit: Image link fixed (capitalization *does* matter :P )

OvermindDL1

Will try to set something up this coming weekend.  College is overwhelming my schedule at moment.  Goto my site here and look at the modules, tell my which ones you want and I can hard integrate them in.  Don't look at the collapsing border things, they will not be there in yours, that is just test code on mine.

draco18s

Yeah, I know how college is (took my Calc 4 midterm today).
Of that portal you've got, all I really want is the part in the middle, the news ("Please test portal in other browsers", etc.), I don't need any of the side collums.

OvermindDL1

Okay, should have time tonight to do it.  If all you want is the news then this'll be very simple.  One question, do you want support to bring in news from just one board, or from multiple boards.

Herman's Mixen

this all can be done with ssi.php just what you like to show up there ... that's all
Met vriendelijke groet, The Burglar!

 House Mixes | Mixcloud | Any Intelligent fool can make things bigger, more complex, and more violent.
It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Albert Einstein

Former Godfather of our dutch community ;)

OvermindDL1

#8
Yea it can, not how I do it however so I can pull a few more things through.

EDIT: open your root index.php file and add this to the array listing for
'miniportal' => array('ODL1MiniPortal.php', 'ShowHome'),

Next make a file in your sources directory with the name of "ODL1MiniPortal.php" and put this into it
<?php
/********************************************************************************************
* ODL1Portal
*
* Stripped to display just news, used snapshot from old version 0.17 as the module system
* would be rather... interesting to strip out, the module system did not exist at that time.
*/

if (!defined('SMF'))
die('Hacking attempt...');

function
ShowHome()
{
global $txt, $modSettings, $context, $settings;
writeLog();

if (!empty($modSettings['hitStats']))
trackStats(array('hits' => '+'));

loadTemplate('ODL1MiniPortal');
loadLanguage('ODL1MiniPortal');

$context['sub_template'] = 'main';

$context['page_title'] = "ODL1's Portal Page";

$context['ODL1Portal_NewsBoardID'] = 3;
$context['ODL1Portal_NewsBoardThreads'] = 10;
$context['ODL1Portal_News'] = getBoardNews($context['ODL1Portal_NewsBoardID'],10);
}

function
getBoardNews($board = null, $limit = null, $start = null)
{
global $scripturl, $db_prefix, $txt, $settings;

// Must be integers....
if ($limit === null)
$limit = 5;
else
$limit = (int) $limit;

if ($start === null)
$start = 0;
else
$start = (int) $start;

if ($board !== null)
$board = (int) $board;
else
return;

$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();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = doUBBC($row['body'], $row['smileysEnabled']);

censorText($row['subject']);
censorText($row['body']);

$return[] = array(
'id' => $row['ID_TOPIC'],
'icon' => '<img src="' . $settings['images_url'] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" />',
'subject' => $row['subject'],
'time' => timeformat($row['posterTime']),
'timestamp' => $row['posterTime'],
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['ODL1Portal_comment'] : $txt['ODL1Portal_comments']) . '</a>',
'replies' => $row['numReplies'],
'new_comment' => '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . '">' . $txt['ODL1Portal_Write_Comments'] . '</a>',
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => !empty($row['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] : '',
'link' => !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName']
),
'is_last' => false
);
}
mysql_free_result($request);

if (empty($return))
return $return;

$return[count($return) - 1]['is_last'] = true;

return $return;
}
?>


Now, seeing as I stripped this out from an old version that didn't even have module support, there is no nice admin menu, so to set which forum ID it uses for the menu, change the number in the line
$context['ODL1Portal_NewsBoardID'] = 3;
to whatever forum ID you want to use, and change the number in this line
$context['ODL1Portal_NewsBoardThreads'] = 10 to display how many you want it to pull up at once.

Next make a file called "ODL1MiniPortal.template.php" in your ./Themes/default/ directory and put this inside it
<?php
/********************************************************************************************
* ODL1PortalTemplate
*
* Stripped to display just news, used snapshot from old version 0.17 as the module system
* would be rather... interesting to strip out, the module system did not exist at that time.
*/

function template_main()
{
global $context, $options;

echo '
<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<td id="middlesection" valign="top" width="*">'
, getDispBoardNews(), '</td>
</tr>
</table>'
;
}

function
getDispBoardNews()
{
global $txt, $context;

echo '
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="margin-bottom: 1ex;">
<tr><td class="bordercolor" width="100%">'
;


foreach ($context['ODL1Portal_News'] as $news)
{
echo '
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="border-bottom: 0;">
<tr class="titlebg">
<td valign="middle" align="left" style="padding-left: 6px;">
'
, $news['subject'], '
</td>
<td valign="middle" align="right" style="padding-left: 6px;">
'
, $news['icon'], ' ', $news['poster']['link'], '
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="bordercolor">
<tr><td style="padding: 1px 1px 0 1px;" class="windowbg">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="top" width="85%" height="100%">
<div style="overflow: auto; width: 100%;">'
, $news['body'], '</div>
</td>
</tr>
<tr>
<td>
<hr width="100%" size="1" class="hrcolor" />
'
, $news['link'], ' | ', $news['new_comment'], '
</td>
</tr>
</table>
</td></tr>
</table>
'
;

if (!$news['is_last'])
echo '
<hr width="100%" />'
;
}

echo '
</td></tr>
</table>'
;
}
?>


Now make a file called "ODL1MiniPortal.english.php" in your ./Themes/default/languages/ directory and put this inside it
<?php
/********************************************************************************************
* ODL1PortalLanguage
*
* Stripped to display just news, used snapshot from old version 0.17 as the module system
* would be rather... interesting to strip out, the module system did not exist at that time.
*/

$txt['ODL1Portal_off'] = 'Portal is off: Major overhauls are currently being performed on the forum portal, check back soon to see the enhancements made.';
$txt['manage_odl1portal'] = 'Manage ODL1 Portal';
$txt['manage_odl1portalModules'] = 'Manage ODL1 Portal Modules';
$txt['manage_odl1portalGoMain'] = 'Go back to the main Portal page';
$txt['manage_odl1portalModules_Desc'] = 'The module system is rather interesting in how it works.  Every module will either be a underneath another, or it will be inside another.  Every module has attachment point "0", this will always be right under, and the same width as the parent module.  If the parent module support additional attachment points, then the parent will display the module that attachs to points "1" and up, however it wants.  The Column module uses this to do the basic formatting of the portal.  The column module has a setting that allows you to specify the columns it supports, in the basic layout, this is three.  Any other single module may use one of the Column Module\'s additional attachment point\'s to format into concise columns.  TODO:  Finish typing basic instructions.';
$txt['manage_odl1portalModulesSettings'] = 'Module Settings';

$txt['ODL1Portal_comment'] = 'comment';
$txt['ODL1Portal_comments'] = 'comments';
$txt['ODL1Portal_Write_Comments'] = 'Write Comment';
$txt['ODL1Portal_No_Active_Already_Voted'] = 'No active poll or you already voted in them all';
$txt['ODL1Portal_Guest_no_Vote'] = 'Please login to use the Poll';
$txt['ODL1Portal_UserLinks_Title'] = 'Links Menu';
$txt['ODL1Portal_BoardStats_Title'] = 'Forum Statistics';
$txt['ODL1Portal_TopBoards_Title'] = 'Top Boards';
$txt['Lupshrink_description'] = 'This will expand/contract the Left bar';
$txt['Rupshrink_description'] = 'This will expand/contract the Right bar';
$txt['odl1portal_title'] = 'ODL1 Portal Admin Control';
$txt['odl1portal_enabled'] = 'ODL1 Portal Admin Control';
$txt['permissionname_odl1portal_access'] = 'ODL1 Portal Admin Control';
$txt['permissionhelp_odl1portal_access'] = 'This controls access to the portal control panel.';
$txt['permissiongroup_odl1portal_section'] = 'ODL1 Portal Modules';

$txt['permissionname_manage_odl1portal'] = 'ODL1 Portal Control';
$txt['permissionhelp_manage_odl1portal'] = 'This controls access to ODL1\'s Admin Portal Control page';
?>


Now, you can access the portal in one of two ways, either directly like
http://www.yourwebsite.com/forum/index.php?action=miniportal
or you can make a wrapper somewhere, say another index file in your root directory named index.php or portal.php or whatever and put something in it to reset index to miniportal, using similier to this
<?php // Made by ODL1 to reroute an index, quick hack, other better ways to do this
$ODL_path_to_forum_indexphp_from_self = "./forum/index.php";

$_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING']."&action=miniportal";

require(
$ODL_path_to_forum_indexphp_from_self);
?>


As stated, this is plain but it is simple to add other columns if you want me too.  It just displays the news and hopefully in a way that looks somewhat pleasing on any theme.  Here is the exact code as a demo http://www.overminddl1.com/miniportal.php should you see how it exactly looks, put ?theme=1 to see what it looks like using the default theme.

Hopefully I didn't mess anything up in the copy-paste or forget anything, if so, just ask and it'll be posted quickly.

EDIT 2:  I also apologize for not making a package, it'd take about 5 minutes if you really want one.

draco18s

Na, I should be able to add a few files and lines of code.
And thanks, it looks great.

draco18s

Alright, got it set up, and I noticed one thing (after I made index.php a redirect to the portal).  There's no was to link to the board index.  It links to the portal now.  Where the heck is the code for that button?

Oh, and my avatar pic isn't showing up.  I think the url for it is a bit screwy, I right-clicked on it to see were it was pulling the pic from and put that in the address bar and ended up back at the portal page.

OvermindDL1

#11
QuoteAlright, got it set up, and I noticed one thing (after I made index.php a redirect to the portal).  There's no was to link to the board index.  It links to the portal now.  Where the heck is the code for that button?
How do you have it setup, with another index.php setup somewhere, or did you replace the default action in the forum's index.php to goto the portal.  In either case its easy to add such a button, go into your theme's index.template.php I think it is, and in that row of buttons, make the one that goes "home" to either link to the portal action or the previous default board action, which ever way you want it to go, add another button to go to the other place, portal or forum.

QuoteOh, and my avatar pic isn't showing up.  I think the url for it is a bit screwy, I right-clicked on it to see were it was pulling the pic from and put that in the address bar and ended up back at the portal page.
That generally happens if it cannot be found or if you have image hotlinking off and it somehow thinks you are coming from another server.  Unable to know more without more information.

Also, you have a link to your page so we can look it over?

draco18s

#12
I changed the index.php to forum.php and index.php redirects to the portal.
Hmm, that really won't work then...all the buttons are all screwy...
*Changes it back.*

The avatar was uploaded via the Avatar option in the profile.

http://members.lycos.co.uk/draco18s/Forum/index.php [nofollow]

[Edit:]
The avatar only disapears on a page refresh.

Also added the button for the forum and the home/miniportal.  Although there is no redirect from an index to the miniportal.

OvermindDL1

Never rename the forum's index.php, it does not handle that... at all.

Your avatar seems to work everytime I refresh for me on your board, although there are a few times that the server would not send information for some things, not related to SMF.

Buttons look good though.

draco18s

Alright, things work now then.  Good.
Thanks for all your help (and the avatar thing may have just been my machine being stupid, Windows does things like that when I'm at the keyboard).

Advertisement: