Hostboard
09-03-2011, 10:00 PM
I take no credit for the code presented. The code was posted by individuals on PhotoPost.com All I did was put the posted code from the few threads together to make this work and present it in a single location. Also I hope by placing it at .org others who do not visit photopost.com often will be able to use it.
If this code infringes on anything or Chuck at PhotoPost wants it removed please feel free to do so.
If there is a better way to do this, please feel free to post any changes, additions or alterations.
This code is unsupported by me.
Working on 4.1.5pl1
Goto Admincp->vBullietin CMS->Widgets->Create New Widget
Choose PHP Direct Execution as Widget's Type
Place a Title. eg Upcoming Events. Keep it short as this is what will appear as title on your pages.
Click Save
Click Configure on the right of the new created widget.
Remove the default code that appears.
Copy and Paste the code that you can find below.
Edit: $host, $dbUser, $dbPass, and $db entries to their correct values.
Edit: Enter your domain and path to classifieds.
Edit: Set limit to number of classifieds you want (currently set for 6)
Leave the template name as is (vbcms_widget_execphp_page)
Click Save
Goto Admincp->vBullietin CMS->Layout Manager
Click Go on the Default Layout
Add the Widget to your Layout
Click Save
$host = 'localhost';
$dbUser = 'DataBaseUserID';
$dbPass = 'DatebasePassword';
$db = 'DataBaseName';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());
ob_start();
$result = mysql_query("SELECT id,cat,bigimage,title FROM cp_products WHERE bigimage != '' order by rand() LIMIT 6" ) or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
print"<center>";
print "<a href=\"http://www.YourDomain.com/PathTo/classifieds/showproduct.php?product=" . $row['id'] . "&cat=" . $row['cat'] . "\"><img src=\"http://www.YourDomain.com/PathTo/classifieds/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\" border=\"0\"></a>";
print "<br />" . $row['title'] . "</center><br />";
}
$output .= ob_get_contents();
ob_end_clean();
Working Demo: http://www.pwrhouse.com/rcmt/index.php
This is a temporary location for this site. When it becomes 404'd the permanent location will be http://www.rcmt.net and a working demo will be able to be seen there.
If this code infringes on anything or Chuck at PhotoPost wants it removed please feel free to do so.
If there is a better way to do this, please feel free to post any changes, additions or alterations.
This code is unsupported by me.
Working on 4.1.5pl1
Goto Admincp->vBullietin CMS->Widgets->Create New Widget
Choose PHP Direct Execution as Widget's Type
Place a Title. eg Upcoming Events. Keep it short as this is what will appear as title on your pages.
Click Save
Click Configure on the right of the new created widget.
Remove the default code that appears.
Copy and Paste the code that you can find below.
Edit: $host, $dbUser, $dbPass, and $db entries to their correct values.
Edit: Enter your domain and path to classifieds.
Edit: Set limit to number of classifieds you want (currently set for 6)
Leave the template name as is (vbcms_widget_execphp_page)
Click Save
Goto Admincp->vBullietin CMS->Layout Manager
Click Go on the Default Layout
Add the Widget to your Layout
Click Save
$host = 'localhost';
$dbUser = 'DataBaseUserID';
$dbPass = 'DatebasePassword';
$db = 'DataBaseName';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());
ob_start();
$result = mysql_query("SELECT id,cat,bigimage,title FROM cp_products WHERE bigimage != '' order by rand() LIMIT 6" ) or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
print"<center>";
print "<a href=\"http://www.YourDomain.com/PathTo/classifieds/showproduct.php?product=" . $row['id'] . "&cat=" . $row['cat'] . "\"><img src=\"http://www.YourDomain.com/PathTo/classifieds/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\" border=\"0\"></a>";
print "<br />" . $row['title'] . "</center><br />";
}
$output .= ob_get_contents();
ob_end_clean();
Working Demo: http://www.pwrhouse.com/rcmt/index.php
This is a temporary location for this site. When it becomes 404'd the permanent location will be http://www.rcmt.net and a working demo will be able to be seen there.