Jump to content


Photo

Help with tpl files and php


  • Please log in to reply
3 replies to this topic

#1 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 02 August 2006 - 09:53 AM

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:
<?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");
	
	}
	
	
	
?> 

And this is what I get!
http://system.dotome...splay.php?fid=2

#2 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 02 August 2006 - 11:53 PM

Anyone please? This is fairly disappointing that I haven't gotten a response.

#3 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 02 August 2006 - 11:58 PM

It would appear to be an error in the templating system.  It isn't doing the regular expression match/replace correctly.  You may want to reference the template creator's website and documentation.

#4 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 03 August 2006 - 12:18 AM

I made the template, and it shows everything, I just need the while loop to be within {LISTTHREADS}

This has put a big halt on development and I really need this solved now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users