Download the PHP package bencarr/statamic-hyperlink without Composer

On this page you can find all versions of the php package bencarr/statamic-hyperlink. 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-hyperlink

Hyperlink

Hyperlink is a Statamic addon for a turbo-charged link field that stores link text and target options alongside the destination, supports multiple links in a single field, and lets you set up reusable config-driven field settings.

Hyperlink is great for CTAs, callouts, and hero buttons, and has everything you need for a smooth author and developer experience:

Get Started

Installation

You can find and install Hyperlink from the Statamic control panel under Tools → Addons, or install from your project root using Composer.

Upgrade Guide

You can upgrade from version 1.x or 2.x to 3.x by re-requiring the package with a new version string:

That’s it! There’s no immediate changes needed to your content or templates after simply installing v3.

Updating a Field to Support Multiple Links

If you'd like to take advantage of multiple links on an existing Hyperlink field, you can update your field configuration to set the "Minimum Number of Links" and "Max Number of Links" options accordingly.

If you're using a Profile for your field configuration, you can adjust the min_items and max_items keys in your profile’s configuration array.

Once you've updated a field to support multiple links, your templates will need to be updated to account for receiving an array of hyperlinks instead of a single hyperlink. Check out the Templating section for examples.

Configuration

Add a Hyperlink field to your blueprint by selecting it from the “Relationship” or “Special” groups.

Profiles

Profiles let you re-use Hyperlink configurations across multiple blueprints. You can set up profiles in a config file, then select which profile each field should use. Future changes can be made in the profile configuration without needing to update each field’s settings.

Customizing the default profile

Start customizing profiles by publishing the hyperlink-config tag.

You can find the published configuration in config/statamic/hyperlink.php.

Adding additional profiles

Make additional profiles available by adding new keys to the profiles array.

Profile options

Each profile can be customized using the following options.

Key Type Description
types array The enabled link types
Default: ['entry', 'url', 'email', 'asset', 'term', 'tel']
collections ?array Available collections for “Entry” links. Leave blank for all collections.
Default: []
containers ?array Available containers for “Asset” links for all containers.
Default: []
taxonomies ?array Available taxonomies for “Term” links. Leave blank for all taxonomies.
Default: []
min_items int Minimum number of links authors must provide
Default: 0
max_items int Max number of links the field can accept
Default: 1

Pro Tip — You can also re-order the link type dropdown by adjusting the order of the types array in your profile. For example, to make the “Asset” option appear first, set the types property to ['asset', 'entry', 'url', 'email', 'term', 'tel'].

Field-specific settings

To bypass profiles and use a one-off configuration for a particular field, select the “Custom” profile in the field settings pane, which surfaces the same profile configuration options in the UI and saves the settings to the blueprint itself.

FYI — When using the “Custom” profile, enabled link types cannot be reordered.

Templating

Hyperlink works great with both Antlers and Blade, and has built-in conveniences to give you full control over your template markup.

Antlers

In your Antlers templates, reference the field value like any other field to return a plain hyperlink with all the necessary info. For example, if your field handle was cta:

Note — The target attribute will be added automatically when the “New window?” toggle is checked.

For maximum flexibility, you can access any of the available data from the Hyperlink field:

If your field configuration supports multiple links, treat the field value like a collection. For example, if your field handle was buttons:

Blade

In your Blade templates, reference the field value like any other field to return a plain hyperlink with all the necessary info. For example, if your field handle was cta:

Note — The target attribute will be added automatically when the “New window?” toggle is checked.

For simple markup modifications like adding a class or an attribute, you can chain class and attributes methods similar to Blade component attributes:

For maximum flexibility, you can access any of the available data from the Hyperlink field:

If your field configuration supports multiple links, treat the field value like a collection. For example, if your field handle was buttons:

Available data

The field value of a Hyperlink field is a HyperlinkData object, which works just like an array in your templates. Inside you’ve got access to everything you’ll need to completely customize your presentation:

Property Type Value
url string The full URL to the destination
text string The provided link text, or a default value based on the selected link type.
target string A target attribute string; _blank when opening in a new window
type string The chosen link type
Possible values: entry, url, email, asset, term, tel
email ?String The entered email address
Note: Only populated for “Email” links
phone ?String The entered phone number
Note: Only populated for “Phone” links
entry ?Entry The full Entry object
Note: Only populated for “Entry” links
asset ?Asset The full Asset object
Note: Only populated for “Asset” links
term ?LocalizedTerm The full LocalizedTerm object
Note: Only populated for “Term” links
newWindow bool Whether the field is set to open in a new window
link string The raw URL, mailto:/tel: string, or Statamic relationship reference

Note — When linking to a Term, Hyperlink will generate a URL to the global term view. If you’d like to link to the term in a specific collection, you’ll need to use the term property to generate that collection-specific URL in your templates.

Default Text Values

When no custom text is provided, Hyperlink will use a sensible default based on the selected link type.

Type Default
URL The hostname of the link destination (e.g. statamic.com)
Entry The selected entry’s title
Asset The selected asset’s basename
Term The selected term’s title
Email The provided email address
Phone The provided phone number

Validation

In general, Hyperlink fields require only a link value. Link text is optional, and will use a default value based on the link type if no custom text is provided (see Default Text Values above for more information). If the Hyperlink field is optional in the Blueprint, a “None” option is added to the available link types for authors to explicitly leave the field blank (and it’s the default for new entries).

Type-Specific Validation

Some link types are also validated conditionally:

Schema

Hyperlink data is stored as a simple YAML structure. For example, if your field handle ws cta:

Entry, Asset, and Term links are stored using an ID reference, so links stay up-to-date event if the related item’s URL changes:

If your field configuration supports multiple links, the YAML structure will be an array. For example, if your field handle was buttons:

Licensing

Hyperlink is a Commercial Addon.

You can use it for free while in development, but requires a license to use on a live site. Learn more or buy a license on The Statamic Marketplace!


All versions of statamic-hyperlink with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
statamic/cms Version ^5.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 bencarr/statamic-hyperlink contains the following files

Loading the files please wait ....