Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-02-03 22:36:42

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

soo_toc table of contents generator

Contains one tag, soo_toc, which will produce a linked and nested table of contents for an article, based on the article’s headings (h1, h2, etc. tags). It is similar to cbs_article_index, but with the addition of heading-level filtering, a choice of relative or absolute URLs, and nested list output.

Current version: 0.1.5 (released 2017.02.15).

Details and download.

An example of the plugin’s output can be seen here.

[Discussion started in this thread

Last edited by jsoo (2017-02-16 02:37:55)


Code is topiary

Offline

#2 2010-07-04 18:38:43

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: soo_toc table of contents generator

Hi Jeff,

emailed you a few days ago regarding this plugin from you website contact form. I have another one of my ideas for you — if you’re interested. Would be good to catch up sometime as I see you’ve been a busy bee in plugin-land.

Best regards,


Steve

Offline

#3 2010-09-02 15:55:01

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: soo_toc table of contents generator

Hi Jeff,

I like your plugin and have installed it.
But: I need a border around the “soo_toc” for my design. I using the code for “soo_toc”:

<div id="toc">
<h4>label from soo_toc</h4> 
ul-list from soo_toc
</div>

If one article has’nt in the main-content (writing-page) a h1(#) (but maybe only h1) for put it in the “soo_toc”, the css-border in <div id="toc"> is still showing a line. Because the code <div id="toc"> is outside of the “soo_toc”-Plugin. Thats not very pretty.

Its there possible to making the div inside the plugin?
Or any another Idea (e.g. for using variables)?

Thanks, Lythande

Offline

#4 2010-09-02 17:09:51

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: soo_toc table of contents generator

You can use variable and if_variable within a form or page template (not within an article body) to do this.

<txp:variable name="has_toc" value='<txp:soo_toc />' />
<txp:if_variable name="has_toc" value="">
<txp:else />
<div id="toc">
<txp:variable name="has_toc" />
</div>
</txp:if_variable>

Code is topiary

Offline

#5 2010-09-02 18:12:55

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: soo_toc table of contents generator

Much thanks, thats wonderful!

<txp:variable name="has_toc" value='<txp:soo_toc />' />

Its working, if I add the needed attributes inside of <txp:soo_toc />. :-)

Offline

#6 2012-09-23 17:38:29

alannie
Member
From: Minnesota, USA
Registered: 2005-09-15
Posts: 150

Re: soo_toc table of contents generator

Hello, I just installed soo_toc with Textpattern 4.5.1 and it doesn’t seem to be outputting anything. I’ve used this plugin on previous TXP versions with no issues. Can anyone confirm whether this plugin is compatible with 4.5.1?

Offline

#7 2012-09-24 01:12:10

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: soo_toc table of contents generator

Sheepish confession, I am a little behind on upgrading. I may not be able to look at this until next week or so.


Code is topiary

Offline

#8 2012-09-24 01:41:43

alannie
Member
From: Minnesota, USA
Registered: 2005-09-15
Posts: 150

Re: soo_toc table of contents generator

No problem, thanks for the quick response! :)

Offline

#9 2012-10-06 14:09:48

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: soo_toc table of contents generator

Having finally upgraded, I have not found any issues with soo_toc. How are you using the tag?


Code is topiary

Offline

#10 2018-06-05 07:30:00

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: soo_toc table of contents generator

This plugin still works, and I’m happy I found it. Writing/editing ToCs manually is some bad news.

Offline

#11 2020-12-23 14:38:34

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: soo_toc table of contents generator

I love the simplicity of this plugin, and it is still the best solution for in-article content lists.*

Being Soo is a bit scarce these days, I’m wondering how future-proof the plugin may be as is, but also whether it might ever see an evolution.

Here’s why I’m wondering… I want to optimize my CSS around using content lists. The plugin hard-codes ul.toc, if I’m not mistaken. But for content lists like on my policies page (and in the Txp docs now, as another example), they clearly demand using an ol list. I would even go so far as to argue that all contents lists should be ordered in web markup because whether content is a 1-2-3 process or narrative storytelling, the ideas and concepts, represented by document sections, are still conceived to following a logical flow to a desired end. Nothing random about it. Of course, in print material, the worry about structural markup is non-existing, but I don’t think it was ever really thought through for the same elements in web content; not that I’ve ever found any discussions on. Also, ‘Table of Contents’ is a rather technical label for what most of the publishing world just calls ‘Contents’, logically. While ‘toc’ make for a nice and short selector, the content element I’m labeling on the surface is ‘Contents’, so I’d like to optimize my CSS to that conceptual match.

Which brings me to the question… Can I safely modify the plugin to use ol.contents, thereby aiding my objective of tightening CSS, and forget about the plugin after that, or should I worry about plugin upgrades that would break what I undoubtedly will forget that I changed?

* Content lists for documents composed of collated articles via a pageless section are handled with etc_query.

Side

Not that I’m asking for this, but musing on the desire for the functionality to appease more tastes than my own.

I can imagine a core tag — contents or contents_list — that makes use of existing attributes and adds one more for indicating desired depth of contents list:

 <txp:contents wraptag="" class="" levels="" />

The levels="" attribute being the new one and meaning the same as the level="" attribute in soo_toc; the depth based on however the article body is structured. I typically use an h1 on titles then begin all ‘first-level’ sections in the body with h2. So a declaration of levels="3" would list headings from h2 to h4.

I currently use soo_toc as a shortcode tag this way:

<section class="contents">
  <hr class="startrule">
  <h2>Contents</h2>
  <txp:soo_toc level='<txp:if_yield name="levels"><txp:yield name="levels" /></txp:if_yield>' />
  <hr class="endrule">
</section>

And the resulting short tag:

<txp::contents levels="" />

But without the benefit of wraptag="" class="", unfortunately.

Remembering wraptag="" is optional, it’s easy to target the list with .contents ol or .contents ul, as needed, and ignore the plugin class altogether. Maybe I’ll do that at least and everyone can forget my self waste of time here. ;)

Last edited by Destry (2020-12-23 14:49:12)

Offline

#12 2020-12-23 16:26:31

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: soo_toc table of contents generator

Hi Destry!

The soo_toc tag supports wraptag and class attributes, so you can use an ordered list with any class name you prefer.

The tag also has a level attribute for assigning the upper bound (i.e., maximum of 6) of heading depth. There is no corresponding attribute for assigning a lower bound, but the plugin only looks in the article body. So if your first-level sections in the body are h2, that is what soo_toc will find, and it will render these as h2 tags.

So, to list only headings from h2 to h4, make h2 your first-level heading within the body, then set limit to 3 (correction : set limit to 4. limit matches the actual designated heading number, not the number relative to the top-level header found in the body).

Hope this helps.

Last edited by jsoo (2020-12-23 20:35:55)


Code is topiary

Offline

Board footer

Powered by FluxBB