Jump to content

TextformatterAutoAnchor


Martin Muzatko
 Share

Recommended Posts

Hello there!

I'd love to publish my first ProcessWire module.

Please let me know if you have any thoughts regarding the quality, documentation or new features you would like to see.

See Github page: https://github.com/MartinMuzatko/TextformatterAutoAnchor/

ProcessWire Module: http://modules.processwire.com/modules/textformatter-auto-anchor/

TextformatterAutoAnchor

Automatically add anchors and IDs to Headings

 

What is it doing?

This Textformatter adds an id attribute to every heading with a slug of the text. Intended for easily creating linkable sections.

Demo

Currently it is used at http://www.happy-css.com

AutoAnchor in action: http://happy-css.com/lessons/riotjs/reusable-components/

Preview can be seen on Github

Configurable Variables

Heading Selector

Determine which headings you want to have the ID + anchor Use a regex-like range or list, e.g.: 2-6 or 346.

Anchor Class

Your css classes that are attached to the anchor link.

Anchor Content

The text for your anchor. If you prefer an icon, you could also use HTML for example.

 

What are the Alternatives?

There are existing tools like Anchorific JS but its dependency is jQuery. I love to have an alternative that is PHP only.

 

Known issues

  • Anchors are placed in front of the text. This could be a future configurable setting.
  • The slug is also not configurable yet, currently it is lowercased and space is replaced with hyphens/dashes
  • Like 12
Link to comment
Share on other sites

  • 2 weeks later...

@kixe I think if modules should work under 2.7 and 3.0 without code changes they need to be without namespace.

I can confirm that adding the ProcessWire namespace to a module and trying to run it on PW 2.x results in an error.

Link to comment
Share on other sites

  • 6 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...