Jump to content


[PHP] Smarty Templates


  • You cannot reply to this topic
No replies to this topic

#1 ShadowMage

    Young Padawan

  • Members
  • Pip
  • 2 posts
  • Gender:Male
  • Location:Pennsylvania, USA

Posted 30 December 2008 - 12:10 AM

I'm creating a forum of my own with Smarty and i'm having problems.

Ive created 2 categories and 2 forums 1 forum assigned to each category. they both appear in the one category.

Here is my PHP code.
 $getCategories = $db->dbQuery("SELECT * FROM `" . DB_PREFIX .
	 "forum_categories` ORDER BY `sort` DESC");
 while ($categories = $db->dbFetch($getCategories)) {
	 $getForums = $db->dbQuery("SELECT * FROM `" . DB_PREFIX .
		 "forum_forums` WHERE `cid` = '$categories->id';");
	 while ($forums = $db->dbFetch($getForums)) {
		 $forum[] = $forums;
		 $forumTopics = $db->dbCount($db->dbQuery("SELECT * FROM `" . DB_PREFIX .
			 "forum_threads` WHERE `fid` = '$forums->id';"));
		 $forumReplies = $db->dbCount($db->dbQuery("SELECT * FROM `" . DB_PREFIX .
			 "forum_replies` WHERE `fid` = '$forums->id';"));
		 if ($forums->last_post_id == 0) {
			 $latestPostInfo[$forums->id] = "No New Posts!";
		 } else {
			 $latestPostInfo[$forums->id] = $db->dbFetch($db->dbQuery("SELECT * FROM `" . DB_PREFIX .
				 "forum_threads` WHERE `id` = '$forums->last_post_id';"));
			 $latestPosterInfo[$forums->id] = $db->dbFetch($db->dbQuery("SELECT * FROM `".DB_PREFIX."users` WHERE `id` = '$latestPostInfo->poster';"));
		 }
	 }
	 $category[] = $categories;
 }
These are my templates.

forums_display.tpl
 {section name=forums loop=$forum}
 <tr>
							 <td class="rows" style="width: 75px;" valign="middle" align="center">Icon</td>
 
							 <td class="rows" style="width: 300px;"><div class="forum_text" style="padding-bottom: 5px;"><a href="#">{$forum[forums]->name}</a><br />
							 {$forum[forums]->description}</div></td>
 
							 <td class="rows" style="width: 125px;">{$topics}</td>
 
							 <td class="rows" style="width: 125px;" colspan="2">{$replies}</td>
 
							 <td class="rows" style="width: 300px;">
							 {if $LatestInfo[$smarty.section.forums.iteration] == 0}
							 No new posts!
							 {else}
							 <strong>In</strong>: <a href="#">{$LatestInfo[$smarty.section.forums.iteration]->title}</a><br />
							 <strong>By</strong>: <a href="#">{$latestPosterInfo[$smarty.section.forums.iteration]->username}</a>
							 {/if}	
						 </td>
 
						 </tr>
 {/section}
category_header.tpl
				<!--Start Category-->
 
					 <table class="forum" width="901" cellpadding="0" cellspacing="0">
 
					 {section name=cats loop=$category}
 
						 <tr>
 
							 <td class="category" colspan="9"><div class="cat_title">{$category[cats]->name}</div></td>
 
						 </tr>
 
						 <tr>
 
							 <td class="small_title" style="width: 75px;">&nbsp;</td>
 
							 <td class="small_title" style="width: 300px;">Forum Name, Forum Description</td>
 
							 <td class="small_title" style="width: 125px;">Topics</td>
 
							 <td class="small_title" style="width: 125px;" colspan="2">Replies</td>
 
							 <td class="small_title" style="width: 300px;">Latest Poster</td>
 
						 </tr>
 
						 {/section}
I have assigned a forum to both categories that I Have but I'm having troubles getting them to show up right.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users