Forum Moderators: not2easy

Message Too Old, No Replies

Need help with placement of floating div

adsense ad positioning

         

mm1220

11:20 pm on Sep 3, 2005 (gmt 0)

10+ Year Member



Hi,

I store my articles in a text file which I include into my article page template via php.

I wish to place adsense ads in such a fashion:

ArticleArticleArticleArticleArticleArticleArticle
ArticleArticleArticleArticleArticleArticleArticle
ADSENSEADSENSE ArticleArticleArticleArticle
ADSENSEADSENSE ArticleArticleArticleArticle
ADSENSEADSENSE ArticleArticleArticleArticle
ADSENSEADSENSE ArticleArticleArticleArticle
ArticleArticleArticleArticleArticleArticleArticle
ArticleArticleArticleArticleArticleArticleArticle

I had been trying:


<div style="width:98%"> <!-- Main Body Div -->
<div style="float:left">
<!-- Adsense code goes here -->
</div>
<div>
<?php include($articleName);?>
</div>
</div>

but this only gives:

ADSENSEADSENSE ArticleArticleArticleArticle
ADSENSEADSENSE ArticleArticleArticleArticle
ADSENSEADSENSE ArticleArticleArticleArticle
ADSENSEADSENSE ArticleArticleArticleArticle
ArticleArticleArticleArticleArticleArticleArticle
ArticleArticleArticleArticleArticleArticleArticle
ArticleArticleArticleArticleArticleArticleArticle
ArticleArticleArticleArticleArticleArticleArticle

and I'd rather not use absolute positioning, any ideas?

createErrorMsg

11:41 pm on Sep 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll have to place the floating div containing the adsense at the location in the source code where you want it to appear. This way the preceeding text will sit above it, the adjacent text will sit beside it, and the subsequent text will wrap beneath it.

Unfortunately, this means interrupting the flow of your source text with a div, as in...

<p>This is the first sentence. This is the second sentence. Guess what? Third and fourth sentences here.</p>
<div id="adsense_float"></div>
<p>This is the fifth sentence. And the sixth sentence. Seventh sentence, coming at'cha. Eighth sentence right here. Ninth sentence and so on.</p>

I have never found nor seen a better option. Relative positioning will move the text but leave a hole in the page layout where it originally renders. Absolute positioning won't clear a space for the location of the code.

cEM

mm1220

12:35 am on Sep 4, 2005 (gmt 0)

10+ Year Member



Thanks for the response, that's pretty much what I expected. I had wanted to avoid that because as you can see I was including a block of text en masse and didn't want to hardcode google code into it.

What I'm doing now is using php's

explode()
function to spilt the text into an array of paragraphs an I can position the floating div wherever I want in the text then.