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...
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