Finally Got This Working!
Finally got this working with the help of member "rainyleaves". Here are better instructions and a code fix which is missing from the author's zip file comments.php file. The missing code is for selecting your database table prefix which is missing.
IMPORTANT NOTE: IMG Tags Can Stretch Sideblock
IMG tags with longer urls will break this if you set this as a side block. Your cmps page will get stretched breaking your layout!
NOTE: More coding is needed to correct this issue.
Suggestion: (temp fix) You may want to use this mod as a center block instead.
INSTRUCTIONS:- Edit the cmps_comments_block.php file.
- The path in this file must be entered in full url format like this:
Quote:
include('/homepages/xx/xxxxxxxx/htdocs/foldername/comments.php');
|
- If you use a normal url here it wont work such as: http://www.domain.com/folder/comments.php you will get error messages with that type of url.
- Once you have your correct url entered upload the cmps_comments_block.php file to your modules folder.
- Next edit the comments.php file which I have attached here that contains the correct fixed code. In the blue highlighted text you must enter in your correct database information.
- The red text represents the new code that allows this mod to select your correct table prefix. Example: vb_ which is the default prefix. This code fix will select your correct prefix for you. You do not edit anything here. Without this code in the comments.php file there is no way for this module to work and you will receive the errors that have been reported in this thread. NOTE: The author should correct his original zip file with this updated comments.php file that I have attached here.
- Optional: You can choose how many comments to include in the block. This number is marked in green. I set it to 10 in the example below.
- Next you must change the two urls to match your site. I labeled these in orange.
- Upload the comments.php file to your forum root.
- The rest of the author's instructions are correct. (see author's original instructions on how to make a new cmps module.)
Here is the corrected contents of the comments.php file with color highlights to match my above instructions:
Blue = Where you must enter your database information
Red = New table prefix code
Green = Number of comments to include: 10 or 5 or whatever.
Orange = Change the two urls to match your site.
Code:
<?php
// UPDATED comments.php file with small fix tweak by Yotsume
// I spent a while on this please leave the next couple of lines intact
// Coded by Optrex @ www.midlandsweather.org.uk
// Please do not put this onto any other site for download unless permission has been granted by myself (Optrex)
// This script is copyright www.midlandsweather.org.uk
//edit the variables on the next few lines in order for the script to connect to your database.
$link = mysql_connect ("database_host", "database_user", "password") or die('I cannot connect to the database.');
mysql_select_db ("database_name")or die("Could not select your database");
// You do NOT need to change the db_table_prefix if you altered it from default to something else the below code will do this for you
$result = mysql_query("SELECT username,title,pagetext,dateline,state,userid,blogtextid
FROM " . TABLE_PREFIX . "blog_text
WHERE title = ''
AND state = 'visible'
ORDER BY dateline desc
LIMIT 10" ) or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
//edit the urls to represent your sites url. (remember to check the /forum folder name)
$comms .= <<<PRINT
<tr>
<td class="$bgclass" align="left">
<span class="{$Style['small']}"><a href="http://www.yourwebsite.com/blog.php?bt=$row[blogtextid]">Comment</a> by <a href="http://www.yourwebsite.com/member.php?u=$row[userid]">$row[username] </a><br>$row[pagetext]
</td>
</tr>
PRINT;
}
?>
Ok this now works for me but I had to set it as a center block since my members use IMG tags in their blog comments. I hope you all find my instructions helpful. Thanks to "rainyleaves" for helping with the missing table prefix code. Again use the attached fixed comments.php file until the author updates his original zip file.
HAPPY BLOGGING!