Hi,
Page design is done via layers. See here for more details:
http://www.simplemachines.org/community/index.php?topic=145838.0The top of the page (page header, etc.) is done via function
template_main_above() in
index.template.php. The bottom part of page is done via function
template_main_below() in
index.template.php.
The stuff that is between these two sections the main_above and main_below is displayed using various templates depending on which page you are at. When you are at a displayed posts page, the
Display.template.php is the file that is responsible for displaying the page content. The function
template_main() is where the magic happens.
The layout of the page is done using tables which is not very nice from the design perspective, it would be nicer if everything was just DIVs, but since the page design is done via tables, I solved the task of adding a sidebar by wrapping everything into another table where the first collumn is my sidebar.
[font=courier]function template_main()
{
echo "<div>\n[color=red]<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"
."<tr>\n<td width=\"200px\" valign=\"top\" style=\"border: 1px solid #9BAEBF;\">[/color]\n";[/font]
The table, tr, and td are the pieces that I added to the template_main() function in the Display.template.php file.
Now, how to add the most recent posts and most recent topics?There are two functions called function
ssi_recentPosts and function
ssi_recentTopics in
SSI.php. Theoretically, you could use these two functions, but the problem is that they output the content in HTML tables again. I wanted to modify the output format without destroying the original functions, so I just copied them into new functions named them function ssi_recentPostsDiv and function ssi_recentTopicsDiv. Then I modified these to output most recent posts and most recent topics in DIV format.
The next step is to do something so that these functions display only most recent posts and topics from the discussion board that the visitor is viewing at the moment. You can supply arguments to the functions. Arg(0) = number of posts to display. Arg(1) = array of board IDs that should be excluded from the view. So, the goal now was to develop this array.
All information about a page can be accessed by looking at
GLOBALS[’context’].
[1] The ID of the current board is stored in
$GLOBALS['context']['current_board'].
[2] The list of all boards that exist in our forum is available in
$GLOBALS['context']['pretty']['board_urls'] as array.
So, now, you only need to strip [1] from [2]. Once you have that, call the ssi_recentPostsDiv and ssi_recentTopicsDiv functions and give it the [2] – [1] array as the second parameter.
$contextArr = $GLOBALS['context']['current_board'];
$arrBoardIds = $GLOBALS['context']['pretty']['board_urls'];
unset($arrBrdsExclude);
$arrBrdsExclude = array();
foreach ($arrBoardIds as $key => $value) {
if($key == $contextArr) { }
else { $arrBrdsExclude[] = $key; }
}
require_once("../forum/SSI.php");
echo "<div class=\"catbg3\">Most Recent Topics:</div>\n<div style=\"clear: both; \">\n";
ssi_recentTopicsDiv(8,$arrBrdsExclude);
echo "</div>\n";
echo "<div class=\"catbg3\">Most Recent Posts:</div>\n<div style=\"clear: both; \">\n";
ssi_recentPostsDiv(8,$arrBrdsExclude);
echo "</div>\n";
Result = sidebar which displays most recent posts and most recent topics from only this current discussion board. See at the left.
Cheers.