Skip to content

A Perch Template Filter that adds IDs to h1-h6 in a textarea field

Notifications You must be signed in to change notification settings

Pipits/pipit-anchors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Anchors Template Filter

Anchors is a Perch Template Filter that adds IDs to HTML headings h1-h6 (based on their content) in a textarea field.

Installation

  • Download the latest version of the template filter
  • Unzip the download
  • Place the PipitTemplateFilter_anchors.class.php file in the folder perch/addons/templates/filters/
  • Include the class in the file perch/addons/templates/filters.php:
include('filters/PipitTemplateFilter_anchors.class.php');

You also need to enable template filters in your config:

define('PERCH_TEMPLATE_FILTERS', true);

Usage

<perch:content id="text" type="textarea" label="Text" markdown editor="simplemde" filter="anchors">

Use case

You may have a textarea field with a Markdown editor:

<perch:content id="text" type="textarea" label="Text" markdown editor="simplemde">

You may enter a heading like so:

# This is a heading

Regular output is:

<h1>This is a heading</h1>

With the anchors template filter:

<h1 id="this-is-a-heading">This is a heading</h1>

This is useful for long blog posts and documentation as you can share links to particular section /docs/#how-to-configure.

About

A Perch Template Filter that adds IDs to h1-h6 in a textarea field

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages