Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2018-03-05 21:44:58
- singaz
- Member
- Registered: 2017-03-12
- Posts: 150
Re: Google Adsense inside an article?
In your example, can work with large text. Similar to what in wordpress
Sorry my horror English. I’m learning textpattern, I’m learning English
Offline
Re: Google Adsense inside an article?
I tried etc_query for repeated fading of an advertising of newsletter and social media stuff like that
<txp:etc_query data='<txp:body />' replace="p[position() mod 10 = 1]/preceding-sibling::p[4]$=<![CDATA[<txp:output_form form='newsletter-snippet' />]]>" />
but that ended up in an Undefined array key 1 error, because of within a div embedded youtube videos. So I ended up with an updated variant of this older direct php snippet.
$text = body();
$quantity = substr_count($text, '</p>');
if ($quantity >= 13) {
variable(["name" => "splitted", "value" => "yes"]);
$parts = explode('</p>', $text);
$i = 0;
while ($i < count($parts) - 1) {
echo $parts[$i] . '</p>';
if ($i >= 10 && $i % 10 == 0 && $i + 3 < count($parts) - 1) {
echo output_form(['form' => 'newsletter-snippet']);
}
$i++;
}
} else {
echo $text;
}
So in this example the output form “newsletter-snippet” is faded in every tenth paragraph, if you have at least 13 paragraphs.
Offline