Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SA Toc / Anchors Plugin
#51
Well I cant see that being a problem I mean both are essentially shortcodes, makes it confusing. Mayeb dynpages should be (% component name %) instead.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#52
Thanks for the plugin! I needed a TOC badly and would have to make the thing myself - and you not only saved me all the work, but did it much better then I would (newbie, heh).

One thing though: I think the generated list badly needs at least an arbitrary class (e.g. "sa-toc") to be styled by. Catching a noname ul on a page that might have more than that one is a bit...tricky.
Reply
#53
Shawn: did you have a look at Mvlcek's pagify 1.1 ?
Would it be possible to adjust toc plugin to work with pagify ?

ps. is it possible to disable toc on certain pages ?
I still haven't solved the problem with i18n_search serp showing pages that call toc plugin at the beginning.
Addons: blue business theme, Online Visitors, Notepad
Reply
#54
https://github.com/tablatronix/sa_toc_an...gin/issues
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#55
I am enjoying the use of the SA TOC plugin. However, has there been any improvement on it's use within a sidebar or component?

I'm new to PHP and can read my way through the code, but have not figured out a way to create a global that stores the TOC content and allows it to be read/parsed in any part of a dynamic page.

Any advise on how to make it work would be appreciated.

As an alternative, I am attempting a floating fixed <div> containing the TOC. The trick is having the text content wrap around the floating <div>. Any tips on this workaround would also be appreciated.
Reply
#56
There seems to be a small bug with detecting the indentation level in the TOC. (Either that, or I am not using the plugin correctlySad).
When the body of the page in which I use SA_Toc has the following succession of headers
H2 H3 H2 H3 H4 H3, I observe the following indentation (the last H3 is indented like the H2s)
H2
 H3
H2
 H3
  H4
H3 (this one is indented as H2)
I have tried this by interspersing those headings with (and without) body text, in various combinations.
There are also problems when heading levels are missing, but it may not be best practice to do that (I disagree, though).

macOS 10.12.5, GS 3.3.13 on a proper server (not localhost/myMac.local of MAMP)
Code:
<div id="tocBox" style="float:right;width:40%;margin-right:0;margin-left:4px;padding:2px; border-width:1px; border-radius:5px;border-color:#CCC;">
    <div style="padding:2px 0 0 3px"><b>TOC</b></div>
    <hr style="background:#CCC;" />
    <div style="padding:0 3px 0 2px;"><b>(% sa_toc %)</b></div>
</div>

<h2>h2</h2><p>hoho</p>
  <h3>h3</h3><p>hihi</p>
  <h3>h3</h3><p>okok</p>
<h2>h2</h2><p>moreok</p>
  <h3>h3</h3><p>blehbleh</p>
   <h4>h4</h4><p>(the anomaly comes next)</p>
<h2>h2</h2><p>bla</p>
  <h3>h3</h3><p>bla</p>
[size=small]
<h2>h2</h2><p>(here is another one:)</p>[/size]

   <h4>h4</h4><p>blablabla</p>
<h1>h1</h1><p>(here is yet another one:)</p>
<h2>h2</h2><p>blablabla</p>
I think I removed all styling that could interfere with dotted lists, divs. (In the above, I used some indentation to sort of suggest what I would expect to happen in the actual rendering).

Can anyone reproduce this problem?
Reply
#57
Ill take a look,

what do you mean by "when header levels are missing" , like H1,H3 etc?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#58
you do realize that the plugin only indents ascenders, not descenders ?
Did you read the docs on my site ?

try abs mode
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#59
Hello,
I have 120 pages. I want to automatically add "table of content" before the first <h2>. Is there any way to include it in that position? The somewhat difficult thing by modifying the php "sa_toc_anchors.php"?
thank you, excuse my english.
Reply
#60
On PHP 8 the plugin gives an error
Code:
Fatal error: Uncaught Error: Call to undefined function create_function() in D:\OSPanel\domains\gsphp8.ia\plugins\sa_toc_anchors.php:45 Stack trace: #0 D:\OSPanel\domains\gsphp8.ia\admin\inc\plugin_functions.php(108): require_once() #1 D:\OSPanel\domains\gsphp8.ia\admin\inc\common.php(348): include_once('D:\\OSPanel\\doma...') #2 D:\OSPanel\domains\gsphp8.ia\admin\plugins.php(15): include('D:\\OSPanel\\doma...') #3 {main} thrown in D:\OSPanel\domains\gsphp8.ia\plugins\sa_toc_anchors.php on line 45
Reply
#61
lines from 44 to 54 I replaced with this and it seems to work
Code:
$allowargs = array(
  'depth' => function($input) {return filter_var(intval($input), FILTER_VALIDATE_INT, array(1,6));},
  'class' => function($input) {return filter_var($input, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);},
  'asc'   => function($input) {return true;},
  'abs'   => function($input) {return true;},
  'ul'    => function($input) {return true;},
  'ol'    => function($input) {return true;},
  'notoc' => function($input) {return true;},
  'debug' => function($input) {return true;},
  'demo'  => function($input) {return true;},
);
but the use of classes for headers had to be abandoned, since such a warning appears
Code:
Deprecated: preg_replace(): Passing null to parameter #2 ($replacement) of type array|string is deprecated in D:\OSPanel\domains\gsphp8.ia\plugins\sa_toc_anchors.php on line 71
Reply
#62
(2023-01-20, 21:11:50)Oleg06 Wrote: lines from 44 to 54 I replaced with this and it seems to work

);
but the use of classes for headers had to be abandoned, since such a warning appears


I tried to install it in GS 3.3.18 and could not call the page or login after that. I had to remove it manually via Filezilla to get my page back.

Will there be an updated version of this plugin?
Reply
#63
(2023-05-09, 17:05:50)Hypertexter Wrote:
(2023-01-20, 21:11:50)Oleg06 Wrote: lines from 44 to 54 I replaced with this and it seems to work

);
but the use of classes for headers had to be abandoned, since such a warning appears


I tried to install it in GS 3.3.18 and could not call the page or login after that. I had to remove it manually via Filezilla to get my page back.

Will there be an updated version of this plugin?

Take this, now works ok on php 8.x and 3.3.18
https://github.com/GetSimpleCMS-CE-plugi...s/main.zip

or Plugins CE repo 
https://getsimplecms-ce-plugins.github.io/
Reply
#64
Quote:Take this, now works ok on php 8.x and 3.3.18

https://github.com/GetSimpleCMS-CE-plugi...s/main.zip



Cool.

The documentation on Shawn's page is not available at the moment, so this is what I found out in this forum about the use of this plugin:

Inserting a
Code:
<p>(% sa_toc depth=2 %)</p>

makes a nice toc of the first and second level headlines on the current page.

Thank you!
Reply
#65
Oh. I tried to format the TOC with a CSS class:

Code:
.sa_toc {
background: #eee;
border: 1px solid #ccc;
padding: 5px 5px;
}

and with

Code:
<p class="sa_toc">(% sa_toc depth=2 %)</p>

on the page. But there is no reaction, the format is not used for TOC.

Does anybody find my error?
Reply
#66
Hi, this plugin seems to be really nice.
But has anyone found a way to include it automatically on every page, i.e. in the template?

By the way, here is a backup of Shawn's documentation in the wayback machine:
https://web.archive.org/web/201906200432...oc-plugin/
Perhaps there is a way to add this to the forum, if it is still correct.


Edit:

Ok, here is what I did to insert the ToC automatically.

I messed around in the plugin's source and prependend the existing filter with another one. The new filter prepends the content with a home div for the ToC tag.
Then comes the existing filter and builds the ToC there.

So here is the original version:
PHP Code:
# activate filter 
add_filter('content','add_toc'); 

and I replaced this with:

PHP Code:
# prepend trigger div
add_filter('content''prepend_toc_div');

function 
prepend_toc_div($contents) {
 
$toc_div '<div class="sa_toc_div" id="sa_toc_div" style="float:right;">(% sa_toc depth=2 %)</div>';
 return 
$toc_div.$contents;
}

# activate filter 
add_filter('content','add_toc'); 

This way, the ToC will always per default reside on the right top corner of the content area.

And now,
  • you can style the ToC and it's contents with a .sa_toc_div css class,
  • or grab it via javascript as #sa_toc_div, and put it somewhere else in den DOM ...
Enjoy!
Reply
#67
Sad 
Quote:By the way, here is a backup of Shawn's documentation in the wayback machine:
https://web.archive.org/web/201906200432...oc-plugin/
Perhaps there is a way to add this to the forum, if it is still correct.

Thank you @Knobbles. I made a PDF from it, but I cannot upload it since there seems to be an "attachment quota" of 500KB in this forum. Undecided
Reply




Users browsing this thread: 2 Guest(s)