A simple ExpressionEngine 2.x Fieldtype for creating links using Markdown formatting.
- Version 0.9.0 (beta)
- Full Documentation
- Hyperlinks without HTML
- Single or multiple links per field
- Full control over output
- Low Variables compatible
- Matrix compatible
Click was built to easily make one or more arbitrary hyperlinks, without needing to know HTML, and with full control over markup in your templates.
Click leverages Markdown as the formatting syntax to write your links. So it can turn this:
[Google it!](http://google.com "Google")
[Bing it!](http://bing.com "Bing")
[Ask it!](http://ask.com "Ask")
Into this:
<ul>
<li><a href="http://google.com" title="Google">Google it!</a></li>
<li><a href="http://bing.com" title="Bing">Bing it!</a></li>
<li><a href="http://ask.com" title="Ask">Ask it!</a></li>
</ul>
Simply by writing this:
<ul>
{my_click_field}
<li>{click}</li>
{/my_click_field}
</ul>
Or this:
<ul>
{my_click_field}
<li><a href="{url}" title="{title}">{text}</a></li>
{/my_click_field}
</ul>
Or actually, even this:
{my_click_field:ul}
- Copy the contents of /system/expressionengine/third_party/click into your own system/expressionengine/third_party folder.
- Log into the CP and go to Add-Ons > Fieldtypes and install the "Click" fieldtype
When creating a Click custom field, the following options are available:
When ticked, this will use the HTML5 placeholder
attribute to show sample text for an empty field, demonstrating the acceptable format for a Markdown-formatted link:
[link text](url "optional title")
When ticked, the custom field will allow for multiple links, each separated by a new line.
The following tags are available for your Click field within {exp:channel:entries}
tag pairs.
Click's tag pair is used to iterate & display multiple links, in the case where multiple links are enabled.
<ul class="nav">
{my_click_field prefix="click:"}
<li class="{switch='odd|even'}"><a href="{click:url}" title="{click:title}">{click:text}</a></li>
{/my_click_field}
</ul>
Strip the last X characters from the tag output.
{my_click_field backspace="2"}{click}, {/my_click_field}
Specify Click to only parse variables which have the specified prefix. Useful in case of naming conflicts between nested fields.
{my_click_field prefix="click"}{click:url}, {/my_click_field}
Specify the maximum number of links to return.
{my_click_field limit="2"}{click}, {/my_click_field}
Within the Tag Pair, the following variable tags are available (note these may change if you have specified a var_prefix=
).
Returns the fully rendered <A> link.
{my_click_field}{click}, {/my_click_field}
Returns the readable Text portion of the <A> link.
{my_click_field}{text}, {/my_click_field}
Returns the Alternative Title portion of the <A> link.
{my_click_field}{title}, {/my_click_field}
Returns the URL portion of the <A> link.
{my_click_field}{url}, {/my_click_field}
When Click is configured to only allow a single link, returning the fully formatted <A> link is as simple as:
{my_click_field}
// renders something like:
<a href="http:domain.com" title="Alternative Title">Link Text</a>
Note: In the case where multiple links are allowed for the field, the Primary Tag will only return the first link.
Returns the total number of links.
{my_click_field:total}
In the case where multiple links are allowed for a field, this will return the first link tag:
{my_click_field:first}
In the case where multiple links are allowed for a field, this will return the last link tag:
{my_click_field:last}
Return an automatically-generated unordered list of links.
{my_click_field:ul}
Return an automatically-generated ordered list of links.
{my_click_field:ol}
Returns only the URL of the <A> link. In the case where multiple links are allowed, will only return the first.
{my_click_field:url}
Returns only the readable Text part of the <A> link. In the case where multiple links are allowed, will only return the first.
{my_click_field:text}
Returns the Alternative title part of the <A> link. In the case where multiple links are allowed, will only return the first.
{my_click_field:title}
Returns the original, unformatted contents of the entire custom field.
{my_click_field:original}
- option to auto encode mailto: addresses
- JS validation
- Confirm Safecracker support
- Confirm MSM support