Download the PHP package sebastianlenz/linkfield without Composer

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

Link field plugin for Craft

This plugin adds a new link field type to the Craft CMS. The link field allows content editors to choose from a list of link types and offers individual input fields for each of them.

Requirements

This plugin requires Craft CMS 4.0.0 or later.

Installation

The plugin can be installed from the integrated plugin store by searching for "Typed Link Field" or using Composer:

  1. Open your terminal and navigate to your Craft project:

    cd /path/to/project

  2. Then tell Composer to load the plugin:

    composer require sebastianlenz/linkfield

  3. Finally, install and enable the plugin:

    ./craft plugin/install typedlinkfield ./craft plugin/enable typedlinkfield

Usage

After the plugin has been installed, link fields can be created using the field settings within the control panel. All field settings can be found within the field manager.

Templating

Link fields can be rendered directly in Twig, they return the url the link is pointing to, or an empty string if they are unset:

The field value is actually an instance of lenz\linkfield\models\Link which exposes additional properties and methods that can be used in templates. Depending on the link type, a more specific subclass will be returned.

Render methods

getLink($attributesOrText = null)

Renders a full html link using the attribute and content data of the field.

To modify the inner text of the link tag, the desired content can be passed:

To modify the attributes of the link, an object can be passed. The special attribute text will be used as the inner text.

getLinkAttributes($extraAttributes = null)

Renders only the link attributes. Attributes can be modified or appended by passing an object to the first argument.

getRawLinkAttributes($extraAttributes = null)

Returns the attributes of the link as an array. Can be used in junction with the attr or tag helpers exposed by Craft.

Helper methods

getAllowCustomText()

Returns whether the field allows users to enter custom texts.

getAllowTarget()

Returns whether the field shows the option for opening links in a new window.

getAriaLabel()

Returns the aria label of the link.

getCustomText($fallbackText = '')

Returns the custom text of the link. The first non-empty text from the following possibilities will be picked:

  1. Custom text of the link.
  2. Default text defined in the field settings.
  3. Fallback text as passed to the function.

getDefaultText()

Returns the default text set in the link field settings of this link.

getElement($ignoreStatus = false)

Returns the linked element (entry, asset, etc.) or NULL if no element is linked.

By default, only published elements are returned. Set $ignoreStatus to TRUE to retrieve unpublished elements.

getEnableAriaLabel()

Returns whether the field allows users to enter aria labels.

getEnableTitle()

Returns whether the field allows users to enter link titles.

getIntrinsicText()

Returns the text that is declared by the link itself (e.g. the title of the linked entry or asset).

getIntrinsicUrl()

Returns the url that is declared by the link itself (e.g. the url of the linked entry or asset). Custom queries or hashes are taken into account and will be appended to the result.

getTarget()

Returns the link target (e.g. _blank).

getText($fallbackText = "Learn More")

Returns the link text. The first non-empty text from the following possibilities will be picked:

  1. Custom text of the link.
  2. Intrinsic text defined by the linked element.
  3. Default text defined in the field settings.
  4. Fallback text as passed to the function.

getType()

Returns a string that indicates the type of the link. The plugin ships with the following link types: asset, category, custom, email, entry, site, tel, url and user.

getUrl($options = null)

Returns the url of the link.

Allows the link to be modified by overwriting url attributes as returned by the php function parse_url. The following options are supported: fragment, host, pass, path, port, query, scheme and user.

This example enforces the https scheme and replaces all query parameters of the original url:

hasElement($ignoreStatus = false)

Returns whether the link points to an element (e.g. entry or asset).

isEmpty()

Returns whether the link is empty. An empty link is a link that has no url.

Properties

The properties generally expose the raw underlying data of the link.

ariaLabel

The aria label as entered in th cp.

customText

The custom text as entered in th cp.

target

The link target as text. Can be either _blank or an empty string.

title

The title as entered in th cp.

Eager-Loading

Link fields can be eager-loaded using Crafts with query parameter. Eager-loading can greatly improve the performance when fetching many entries, e.g. when rendering menus.

API

You can register additional link types by listening to the EVENT_REGISTER_LINK_TYPES event of the plugin. If you just want to add another element type, you can do it like this in your module:

Each link type must have an unique name and a definition object extending lenz\linkfield\models\LinkType. Take a look at the bundled link types ElementLinkType and InputLinkType to get an idea of how to write your own link type definitions.

Remarks

Upgrading from Fruit Link It

If wish to migrate a field created using "Fruit Link It", please follow the discussion and directions here:

https://github.com/sebastian-lenz/craft-linkfield/issues/51#issuecomment-538782716


All versions of linkfield with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
craftcms/cms Version ^4.0.0
sebastianlenz/craft-utils Version ^3.0.5
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 sebastianlenz/linkfield contains the following files

Loading the files please wait ....