dev-master
9999999-devLink fieldtype for Craft
MIT
The Requires
dev-feature/composer-compatibility
dev-feature/composer-compatibilityLink fieldtype for Craft
MIT
The Requires
Link fieldtype for Craft
One link field to replace them all, a multi-purpose link fieldtype for Craft CMS., (*1)
This plugin adds a fieldtype which links to all sorts of stuff, Linkit can currently link to:, (*2)
And it plays really nicely with Matrix!, (*3)
Field settings allow you to:, (*4)
To install Linkit, follow these steps:, (*5)
Get the link object:, (*6)
{% set yourLink = entry.yourLinkFieldHandle %}
Just the link - output a pre built HTML link:, (*7)
{{ yourLink.link|raw }}
Build a simple custom link:, (*8)
<a href="{{ yourLink.url }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.linkText }}">{{ yourLink.linkText }}</a>
Build your own:, (*9)
{% switch yourLink.type %} {% case "entry" %} <a href="{{ yourLink.entry.url }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.entry.title }}">{{ yourLink.entry.title }}</a> {% case "category" %} <a href="{{ yourLink.category.url }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.category.title }}">{{ yourLink.category.title }}</a> {% case "asset" %} <a href="{{ yourLink.asset.url }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.asset.title }}"> {% if yourLink.asset.kind == 'image' %} <img src="{{ yourLink.asset.url('thumb') }}" /> {% else %} <img src="thumb-{{ yourLink.asset.kind }}.png" /> {% endif %} </a> {% case "custom" %} <a href="{{ yourLink.custom }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.linkText }}"> <i class="custom-link-icon"></i> {{ yourLink.linkText }} </a> {% case "email" %} <a href="mailto:{{ yourLink.email }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.linkText }}">{{ yourLink.email }}</a></p> {% case "tel" %} <a href="tel:{{ yourLink.tel }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.linkText }}">{{ yourLink.tel }}</a></p> {% endswitch %}
Each link returns a link object which contains the following:, (*10)
{% set yourLink = entry.yourLinkFieldHandle %} // Get the link {{ yourLink.type }} // Returns the link type - entry, asset, email, tel, custom {{ yourLink.email }} // Email String / False {{ yourLink.custom }} // Custom URL String / False {{ yourLink.tel }} // Telephone Number / False {{ yourLink.entry }} // Entry Object / False {{ yourLink.category }} // Category Object / False {{ yourLink.asset }} // Asset Object / False // Each link type is returned - only the active type will return data the rest return false {{ yourLink.text }} // The Custom Text String {{ yourLink.target }} // True/False (Bool) - Open in new window? {{ yourLink.url }} // The full url (correct prefix added eg mailto: or tel:) {{ yourLink.linkText }} // The link text string ready to use (If no custom text is provided it generates it based on the link type) {{ yourLink.link }} // Full link HTML ready to use
Copyright 2014 Fruit Studios Ltd, (*11)
Link fieldtype for Craft
MIT
Link fieldtype for Craft
MIT