(copied from http://docs.simplemachines.org/index.php?topic=1008.0 by SleePy, February 22, 2007) |
m (moved Site Intergration - Boards to Site integration (boards): document naming convention) |
Revision as of 23:48, 25 April 2011
Many people would like to learn to do stuff such as what is done at simplemachines.org and other SMF sites where the content is loaded even on non SMF pages.
Have you ever seen a website that includes information taken directly from an SMF powered forum? Many people have use for including information from their forum on to their website, and thus use integration between their website and forum to help make the user feel well connected. An example can be found directly at the Simple Machines website, which uses the site's top menu inside the forum and extracts the latest news posted on the news board on the main page.
It is not difficult to accomplish this for your own website and forum with the use of SSI.php.
SSI.php Information: Using SSI.php SSI FAQ's directory
This tutorial assumes that you have some level of HTML and PHP knowledge.
From the most simplest things, up to building a whole site, SSI can be used sparingly or extensively.
Let's say you wanted to create a page that displays board information.
Code: [Select]<?php
// Get SSI into the mix. include_once(dirname(dirname(__FILE__)) . '/Demo/SSI.php');
// What boards do we want to load? $myboards = array(1, 2, 3);
// This is simple.. For each board, load the info and remove the junk. foreach ($myboards as $board) { // With $board set as the current board this function will use it to load the board. loadBoard();
// If we got nothing it must be an error. if (empty($board_info)) die('Hey, ' . $board . ' is empty');
// Clean up and only use the stuff we want. $context['boards'][$board] = array( 'id' => $board_info['id'], 'name' => $board_info['name'], 'description' => $board_info['description'], 'moderators' => array(), );
// Moderators contain too much junk. We can fix this. if (!empty($board_info['moderators'])) foreach ($board_info['moderators'] as $temp_mod) $context['boards'][$board]['moderators'][] = $temp_mod['name']; }
// Get rid of the unnecessary. unset($myboards, $board_info);
// Header.. echo ' <html> <head> <title>Test Document</title> </head> <body>
'; // Now we output. foreach ($context['boards'] as $b) { echo ' '; } // Echo footer. echo '', $b['name'], ' | ||
Desciption | ', $b['description'], ' | |
Moderators | ', implode(', ', $b['moderators']), ' |
</body> </html>';
?> This script would output board information from boards with IDs of 1, 2 and 3. So we get something like:
General Discussion
Description Feel free to talk about anything and everything in this board. Moderators
FAQ Discussion
Description FAQ Discussion Moderators test
Feedback
Description Moderators
And our board Information is now on another page on our site but not within SMF visibly.
Thus allowing you to put your site information where ever you want it on your site. The script is very well commented and easy to follow and should work as long as the path to SSI.php is changed to your own path and you change the boards you wish to use. This is just an example file. More functionality can be done and more information can be included. The best way to get information would be to add a little script to output what information is possible to get from each board. So we find in the script: Code: [Select] // Moderators contain to much junk. We can fix this if(!empty($board_info['moderators'])) foreach($board_info['moderators'] as $temp_mod) $context['boards'][$board]['moderators'][] = $temp_mod['name']; and after it add:
Code: [Select] echo '
'; print_r($board_info); echo '
';
This now is outputting a whole bunch of information that is possible to use. Following the correct array you can correctly include information into your site that even this script does not yet handle.