Jump to content

Help with tpl files and php


localhost

Recommended Posts

I am makign a forum display that needs to use a while statement to list all the threads, although it is fairly messed up because I cannot get it inside of the forumdisplay.tpl file!

code:
[code=php:0]
<?php
/*---------------------------------------------------+
| [dotOmega 0.1.0 Beta] Community System
+----------------------------------------------------+
| Copyright © 2006 Robert Playford
| http://dotomega.com
+----------------------------------------------------+
| Filename: forumdisplay.php - 07-28-2006 - 08:55AM
| File written by: Dan La Manna (Copernicus)
+----------------------------------------------------*/

// Require necessary file(s)
require_once "inc/global.php";
require_once "inc/config.php";
require_once "inc/class_template.php";

ini_set('error_reporting', E_ALL);

/*
Forum table types

Type 1 = Thread
Type 2 = Post

Note:
Threads have a tid of 0 ALWAYS
*/

$FID = secureGet($_GET['fid']);

// Find out the forum name!
$forum_name = query("SELECT `title` FROM `" . $config['table_prefix'] . "forums` WHERE `type` = '2' AND `id` = '$FID'");
$fetchname = fetch_array($forum_name);
$forum_title = $fetchname['title'];


// Select all threads that exist within the forum id $FID
$sel_threads = query("SELECT * FROM `" . $config['table_prefix'] . "posts` WHERE `type` = '1' AND `fid` = '$FID' ORDER BY `id` ASC");
$num_threads = num_rows($sel_threads);

// Query failed error message
if(!$sel_threads) {
echo 'Could not query threads list.';
}

$tplObj = new tplSys("./");
    $tplObj->getFile( array(
        'forum_display' => 'templates/default/forum_display.tpl' )
    );

// Display it all!
    $tplObj->varRef( "forum_display", array(
"TITLE" => '.Omega Development Forums',
"FORUM" => "$forum_title",
"BOARDNAME" => ".Omega Development Forums",
"NEWTHREAD" => "<a href=\"newthread.php?fid=$FID\"><img src=\"images/newthread.gif\" border=\"0\"></a>"

)
    );


    $tplObj->parseDynamic("forum_display");

// Loop to fetch thread info and display it
while ($fetch_thread_info = fetch_array($sel_threads)) {
$thread_title = $fetch_thread_info['title'];
$thread_id = $fetch_thread_info['id'];
$thread_poster = $fetch_thread_info['poster'];

$tplObj = new tplSys("./");
    $tplObj->getFile( array(
        'forum_threads' => 'templates/default/forum_threads.tpl' )
    );

$tplObj->varRef( "forum_threads", array(
"THREADNAMEANDSTARTER" => "<A href=\"showthread.php?fid=$FID&tid=$thread_id\">$thread_title</a><br>by <a href=\"viewprofile.php?u=$thread_poster\">$thread_poster</a>",
"LASTPOST" => "Not implemented",
"REPLYCOUNT" => "x",
"VIEWCOUNT" => "x"
)
);

$tplObj->parseDynamic("forum_threads");

}



?>
[/code]

And this is what I get!
http://system.dotomega.com/forumdisplay.php?fid=2
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.