fromholdio/silverstripe-globalanchors

A SilverStripe module that allows developers to define a static list of global html anchors - #nav, #content, etc - allowing them to be used for constructing links and etc by CMS users.

Installs: 397

Dependents: 3

Suggesters: 1

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Type:silverstripe-vendormodule

1.0.2 2020-08-05 16:32 UTC

This package is auto-updated.

Last update: 2021-08-05 19:02:16 UTC


README

A SilverStripe module that allows developers to define a static list of global html anchors - #nav, #content, etc - allowing them to be used for constructing links and etc by CMS users.

Intended to work inconjunction with modules that allow users to build links, or extending the create link functions in WYSIWYG editor, making global anchors available for link construction rather than only anchors within that content area.

Requirements

SilverStripe 4

Installation

composer require fromholdio/silverstripe-globalanchors

No anchors are setup by default - to complete the install, you need to setup your anchors config:

Fromholdio\GlobalAnchors\GlobalAnchors:
  anchors:
    nav: 'Main Navigation'
    content: 'Page Content'
    footer: 'Footer'

Usage example

Documentation will be forthcoming, but also, it's just one class and pretty lean. Check the class itself to see all options at the moment.

Key uses are below:

Use to fuel values in a dropdown

DropdownField::create(
    'GlobalAnchorKey',
    'Global Anchor',
    GlobalAnchors::get_anchors()
);

Get anchor title from saved key

$key = $this->GlobalAnchorKey;
$anchorTitle = GlobalAnchors::get_anchor_title($key);