Site integration (boards): Difference between revisions From Online Manual

Jump to: navigation, search
m (moved Site Intergration - Boards to Site integration (boards): document naming convention)
m (Bot: Automated text replacement (-  + ))
 
(4 intermediate revisions by 2 users not shown)
Line 4: Line 4:


It is not difficult to accomplish this for your own website and forum with the use of SSI.php.
It is not difficult to accomplish this for your own website and forum with the use of SSI.php.
 
for more information about SSI.php see [[Category:SSI|Using 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.
This tutorial assumes that you have some level of HTML and PHP knowledge.
Line 15: Line 12:
Let's say you wanted to create a page that displays board information.
Let's say you wanted to create a page that displays board information.


Code: [Select]<?php
{{code|1=<nowiki><?php


// Get SSI into the mix.
// Get SSI into the mix.
Line 74: Line 71:
<td></td>
<td></td>
<td>Moderators</td>
<td>Moderators</td>
<td>', implode(',&nbsp;', $b['moderators']), '</td>
<td>', implode(', ', $b['moderators']), '</td>
</tr>';
</tr>';
}
}
Line 84: Line 81:
</html>';
</html>';


?>
?></nowiki>}}
This script would output board information from boards with IDs of 1, 2 and 3.
This script would output board information from boards with IDs of 1, 2 and 3.
So we get something like:
So we get something like:


 
<pre>
General Discussion
General Discussion
   Description    Feel free to talk about anything and everything in this board.
   Description    Feel free to talk about anything and everything in this board.
Line 97: Line 94:
Feedback
Feedback
   Description     
   Description     
   Moderators
   Moderators</pre>
 


And our board Information is now on another page on our site but not within SMF visibly.
And our board Information is now on another page on our site but not within SMF visibly.
Line 105: Line 101:
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.
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:
So we find in the script:
Code: [Select] // Moderators contain to much junk. We can fix this
{{code|1=<nowiki> // Moderators contain to much junk. We can fix this
if(!empty($board_info['moderators']))
if(!empty($board_info['moderators']))
foreach($board_info['moderators'] as $temp_mod)
foreach($board_info['moderators'] as $temp_mod)
$context['boards'][$board]['moderators'][] = $temp_mod['name'];
$context['boards'][$board]['moderators'][] = $temp_mod['name'];</nowiki>}}
and after it add:
and after it add:
Code: [Select] echo '<pre>';
{{code|1=<nowiki> echo '<pre>';
print_r($board_info);
print_r($board_info);
echo '</pre>';
echo '</pre>';</nowiki>}}
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.
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.
[[Category:Developing SMF]]
[[Category:Coding with SMF]]

Latest revision as of 12:07, 1 July 2013

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. for more information about SSI.php see

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.

<?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>
<table border="1">';

// Now we output.
foreach ($context['boards'] as $b)
{
echo '
<tr>
<td colspan="3">', $b['name'], '</td>
</tr>
<tr>
<td></td>
<td>Desciption</td>
<td>', $b['description'], '</td>
</tr>
<tr>
<td></td>
<td>Moderators</td>
<td>', implode(', ', $b['moderators']), '</td>
</tr>';
}

// Echo footer.
echo '
</table>
</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:

 // 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:

 echo '<pre>';
print_r($board_info);
echo '</pre>';

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.



Advertisement: