We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22797
    • 134 Posts
    It probably has to do with a setting in your php.ini file that limits the amount of "backtracking" that is allowed. I’m not an expert in this setting, but I do know that we had a similar problem with long pages on one of our servers and we had to increase the "pcre.backtrack_limit" setting. Here’s the part of the php.ini file that refers to that setting:
    [Pcre]
    ;PCRE library backtracking limit.
    pcre.backtrack_limit=800000 
    ; Note: the default is 100000
    
    ;PCRE library recursion limit.
    ;Please note that if you set this value to a high number you may consume all
    ;the available process stack and eventually crash PHP (due to reaching the
    ;stack size limit imposed by the Operating System).
    

    I don’t know if 800000 is the best value or not in terms of safety (note the warning for the recursion limit that was included in the original php.ini file), but I haven’t had any problems with it. It may depend on your server’s memory. But increasing the backtrack_limit does work, at least on the servers I’ve tested it on, which were running either Linux or Mac OSX.

    If you don’t have access to the php.ini file, I’m not sure what else can be done. Some server configurations allow for subsite-specific php initiation files that override the main php.ini file, but you’ll have to investigate your options as far as that goes.
      • 6892
      • 7 Posts
      Thank you paulb, that did the trick  smiley

      I’m learning PHP, but must admit that I haven’t got a clue what is happening here. When I checked my php.ini file (was accessible through the control panel of my hosting company), there wasn’t a pcre.backtrack_limit defined in there at all. I simply inserted all the code you suggested, saved the php.ini file, and the problem was solved. Great!

      I did some searching and found 2 links that may be relevant/of interest to anyone else:
      http://bugs.php.net/bug.php?id=36983 and http://bugs.php.net/bug.php?id=40846.

      Thanks again for your help!

        • 5706
        • 0 Posts
        Quote from: astrolabe at Dec 03, 2007, 01:54 AM

        Hello,

        Thank you for this script. But for me, the differents tags are not interpeted by Modx.

        Exemple in a page content, Iput this HTML code :

        <!--#toc_plugin#_START_CONFIGURATION-->
        <!--#toc_plugin#_list_type=ul-->
        <!--#toc_plugin#_start_level=2-->
        <!--#toc_plugin#_end_level=3-->
        <!--#toc_plugin#_header=Page Contents-->
        <!--#toc_plugin#_header_tag=h2-->
        <!--#toc_plugin#_parent_tag=div-->
        <!--#toc_plugin#_parent_tag_id=toc-->
        <!--#toc_plugin#_END_CONFIGURATION-->

        <!--#toc_plugin#_TOC_OUTPUT-->

        <!--#toc_plugin#_START_TOC_INDEXING-->
        <h2>Here is a heading</h2>
        <p>Here is some text</p>
        <h2>Here is another heading</h2>
        <h3>Here is a subheading</h3>
        <h3>Here is another subheading</h3>
        <!--#toc_plugin#_END_TOC_INDEXING-->


        And in an other div on my page, i put :
        <!--#toc_plugin#_TOC_OUTPUT-->

        But absolutely nothing appear ! And the plugin is properly configured with OnWebPagePrerender.

        The tag are not interpreted and appear as comment in the source code.

        Help... tongue



        Howdy,

        Okay I know this was sometime ago but the problem, which I have also come across, is that there’s a bug in the code (I’m using latest 0.9.2).

        At line #313 it says:
        $source = str_replace($open_param.$start_config_marker.$close_param, $display_content, $source);

        which means that the Start Config Marker "<!--#toc_plugin#_START_CONFIGURATION-->" gets replaced with the new TOC content $display_content in the source for the resource.

        This line should be:
        $source = str_replace($open_param.$start_config_marker.$close_param, '', $source);

        This removes the Start Config Marker from the $source the same as the End Config Marker.

        And line #323 should be changed from:
        $source = str_replace($open_param.$output_marker.$close_param, '', $source);

        to
        $source = str_replace($open_param.$output_marker.$close_param, $display_content, $source);

        This will make the Output Marker "<!--#toc_plugin#_TOC_OUTPUT-->" get replaced by the TOC content in $display_content

        Hope this helps. Although perhaps people are using something different now days.

        There’s also another little gotcha (not sure if I could call it a bug). But with the version 0.9.2 if you don’t specify a TOC Heading then it uses a default of "Page Contents" and if you don’t specify a TOC Header Tag then that defaults to "<h2>". Now if you don’t want to have a heading for the TOC (as in nothing put in the source) then, looking at the code, you’d expect that the code at line #121 would let you do this by specifying a "#toc_plugin#_header_tag=’’" in the configuration. Unfortunately this results in the $toc_heading_tag getting set to the default "<h2>" by the code in line #79. So you can’t stop the TOC Heading being created. To get around this I just changed the default for the toc_heading_text to ’’ on line #34 and changed line #121 to check $toc_heading_text instead like so:
        Line #34: $default_toc_heading_text = ''; // The text of the heading above the table of contents

        Line #121 if ($toc_heading_text!='')

        So now if you don’t specify a TOC Header Text in the configuration then no TOC Heading gets added to the source. And specifying only the TOC Header Text results in a "<h2>" TOC heading with the text.

        Cheers
        Julz
          • 44427
          • 7 Posts
          Hi All,
          Is there any limitation of header in the contents table for this plugin?I am having a problem.This plugin is working good in all pages.But for a particular page it does not work.I have debug it and see that contents of this page was much higher than other pages.I have remove some text from this page and seems that this plugin is working.