Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: menkaura on December 22, 2005, 02:43:22 PM

Title: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: menkaura on December 22, 2005, 02:43:22 PM
Show your SMF Forums' Topic Replies on your own Websites 'index.html' page. ie partially at least Portalize your
own Website.

I make no pretentions of being anything more that enthusiastic when it comes to coding so please check
the code out first and know what your are running before you use it please. I'm open to ideas so please feel
free to make constructive suggestions.

The following PHP code canbe embedded into a suitable standard HTML page which canbe in turn called from
you websites main index.html page as follows:

<FONT COLOR=#004080><?
include 'http://www.menkaura.com/Place your subs folder name here/getReplies.php';
?></FONT>

Firstly use phpMyAdmin to setup a User/Password combination that has view rights over your SMF MySQL Database.
Amend the variables below to reflect you particular setup.

Have fun and if you need any assistance give please post against this top at http://www.menkaura.com/Forum/index.php?topic=334.0

If you want to see it working please have a look at http://www.menkaura.com

PS: Hopfully I've got the posts correct above.

<?

//Define and set variables.
$db_server = 'localhost';
$db_name = 'Your SMF MySQL DB Name Goes Here';
$db_user = 'An Appropriately Priv Users Name Goes Here';
$db_passwd = 'The Priv Users Password Goes Here';

//Connect to the server and select the databse ... with error checking.
$db_connection = @mysql_connect($db_server, $db_user, $db_passwd)
   or die('Could not connect: ' . mysql_error());
   
mysql_select_db($db_name,$db_connection);

//Form the first query to get the fields from smf_messgaes table.
$get_most_replies = mysql_query("SELECT smf_messages.id_topic, smf_messages.subject, smf_topics.numReplies FROM smf_messages, smf_topics WHERE smf_messages.id_topic = smf_topics.id_topic AND smf_messages.subject NOT LIKE 'Re:%' ORDER BY numReplies Desc", $db_connection);

for($i = 1; $i < 9; $i++) {
    $row = mysql_fetch_array($get_most_replies);
   echo "$i. <a href='http://www.menkaura.com/Forum/?topic=$row[id_topic]'>$row[subject]<br />\n</a>";
} //end For...

//Finally clean up after yourself.
//Clear the memory used for the query result.
mysql_free_result($get_most_replies);

//Close the database connection.
mysql_close($db_connection);
?>
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' p
Post by: 1MileCrash on December 22, 2005, 02:47:02 PM
why not just use SSI.php?
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: menkaura on December 22, 2005, 03:20:21 PM
To be honest I'm sure that there are other ways of doing the same thing. I was after an easy way to show Forum Topic posts and views on my Websites from page and independent of the SMF functionality.

However I'm certainly always after other ways of doing the same thing. If you could elabotrate a bit on ssi.php that would be great.

Many thanks ...
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' p
Post by: 1MileCrash on December 22, 2005, 03:23:00 PM
this is a built in function of smf. after including ssi.php into your page, inserting this single line would accomplish the same thing.

<?php ssi_recentTopics(); ?>

Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' p
Post by: router on December 24, 2005, 01:32:10 PM
nice info, thanks, How can I put the info into tables? I want to use my site template tables.

thanks
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' p
Post by: Harvester on March 24, 2006, 09:06:38 AM
Quote from: Tippmaster on December 22, 2005, 03:23:00 PM
this is a built in function of smf. after including ssi.php into your page, inserting this single line would accomplish the same thing.

<?php ssi_recentTopics(); ?>



I dont understand this... what do you mean "including ssi.php into your page"?? Id like to be able to do what menkaura has done on his page but if there is an easier like Tippmaster says I am all for that because I am vvery new  to all this stuff.
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: kegobeer on March 24, 2006, 09:15:46 AM
Please read the SSI FAQs and look at ssi_examples.php.
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: Harvester on March 24, 2006, 09:28:49 AM
ok I have looked at the ssi examples and thats what I want to do but I guess I am not doing something right. I also cant seem to locate the SSI FAQ.
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: kegobeer on March 24, 2006, 09:35:48 AM
Here's the link:

http://www.simplemachines.org/community/index.php?topic=14906.0

You'll have to explain what you've done so far and post the code you are using in order for me to help you.
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: Harvester on March 24, 2006, 09:51:57 AM
I get the feeling I am doing it totally wrong hehe  :-[

I just opened my index.html file and pasted this in it:

<?php
include('./bassin-forums/SSI.php?ssi_function=recentTopics');
?>


Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: Harvester on March 24, 2006, 10:18:25 AM
Well, I am more lost than ever now lol

Ive been reading the FAQ and the ssi_examples.php file

and now i have in my index.html file the very first line reading this:

<?php require("/home/harvester/public_html/forums/SSI.php"); ?>

so I think my next step would be to put this:

<?php ssi_recentTopics(); ?>

wherever I want on my index.html page? yes? Im thinking not or that I am missing something more because its not working  still.

please help?
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: kegobeer on March 24, 2006, 10:37:55 AM
You can't use SSI inside of a static HTML page, it must be a php or shtml file.  Just change index.html to index.php.  If you don't have any experience coding PHP, I highly recommend visiting www.php.net and taking a look at the online documentation, and also searching the 'net for php tutorials.  That will help you understand the basic workings of PHP.
Title: Re: Show your own SMF Forum 'Topic Replies' on your Websites main 'index.html' page
Post by: Harvester on March 24, 2006, 10:47:32 AM
I changed my page name to index.php and i see the recent topics now... only problem is... they are at the very top of the page behind my header graphic. I tried to move the code to the bottom of the page but the output is still at the very top of the page.

...and I thought I was lost and confused before?? lol