<?php the_post(); ?>
	<?php get_template_part( 'content', 'page' ); ?>
	<!-- End WordPress page content components -->


	<?php	
	echo '<div id="my-forum-table">';
		echo '<div class="my-forum-row" style="background-color:#ccc">';
			echo '<div class="my-forum-title">';
				echo '<strong>CATEGORY</strong>';
			echo '</div>';
			echo '<div class="my-forum-title-topic" style="float:right">';
				echo '<strong>LAST TOPIC</strong>';
			echo '</div>';
		echo '</div>';
		$categories = $wps_forum->get_categories();
		foreach ($categories as $category) {
			echo '<div class="my-forum-row">';
				echo '<div class="my-forum-row-title">';
					echo stripslashes($category->title);
				echo '</div>';
				echo '<div class="my-forum-row-last-topic">';
					$last_topic = $wps_forum->get_topics($category->cid, 0, 1);
					if ($last_topic) {
						echo '<div class="my-forum-row-last-topic-avatar">';
							$wps_user = new wps_user($last_topic->topic_owner);
							echo '<a href="'.$wps->get_profile_url().'?uid='.$last_topic->topic_owner.'">';
							echo $wps_user->get_avatar(48);
							echo '</a>';
						echo '</div>';
						echo stripslashes($last_topic->topic_subject).'<br />';
			
			echo '<strong>Topic not available, sorry</strong><br />';
			echo '<a href="'.$wps->get_forum_url().$wps->get_url_q($wps->get_forum_url()).'catid='.$catid.'">Go to forum category</a>';			
			
		}
		
	} else {

		// Add breadcrumbs
		echo $wps_ui->get_breadcrumbs($catid, 'catid');
		
		// Start forum table
		echo '<div id="my-forum-table">';
				
			// Shows categories from the current level
			$categories = $wps_forum->get_categories($catid);
			if ($categories) {
				echo '<div class="my-forum-row my-forum-row my-forum-row-header">';
					echo '<div class="my-forum-title">';
						echo '<strong>CATEGORY</strong>';
					echo '</div>';
					echo '<div class="my-forum-title-topic">';
						echo '<strong>LAST TOPIC</strong>';
					echo '</div>';
				echo '</div>';
				foreach ($categories as $category) {
					echo '<div class="my-forum-row">';
						echo '<div class="my-forum-row-title">';
							$title = stripslashes($category->title);	
							echo '<a href="'.$wps->get_forum_url().$wps->get_url_q($wps->get_forum_url()).'catid='.$category->cid.'">'.$title.'</a>';
						echo '</div>';