Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/68897?pagenum=1
05 November 2025, 08:47
Topic
Running925
How to put ad spots between posts ??
03 September 2009, 13:54
I'm interested in finding out how i can automate a snipit of code to pop in-between every so many posts for ad space.
Any help would be appreciated.
Thank
tony
<moved from="Help: General / Current Version (v3.4.xx)" by="Shaggy" />
Replies ...
balexandre
03 September 2009, 17:01
quite easy...
open topic.asp file
in the original file (v.3.4.07), at line 683 add:
right before the next in the loop For iForum = 0 to iReplyCount
Code:
if ( iForum Mod 2 = 0 ) then Response.Write "<tr>" & VbCrLf & _ "<td bgcolor=""" & CColor & """ valign=""top"" width=""" & strTopicWidthLeft & """ colspan=""3"">" & VbCrLf & _ " [CONTENT OF THE ADD] " & VbCrLf & _ "</td></tr>" end if
Where iForum Mod 2 ... the 2 is the separation, if you want 3 by 3... write
iForum Mod 3
you will end up with something like:
Running925
04 September 2009, 09:18
that is exactly what i was looking for.
thanks a ton!! :)
balexandre
04 September 2009, 09:46
see how easy it was
Running925
04 September 2009, 10:17
ok.. idk if my file is different or what but i'm having a hard time making this work. I put that code in on the line you said and it failed. so i moved it to where i thought it looked right (to me) and it poped in after the first post and nowhere else...
any suggestions?
Running925
04 September 2009, 10:41
n/mind, i figure it out!
Running925
04 September 2009, 10:58
Now i'm having a problem puting my adsense code in the spot where the txt is displaying. It thinks it's the end of a statement when it sees the google script...
This is what i've done: (Whats wrong here?)
if ( iForum Mod 2 = 0 ) then Response.Write "<tr>" & VbCrLf & _ "<td bgcolor=""" & CColor & """ valign=""top"" width=""" & strTopicWidthLeft & """ colspan=""3"">"
if ( iForum Mod 3 = 0 ) then Response.Write "<tr>" & VbCrLf & _ "<td bgcolor=""" & CColor & """ valign=""top"" width=""" & strTopicWidthLeft & """ colspan=""3"">" & VbCrLf & _ " <!--#INCLUDE FILE="midpost.html"-->" & VbCrLf & _ "</td></tr>" end if
with nothing but some txt in the midpost file, it still gives me an error that states: Expected end of statement at the first "
AnonJr
04 September 2009, 15:03
Try:
Code:
if ( iForum Mod 3 = 0 ) then Response.Write "<tr>" & VbCrLf & _ "<td bgcolor=""" & CColor & """ valign=""top"" width=""" & strTopicWidthLeft & """ colspan=""3"">" & VbCrLf & _ " <!--#INCLUDE FILE=""midpost.html""-->" & VbCrLf & _ "</td></tr>" end if
HuwR
04 September 2009, 15:40
you can't use the include directive inside a response.write, it will not work, you have to end the script first so you would have to do
if ( iForum Mod 3 = 0 ) then Response.Write "<tr>" & VbCrLf & _ "<td bgcolor=""" & CColor & """ valign=""top"" width=""" & strTopicWidthLeft & """ colspan=""3"">" & VbCrLf %> <!--#INCLUDE FILE="midpost.html"--> <% Response.Write "</td></tr>" end if
Running925
04 September 2009, 16:41
you guys are Awesome!!
that worked HuwR
ony thing i'm tryin go square away now is i can't seem to get the ad to center it self in that cell. I've tried multiple ways to align it center (css / hard center) and i think the forum's propertys are taking priority on that because it continues to flush left on me.
If anyone has a suggestion then please toss it out there, i'd love to give it a shot. Otherwise, i might just live with it, at least it's on there!!
thanks again for the help guys.
leatherlips
04 September 2009, 18:54
Have you tried putting inside of a div tag? You could do something like <div align="center">Your Content</div>
Running925
05 September 2009, 00:01
Originally posted by leatherlips Have you tried putting inside of a div tag? You could do something like <div align="center">Your Content</div>
yea, it didn't seem to work...
Classicmotorcycling
05 September 2009, 02:03
Have you tried putting a simple align tag in:
if ( iForum Mod 3 = 0 ) then Response.Write "<tr>" & VbCrLf & _ " <td bgcolor=""" & CColor & """ align=""center"" valign=""top"" width=""" & strTopicWidthLeft & """ colspan=""3"">" & VbCrLf %> <!--#INCLUDE FILE="midpost.html"--><% Response.Write " </td>" & VbCrLf & _ "</tr>" end if
balexandre
05 September 2009, 07:51
the proper css rule if using a div is
.googleads { width: 100%; text-align: center; }
you can easily add this into your midpost.html file.
the problem you had when inserting the Google Code in your code is the breakin's, you have to break each line in VBScript, the include file is always the best way to go as it turns your script much more accessible for later updates.
phoenixtaz13
05 September 2009, 20:50
hi.. Good day to all.... :)
how can u make ads appear only once or twice?... and if a forum topic reaches 2 or 4 pages, how can u make ads appear once or twice per page?... coz what i remember with Google adsence TOS, u can only have maximum of 3 ads displayed in a page.
balexandre
05 September 2009, 21:19
easy, instead of
if ( iForum mod 2 = 0 ) ... witch says: every time 2nd time use:
if ( iForum mod cInt( (iReplyCount + 1) / (ads2show + 1) ) = 0 ) ...
witch will say something like:
divide the number of posts by the ads to show plus 1, plus 1 so we put the ad in the middle and not at the end.
remember to add, if using the variable,
dim ads2show in the config.asp file
work:
4 replies to a post, and we want to add 2 ads:
5 / 3 = 1.666 (cInt will convert to 2 - so, every 2)
1 - post 2 - 1st reply ------------------ AD 3 - 2nd reply 4 - 3rd reply ------------------ AD 5 - 4th reply