Project:Content Injector (formerly AdSense Injector)
Version:6.x-3.1
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hello,
Please excuse me because this is quite off topic, but I don't know where to ask this.
It's really simple!
in the xpath Expression you write:
/html/body/p[3]

instead of p, paragraph, I'd like to use the br tag, that define a new line.
I tried to modify the string in:
/html/body/br[4]
but adsense is disappear, so I think I'm making a mistake.
can you give me the exact string for the br?
Thank you.

Comments

#1

Actually, this is a very good question.

One thing to be aware of: the rendered HTML for any given node will depend on the input filters being used for the node.

My first question: what does the node's rendered HTML look like? Can you post a HTML snippet? (Just the node body section, please!)

Note to self: I need to document the xPath stuff, or provide 'shortcuts' that allow you to specify common patterns without resorting to using raw xPath expressions.

#2

Ok, this is a piece of source from a webpage, I'm logged as admin so you will see add disabled.
the ads will appear after two paragraph, because I put p[2] instead of 3.

#3

sorry, I will reply tomorrow because I must understand what's happening with filters on my site. sometime I see <br>, other time <br />, so I assume filters are the key.

#4

The built-in line break converter input filter has had a number of issues reported, specifically about interactions with <p>...</p> blocks. In my tests (on Drupal 7), some hand-entered br tags get converted to <p>...</p> blocks and others are left as-is. In any case, just beware that line breaks / br conversion issues may gum up the works rather badly.

For example, the following source text:

Ex facilisi illum jugis neque. Brevitas elit eum facilisis lobortis occuro paratus suscipit ulciscor utrum. Commoveo gilvus persto. Et exputo macto pagus quadrum quidem te utrum uxor. Lobortis magna pertineo. Jus ludus sit. Commoveo duis eligo nimis praesent quis volutpat. Nimis scisco torqueo vulpes.

line break 1 <br/>
line break 2<br/>
line break 3<br/>

Cogo fere inhibeo loquor paulatim quidne turpis. Adipiscing meus odio paratus saepius typicus ullamcorper. Amet antehabeo augue et ibidem iustum mauris melior olim. Hendrerit jus populus qui ratis ullamcorper ut valetudo. Ea esca eu haero ibidem ideo meus nimis tincidunt. Abico aptent eu gravis populus.

Is converted to:

<p>Ex facilisi illum jugis neque. Brevitas elit eum facilisis lobortis occuro paratus suscipit ulciscor utrum. Commoveo gilvus persto. Et exputo macto pagus quadrum quidem te utrum uxor. Lobortis magna pertineo. Jus ludus sit. Commoveo duis eligo nimis praesent quis volutpat. Nimis scisco torqueo vulpes.</p>
<p></p>
<p>line break 1 <br>
line break 2<br>
line break 3</p>

<p>Cogo fere inhibeo loquor paulatim quidne turpis. Adipiscing meus odio paratus saepius typicus ullamcorper. Amet antehabeo augue et ibidem iustum mauris melior olim. Hendrerit jus populus qui ratis ullamcorper ut valetudo. Ea esca eu haero ibidem ideo meus nimis tincidunt. Abico aptent eu gravis populus.</p>

So, as you can see, the HTML filter / line break converter has done a rather nasty thing: it's put <p>...</p> blocks around the <br/> tags, and it's changed my self-closing, syntactically-correct XHTML <br/> tags into <br> (it's removed the self-closing '/' from the br tags.) Which means the xPath expression /html/body/br[4] won't work, because it's looking for the fourth <br> tag at the root level of the DOM. The xPath expression that might work given the mangled HTML output: /html/body/p/br[4] -- which says: find the fourth BR tag nested within top-level P elements (I'd need to verify this) -- and even that may not be what you want.

For more on the line break converter problems, see:
#653988: Line break filter corrupts existing XHTML
#659580: Specify what the line break converter should do and rewrite it in DOM

More: Core Issues: Line Break

And: Core Issues: Line Break Paragraphs

Is there a reason why you are trying to trigger insertion on <br/> tags?

(BTW, I expected DOM-based insertion would open a can of worms. This may be the tip of the iceberg, so hold on to your life jackets.)

nobody click here