• Resolved sel

    (@glashsix)


    Hi,

    I’d need some help with paragraph counting.

    What I need to do is count the following tags as paragraphs: p, figure, img, div…

    But I don’t want to count divs that have the class ‘code-block’ or other class I define. Please note, that I’d like to keep the wrapping of the blocks with the divs and the numbered code-block classes.

    In the first section, where I set Count “from top” and set the tags… and then there is the ‘and “do not contain” : ‘… I tried to set up fill ‘code-block’… But this “do not contain” setting only seems to check for text inside the tag, not for attributes.

    I understand, that there is also a setting that allows to not count inside tags with certain text or attributes like classes, but as far as I understand and tested, this only disables the counting inside the tag, while still count’s the tag itself.

    Could you please give some advice how to only ignore = not count divs with a class and keep counting the other divs and don’t count inside divs?

    Thanks for the help and the plugin!
    Bests

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Spacetime

    (@spacetime)

    Hello,

    specify the tags for paragraph counting and then define “Do not contain” texts.
    It should check the complete paragraph from the opening tag to the closing tag.

    https://adinserter.pro/documentation/paragraph-settings#counting

    If you still have issues:
    https://www.ads-software.com/support/topic/ad-inserter-support-forum-before-you-ask-for-help/

    Thread Starter sel

    (@glashsix)

    Hi @spacetime,

    thanks for the answer. Does “Do not contain” also check the tag attributes like classes and ids? Because that’s the condition I need to check.

    I checked the documentation and I don’t think this is clear in the documentation.

    The plugin seems to work correctly I just need to figure out whether it is possible to count divs, but not divs with certain classes.

    This is not a bug neither an error, it’s rather a question / feature request.

    Thanks!
    Bests

    Plugin Author Spacetime

    (@spacetime)

    Yes, paragraph attributes should also be checked.

    Thread Starter sel

    (@glashsix)

    Thank You, I’ll test one more time with this in mind ??

    Bests

    Thread Starter sel

    (@glashsix)

    Hi @spacetime,

    I’d just like to give some feedback because the settings don’t work as I need them to and I can’t achieve my intended outcome.

    What I need to do is count divs, but don’t count ad-inserter’s own divs that have the “code-block” class and I can’t achieve this.

    What I tried was:

    1. Count “from top” paragraphs with tags “p, figure, img, div” that have between “empty” and “empty” words and “do not contain” “code-block”… Outcome: This doesn’t work and ad-inserter still count’s the divs with the class “code-block” as any other div… It doesn’t seem to exclude divs based on classes that match the text inserted inside the text field
    2. Same settings, but set minimum number of words to 1 like this: that have between “1” and “empty”… Outcome: This would work but only if the other divs would contain at least one word and I cannot guarantee that
    3. Same settings as in the 1st option, but setting: and “do not contain” “Advertisement”… Outcome: I also inserted in each ad-inserter block content the text “Advertisement” but it did not ignore the blocks at all, maybe because I don’t count inside divs of divs… so this is not an option either

    Any suggestions please? Currently the only option I have is changing my divs that I need to count to something else like section tags but that’s not entirely the nicest solution…

    Could you please explain why the 1st option doesn’t work? According to your answer yesterday it should

    Really appreciate the help!
    Thanks!
    Bests

    Plugin Author Spacetime

    (@spacetime)

    You did not provide any data so we can’t check it.

    Make sure the divs with code-block class are not inserter AFTER you check them.
    The bloks are normally inserted according to the block number order.

    For each block insertion the post content (with previously inserted blocks) is checked for insertion positions – according to the block settings.

    The plugin works as described – however, the actual insertions depend on your installation and plugin settings.

    Thread Starter sel

    (@glashsix)

    @spacetime

    Thanks for the reply. I cannot share the website nor give access to it for debugging. Ofcourse I understand this makes it really hard to know, if something is behaving differently because of all our other functionality.
    Still I really appreciate the help.

    I checked if the issue is the order in which the blocks are inserted but found no evidence that this could be an issue.

    Just wanted to let you know, that after some manual debugging ( latest version of AI, latest version of WP, using block editor) in the plugins code.. I noticed that if I print out the $content on line 7048 in class.php, I get the following output:

    <p>Lorem ipsum...</p><div class='code-block code-block-9' style='clear: both;'>
    <section class='ai-debug-block ai-debug-default'>
    <section class='ai-debug-bar ai-debug-default '><kbd class="ai-debug-invisible">[AI]</kbd><kbd class='ai-debug-text-left' title=''>9 &nbsp; Mobile - ad after 1. p. = interscroller<kbd data-separator=" - " class="ai-option-name"></kbd></kbd><kbd class='ai-debug-text-center'>&nbsp;<kbd class="ai-debug-name ai-main"></kbd>&nbsp;</kbd><kbd class='ai-debug-text-right' title='Counters: C= Content,  N = Block'> C=1 N=1</kbd><kbd class="ai-debug-invisible">[/AI]</kbd></section>
    <div class='ai-code'>
    <div id="inventory_container_mob_article_after_5_paragraph"></div>
    </div>
    </section>
    </div>

    Here you can see, that on that line at that point, the divs with “code-block” class are present in the content… But after I try to print out the $paragraph_code on line 7126 in class.php each time a paragraph is checked, these are the first 2 codes I see that are checked.

    1st:
    <p>Lorem ipsum...</p>

    2nd:

    
    </section>
    </div>

    Notice that the 2nd $paragraph_code should contain the divs with the “code-block” classes but it does not…

    Because of this I tried to change the “Do not contain” text to “/section” because this is the only string that is present when the plugin is looking for the text in the paragraph…

    And now the div is correctly NOT counted.

    So indeed the class text exclusion works it’s just that the plugin doesn’t see the whole code as I was expecting.

    Thanks
    Bests

    Plugin Author Spacetime

    (@spacetime)

    The section tags are inserted only for debugging purposes – to label blocks.

    In order to diagnose the issue you have I would need to debug your website, check plugin settings and the insertion log. For this the website address (with remote debugging enabled) is needed.
    Without this I can’t help much.

    The plugin sees the post content as provided via WP filter hook the_content.
    https://adinserter.pro/faq/how-ad-inserter-works

    Of course, this applies to the server-side insertions.
    Please note that whatever you insert client-side it is not “visible” when the page is created (server-side).

    I would suggest you to pause all blocks and then enable one by one starting from block 1 to see when the issue appears.
    This may give you a hint why the unwanted insertions occur.

    You can also try to use the clearance options to avoid unwanted insertions:
    https://adinserter.pro/documentation/paragraph-settings#clearance

    Thread Starter sel

    (@glashsix)

    @spacetime Great point with the /section I forgot that I was testing this while the block labels where enabled.

    I’ll follow your instructions and try to find the cause.

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to count divs but don’t count divs with a class’ is closed to new replies.