MyBB Community Forums

Full Version: Help with conditional in archive pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need some advice if it's possible to use a conditional in the archive file called: "archive/index.php".

I'm trying to make only one AdSense Banner appear in all archive threads (posts) by using this below. I added the RED code.

Quote: // Damn thats a lot of parsing, now to determine which username to show..
if($post['userusername'])
{
$post['username'] = $post['userusername'];
}
$post['username'] = build_profile_link($post['username'], $post['uid']);

$plugins->run_hooks("archive_thread_post");

// Finally show the post
echo "<div class=\"google_adsense\">GOOGLE ADSENSE HERE</div>\n";
echo "<div class=\"post\">\n<div class=\"header\">\n<div class=\"author\"><h2>{$post['username']}</h2></div>";
echo "<div class=\"dateline\">{$post['date']}</div>\n</div>\n<div class=\"message\">{$post['message']}</div>\n</div>\n";
}
archive_multipage($postcount, $perpage, $page, "{$base_url}thread-$id");

$plugins->run_hooks("archive_thread_end");

archive_footer();
break;

The problem is this, the banner just gets repeated over and over after every posts made. Rather that it only being displayed - once only.

Is there a conditional I can add to my red code added, to make it only get displayed once.
I've solved it myself. I put that echo line of code directly after this line of code in the archive/index.php file.

Find:

		$plugins->run_hooks("archive_thread_end");

After that put you code