placing adds in the middle of a node
udijw - April 15, 2007 - 15:50
| Project: | Adsense Injector |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
Hi,
I just love this module.
Is there a way to introduce a banner in the middle of a node something like:
%first_half_of_body<div class="ad-auto-inserted" style="float:middle; margin: 0 1em .25em 0;">[adsense:120x240:2:3]</div>%second_half_of_bodyI am not familiar with CSS so I don't know the DIVs to place for this, so this is just "pseudo code".
thanks,
Udi

#1
Sorry, no way to do it with the current version. The problem is how does one ensure that the injected ad is placed correctly inside the body, not breaking any HTML tags or other markup - this is a non-trivial issue. I think the injected ad needs to be placed outside of all HTML tags in order not to break a page's content and markup.
I'm not arguing against the feature (which I would love to have as well) but I won't implement it until I know it won't break a site's content.
Perhaps in some future release...
#2
Thanks anyhow for the great module.
#3
Sorry I can't help you right now - but please, rest assured, I am thinking about how to make this feature available... just not sure how to make it happen.
#4
This is just an idea (maybe foolish, dont be mad)
is there a way to place the block between teaser and body?
I mean the teaser has a clear ending of HTML, right - it must have one for the front page.
then you have the rest of the code.
do the code will look like
%teaser<div class="ad-auto-inserted" style="float:middle; margin: 0 1em .25em 0;">[adsense:120x240:2:3]</div>%body_without_teaserdoes it make sense?
#5
I appreciate your suggestions.
It's a nice idea. I've thought about it recently - but: I've seen Drupal end a teaser in the middle of HTML elements like blockquote, ul, etc - so, this technique probably won't guarantee anything - far from it.
All you have to do to see what I'm talking about is create a node with a single short sentence at the top then a large blockquote or ul section that goes on for 1000 characters (or whatever your default teaser length is.) The teaser is generated in the middle of the blockquote or ul section, which means... that the ad would be inserted in the middle of a blockquote or ul list - this is but one example - I could go on. The problem is that in general you should not insert the ad inside of any HTML element - it should fall outside of any markup element.
Consider the following node:
<p>This is a test node</p>
<blockquote>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque facilisis, augue at consequat vulputate, quam dolor lobortis nunc, sed consequat purus quam et ante. Donec non mauris et nulla luctus dapibus. Quisque arcu erat, rhoncus sit amet, interdum vel, tristique vestibulum, orci. Maecenas porta magna quis nisl. Curabitur lacus. Mauris ipsum. Vestibulum et massa. Morbi sollicitudin leo eu pede. Nam purus. Quisque ut elit eu tellus ultricies consequat. Nulla purus. Nulla venenatis augue vel ante. Vestibulum nisi. Donec vel est. Nullam vel dui.
Donec nunc tortor, volutpat iaculis, nonummy at, tempor vel, justo. Nam eleifend commodo tellus. Sed at sapien at dui feugiat posuere. Quisque et quam suscipit est varius pellentesque. Cras vitae quam eu ipsum vehicula porta. In consectetuer, arcu ut nonummy accumsan, eros nulla dignissim nulla, in elementum ante sem eget lectus. Praesent ut lectus sit amet pede ullamcorper iaculis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce vulputate felis quis massa. Mauris cursus, tortor sed fermentum convallis, enim erat pretium magna, ut pharetra tortor erat eu enim.
Maecenas ac sem et nulla molestie semper. Pellentesque vel dolor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam sit amet nunc id eros pretium congue. Etiam nec ligula sit amet quam facilisis lacinia. Aliquam erat volutpat. Sed odio ipsum, commodo eget, faucibus ut, rhoncus ac, mauris. Etiam pellentesque, velit vitae condimentum vehicula, tortor dolor sodales risus, vitae dictum ligula nunc ut velit. Morbi ac felis in velit dictum suscipit. Nullam ullamcorper. In mattis, mi blandit viverra tempor, orci dui consectetuer dui, ultricies eleifend arcu arcu quis felis. Sed justo lectus, lobortis imperdiet, ullamcorper eu, iaculis id, justo. Nam faucibus aliquam dolor. Donec cursus. Suspendisse id metus ut libero malesuada lobortis. Suspendisse varius aliquet neque. Sed in quam.
Nunc euismod, enim sed laoreet elementum, purus nisl venenatis tellus, in accumsan lacus arcu ac justo. Cras condimentum nibh quis sapien. Phasellus mauris massa, tempor eu, consectetuer ut, aliquet sit amet, arcu. Aliquam eget dui. Nam semper, dolor ut rhoncus consequat, eros sapien sagittis est, vel aliquam mauris dolor sed massa. Suspendisse sed mauris sed justo dictum laoreet. Proin sapien nibh, condimentum id, vestibulum ut, adipiscing ut, mi. Mauris scelerisque ultricies pede. Mauris cursus, massa sit amet sollicitudin facilisis, elit velit posuere nulla, eu imperdiet enim est in orci. Aenean pharetra libero vel ligula. Morbi lectus. Donec justo. Etiam ac lorem eget magna sollicitudin tincidunt. Suspendisse potenti. Morbi adipiscing tellus suscipit urna. Maecenas ac metus eu leo lacinia malesuada. Aenean tempus ullamcorper quam.
Nam nonummy mauris vel nisl. Integer et lectus eu lectus scelerisque fringilla. Morbi semper neque at massa. Nulla id nunc. Donec sed purus. In nec quam. Aenean vel nisi eget velit blandit pretium. Suspendisse hendrerit turpis nec turpis. Nulla tincidunt dapibus pede. Ut a magna.
</blockquote>
In my experience, Drupal's teaser generation does not look for the closing tag - it just cuts off the text at the appropriate character limit and uses that HTML snippet as a teaser.
Now, consider this node:
<p>This is a test node with long lists</p>
<ul>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Maecenas egestas ultrices lacus.</li>
<li>Fusce eget nulla in dolor scelerisque aliquet.</li>
<li>Praesent ut urna nec ligula porta faucibus.</li>
<li>Cras iaculis odio ac sapien.</li>
<li>Nam vitae augue sit amet neque placerat consectetuer.</li>
<li>Donec scelerisque sapien id pede.</li>
</ul>
<p>
</p><ul>
<li>Nam ullamcorper euismod turpis.</li>
<li>Vestibulum tempus metus id dolor.</li>
<li>Aliquam ultrices tempor ipsum.</li>
<li>Duis pretium placerat felis.</li>
<li>Phasellus quis ligula a diam porta egestas.</li>
<li>Nunc mattis tempor eros.</li>
</ul>
<p>
</p><ul>
<li>In vel dolor nec ipsum condimentum varius.</li>
<li>Mauris at diam eu quam tincidunt rutrum.</li>
<li>Mauris eu magna nec lorem pellentesque posuere.</li>
<li>Sed blandit justo porttitor mi.</li>
<li>Nullam id quam id lacus ornare ornare.</li>
<li>Ut eu eros ut lectus pretium adipiscing.</li>
<li>Etiam rutrum turpis sed velit.</li>
</ul>
<p>
</p><ul>
<li>Vestibulum euismod orci vel nisi lacinia iaculis.</li>
<li>Nullam eleifend elit eget tortor.</li>
<li>Nunc facilisis lorem in augue.</li>
<li>Integer non est sit amet est imperdiet ultricies.</li>
<li>Morbi varius commodo leo.</li>
<li>Vestibulum dignissim pede sed magna.</li>
<li>Etiam malesuada orci nec est.</li>
</ul>
In my experience, the lists will be 'hacked off' and the teaser will consist of an incomplete node.
Feel free to paste these tests into your own site and see what it does with the teaser.
Rest assured that I've been thinking about this problem for months - inserting content inside of html and ensuring that it is well-formed is a non-trivial task - and I'm not quite ready to tackle it at this time. So I'm putting this thread 'to bed' - I don't really have time to dedicate to this problem right now.
#6
i read the string of comments, I was wondering if there was a way to insert the adsense ad after a certain amount of words in the article. If the article is not long enough..just drop the last 2 adsense ads at the bottom of the page. Can this be done ???? You can still use the right and left floating div... no ???
thanks
mjh
#7
Duplicate of #141096: Inject adsense into content
THis is an interesting (and frustrating) problem. I'm investigating solutions.