TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 219
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 126
  • Total: 126

Display boardnames of a category within a TP Block

Started by guvenck, August 01, 2006, 01:51:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

guvenck

Hi, I need a block code that displays the boardnames from a category as links to the board in a TP block.
Can someone help me here?

Xarcell


guvenck

I could do it with external SQL queries in a phpblock, but perhaps there are easier to use functions within TP and/or SMF.

guvenck

Xarcell: I made a simple one-level list without caring about the permissions.
Put following in a phpblock:



$hostname = "localhost"; // MySQL server
$dbname = "mysqldbname"; // Your MySQL DBName
$dbusername = "mysqlusername"; // Your MySQL Username
$dbpass = "mysqlpassword"; // Your MySQL Password

$cat = 1; // Category ID you want the boards to be fetched

if (!isset($connection)) {
    $connection = mysql_connect($hostname, $dbusername, $dbpass) or die(mysql_error());
    mysql_select_db($dbname, $connection) or die(mysql_error());
}

$query = "SELECT ID_BOARD, name FROM smf_boards WHERE ID_CAT='$cat'";
$result = mysql_query($query);
while ($row = mysql_fetch_row($result)) {
echo "<a href=\"index.php?board=$row[0].0\">$row[1]</a><br>";
}


JPDeni

SMF already connects to the database. You don't have to do it again. Here's the same thing, listing all of the boards and child boards in a category, in the order they appear on your forum:
global $scripturl;
$category = 2; // Change this to the number of the category you want

$query = db_query(
  "SELECT ID_BOARD, name
   FROM smf_boards
   WHERE ID_CAT = $category
   ORDER BY boardOrder", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
{
  echo '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '">' . $row['name'] . '</a><br />';
}


It doesn't check permissions, either, so you would only want to use this when your board was accessible to everyone.

guvenck


bloc

Serves as a good way to let people see whats inside - a sneak preview even if the boards are restricted.

guvenck

Also, it attracts people to visit the forums. In my case, I run a TV Series site and have a single board dedicated to each title. Have more than one hundred boards this way, imagine what a visitor would feel like when he/she sees the huge list at the right side. This could be a better way to take him to the Forums.

This website is proudly hosted on Crocweb Cloud Website Hosting.