WordPress.org

Ready to get started?Download WordPress

Forums

Table of Contents Plus
[resolved] Widget isn't showing up (22 posts)

  1. drdamour
    Member
    Posted 1 year ago #

    trying to use this plugin, works fine when injecting it into article, but is failing to work when using it as a widget. The HTML dom doesn't show that widget li element. tried a couple different themes. No error in logs. anyone have a similar problem?

    http://wordpress.org/extend/plugins/table-of-contents-plus/

  2. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Which themes have you tried? I'd like to see if I can replicate the problem.

  3. drdamour
    Member
    Posted 1 year ago #

    i tried twenty-eleven

  4. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    That's crazy strange. Do you have at least the minimum number of headings? Are you using any special character sets or just plain ascii?

  5. drdamour
    Member
    Posted 1 year ago #

    ok let me clarify.
    twenty eleven is bad test case cause it doesn't have a sidebar for single.php

    i'be been using bloxy two

    yes i'm sure i have the minimum number of headings because it displays fine in the post content. should be plain ascii or whatever the default is.

    i'm happy to try another theme if you want to get a basic reference test.

  6. drdamour
    Member
    Posted 1 year ago #

    just switched to coraline, doesn't work there either.

    to recap:
    TOC shows fine in post body if widget is there or not
    set widget to only show widget, TOC does not appear in post body
    widget never appears

  7. drdamour
    Member
    Posted 1 year ago #

    another bug

    if i add the widget, check the only show as widget option, then delete the widget, the TOC doesn't appear for any articles (post or pages). I then need to add the widget back to get the toc to appear in the post body, and as long as i don't check the only show option the body continues to show the TOC.

    clearly the option is persisted across the widget's lifespan. adding the widget again resets the option.

  8. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    That's concerning that it's not appearing in the sidebar when you add the widget. It definitely does for me with Twenty Eleven (using one of the footer widgets). I'll give Coraline a try.

    What other plugins have you got enabled?

    The other bug is a known issue and was identified in the release note when the widget made its first appearance. Haven't found a good way to unset it on widget removal yet.

  9. drdamour
    Member
    Posted 1 year ago #

    during my tests it is the only enabled plug-in
    I've also made it the only widget

    in twenty eleven it doesn't appear in footer either for me.

  10. drdamour
    Member
    Posted 1 year ago #

    this is a multisite, and my blog isn't the main site.

  11. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Nothing out of the ordinary. I use it in prod on multisite installs ok.

    Are you able to send me the content you use as your test?

    Are you using linux? Apache/nginx? Which version of PHP?

  12. drdamour
    Member
    Posted 1 year ago #

    running on ubuntu
    apache 2. something
    php 5.3.18

    the dead simplest test exhibits the problem

    <h2>header 1</h2>
    lorem
    <h2>header 2</h2>
    lorem
    <h2>header 3</h2>
    epsum
    <h2>header 4</h2>
    epsum
  13. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Architecture looks normal. I just tried Coraline and it's ok for me.

    Does any other type of widget work?
    Do you have anything in wp-content/mu-plugins?

  14. drdamour
    Member
    Posted 1 year ago #

    all the basic widgets work fine
    there is no mu-plugins folder
    is there a debug mode or something i can turn on, or logging of some sort?

  15. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    You can add the following into your wp-config.php file but I'm not sure if it'll give you anything useful with TOC+

    define('WP_DEBUG', true);

    I have it enabled on my platform to ensure there are no warnings/notices, etc.

    I'm out of ideas as to what could be causing it. If I was in this situation, I would be editing toc.php to see what is going on. If you want to try, I would concentrate on the following area:

    function widget( $args, $instance )

  16. drdamour
    Member
    Posted 1 year ago #

    so here's the problem.
    the widget happens before certain processing takes place. That processing is putting in newlines into the content string

    so for the widget, the regular expression is matching against one line of text, thus only finding one h2 tag for the entire doc, where the post body it's finding a bunch cause they are all newlined out.

  17. drdamour
    Member
    Posted 1 year ago #

    fyi: i fixed it by making it ungreedy on the .*

    from:

    preg_match_all('/(<h([1-6]{1})[^>]*>).*<\/h\2>/', $content, $matches, PREG_SET_ORDER)

    to:

    preg_match_all('/(<h([1-6]{1})[^>]*>).*?<\/h\2>/', $content, $matches, PREG_SET_ORDER)

    per: http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php

  18. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    Nice work! Works well for my tests so far.

    I was able to replicate the issue after putting multiple headings on the same line. I normally have headings on separate lines but this will make it more robust.

    I'll put it into the next release (probably use the /U switch so it does it globally rather than temporarily).

  19. drdamour
    Member
    Posted 1 year ago #

    /U might be more expensive, but may not matter at all. not really sure, a performance test harness would help a lot there.

    I use windows live writer to generate my posts and it flattens everything to a single line in XHTML mode so that was the culprit.

    I probably should start another thread, but is there a way to enable TOC in the post body on the front page but disable it (widget only) for single article views?

  20. Mike
    Member
    Plugin Author

    Posted 1 year ago #

    The only way to do that is to get your hands dirty with PHP. You'll need to add one or two if statements (eg is_home() || is_front_page()) to is_eligible and probably the widget functions. The alternative is to edit your theme and trigger the TOC+ functions at the desired spots.

  21. astrakub
    Member
    Posted 1 year ago #

    Hello,

    I have a problem : the widget is only displayed if the TOC is enabled in the post...

    I cannot make my hands dirty with PHP, because I do not know PHP... And more, I apologize, I am French, not too much English fluent :-(

    My theme is generated by WordPressthemeshock, I have a lot of plugins and I use WP 3.5.

    Can you help me ?

    Thanks in advance,

    Jean-Louis

    http://www.vegetarisme-et-sante.fr

  22. astrakub
    Member
    Posted 1 year ago #

    Hello,

    I deleted 3 plugins, already deactivated, and now the display in the widget only is OK...

    Don't ask me why !

    Jean-Louis

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.