Download the PHP package goldnead/statamic-toc without Composer

On this page you can find all versions of the php package goldnead/statamic-toc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package statamic-toc

Latest Version Statamic v3 workflow

Statamic ToC

Automatic Table Of Contents for Statamic Bard or Markdown fields or other HTML content

This addon generates a Table-Of-Contents (ToC) for any Bard- or Markdown-Field in Statamic. Just like any Antlers-Tag you can use this addon in your templates with the usual Statamic-Magic Sugar:

Sweet, isn't it?

Installation

Install via composer:

No further Vendor-Publishing or config files are needed.

Usage

This Addon provides the functionality to automatically generate an array of headings from your bard or markdown field you can iterate over in your antlers templates. Additionally, it ships with a modifier to automatically generate IDs for anchor-links.

Blueprint setup

Ideally, this addon works out-of-the-box with any bard setup. Behind the scenes it parses the given content for headlines and generates an associative nested (or unnested, see options below) array that you can iterate through. So, no special headline-sets are needed, just the plain ol' default Bard-field can be used:

Of course, you can use as many heading-buttons as you like. If you prefer to save your bard-content as HTML, you can safely turn on save_html: true in your bard-settings. You can also use this addon with your markdown-fields. Just pass it along to the tag like this:

or

The toc Modifier

Use the modifier in your templates to add IDs to your headings:

Then you get something like this:

!> Note: When headings are duplicated, the ID is suffixed with a number preventing duplicated IDs which would be semantially wrong in HTML.

The toc Tag

You can use the toc-Tag like you would use any recursive tag (like the nav Tag) in your Antler-Templates:

By default, this addon assumes your bard-content lives inside a content-field named article. To change that behaviour you can assign the name of the bard field with the parameter field:

{{ toc field="bard" }}

or alternatively you can pass the bard-content directly to the content parameter:

{{ toc :content="bard" }} or {{ toc content="{bard}" }}

If you don't want to display your ToC as a nested list you can pass the parameter is_flat which flattens your list to one level:

Variables

Every Item has the following variables at your disposal:

Variable Description
toc_title (string) The title of the heading (Note: title would be more obvious, but this lead to some weird cascade issues.)
toc_id (string) The slugified title to use as anchor-id
id (int) The internal id used to assign children and parents
is_root (bool) A flag to determine if the current heading is at root level
parent (int/null) Id of parent item if current item is a child
has_children (bool) Flag if current item has children
children (array) Contains all the Child-headings
total_children (int) Number of children (only if has_children is true)

Also, there are the following global variables present inside the toc tag:

Variable Description
total_results (int) The number of total headings including children.
no_results (bool) True if no results are present

Parameters

You can control the behaviour with the following tag-parameters:

Parameter Description (Type) Default
depth Specifies wich heading-depth the list includes (int) 3
is_flat When true the list will be displayed as a flat array without nested children (boolean) false
field The name of the bard-field. (string) "article"
content Content of the bard-structure or HTML String (string/array/null) null
from The starting point from where the list shohuld be outputted (string) h1

License

This is commercial software. To use it in production you need to purchase a license at the Statamic-Marketplace.


All versions of statamic-toc with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 | ^8.0 | ^8.1 | ^8.2
statamic/cms Version ^3.0 | ^3.1 | ^3.2 | ^3.3 | ^3.4 | ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package goldnead/statamic-toc contains the following files

Loading the files please wait ....