Forum Moderators: coopster
"
The file you'll need to look at is viewtopic.php, which if you're using Nuke is probably somewhere around here:-
/www/modules/PNphpBB/viewtopic.php
Look for the start of the main loop:-
for($i = 0; $i < $total_posts; $i++)
.... in there is the code you'll need to edit for the first post (if $i == 1 then $super_ads = $as_code otherwise $super_ads = ""). Then you need to add the new super_ads variable to the template array.
I won't get further into the PHP here as this is the AdSense forum. If you need help with the coding side, I suggest you repost in the PHP forum. "
i know were the file is and i have found the line, i jsut dont know where to go from there, and if i have to add that line or edit the current one
you could then add the if in the loop
if ($i == 1) $super_ads = $as_code
else $super_ads = "";
then somewhere you need to echo $super_ads after the post content is output
this would mean that it would show AdSense code only when $i==0, which I assume is after the first post
Backup viewtopic.php now!
Copy it and rename to viewtopic.old (or whatever).
You are not deleting or editing anything. You are only adding new lines of code.
Basically Adam's (jatar-k) post above is correct, but there is not output at the end. The script calls a parsing function which runs an array of variables through the template to create the final page.
Variables are set in the array with an assignment, you'll see code like this for example:-
'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
The words on the left in quotes are referenced in the template. If you have a look at viewtopic.tpl (or whatever the template is - can't remember now), you'll see things like:-
<tr><td>{POST_DATE}</td></tr> You'll need to add your adsense code into the array in viewtopic.php, something like:-
'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'ADSENSE' => $super_ads, // Added by Arbit 7.1.06
Then in your template file you would need to add something like:-
<tr><td>{ADSENSE}</td></tr> .... where you want it to appear.
Remember that viewtopic.php works in a loop, and the same template is used for every post. That's why we must be sure to reset $super_ads to "" (empty) if it's not the first post, otherwise the loop will insert your AdSense code at the bottom of every post.
So, to clarify with an overview:-
Backup viewtopic.php right now buster or the cat gets it! ;-)
Backup the template file too
We are adding to the top of viewtopic.php:-
// Variable to store our AS code
// Makes for easier editing if we change a channel etc
// Added by Arbit 7.1.06
$as_code = "<your adsense code>";
Then within our main loop:-
// Added by Arbit 7.1.06 - Ads after first post
if ($i == 1) { // if this puts ads on 2nd post, change to 0
// First post - output ads
$super_ads = $as_code;
} else {
// This will get output anyway, so make sure it's nothing
$super_ads = "";
}
Then where the script variables are put into the main array:-
// Added by Arbit 7.1.06
'ADSENSE' => $super_ads,
Then you need to edit your template file (viewtopic.tpl I'm sure it's called - it'll be in the /templates folder):-
{ADSENSE}
Where you want the ads to appear. You can use straight HTML in here if you want to put it into a DIV, <TD> etc
That should do it. If you get stuck beyond this, rename the new edited viewtopic.php to viewtopic.broke and put the .old back to .php. That will ensure your forum remains operational. Let us know what errors you got and we can probably get you fixed up from there.
<Patronising Voice of Experience>As a general tip I recommend you leave the comments in, or write your own. Use lots of comments - I promise you that you'll come back to this in a years time and you won't understand how it works because you'll have forgotten.... ;)</Patronising Voice of Experience>
TJ