Skip to content

Commit

Permalink
Version 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
samhibberd committed Feb 28, 2016
1 parent d46f87a commit 5ac8324
Show file tree
Hide file tree
Showing 12 changed files with 1,308 additions and 101 deletions.
8 changes: 8 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Fruit Studios

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
220 changes: 119 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Linkit plugin for Craft
# FruitLinkIt plugin for Craft CMS ![Craft 2.5](https://img.shields.io/badge/craft-2.5-red.svg?style=flat-square)

One link field to replace them all, a multi-purpose link fieldtype for Craft CMS.

This plugin adds a fieldtype which links to all sorts of stuff, Linkit can currently link to:

## UPGRADING Pre 2.3.0???

See upgrade details below.


## FruitLinkIt Overview

This plugin adds a fieldtype which links to all sorts of stuff, Link It can currently link to:

* Entries
* Assets
Expand All @@ -11,120 +19,128 @@ This plugin adds a fieldtype which links to all sorts of stuff, Linkit can curre
* Phone numbers
* Custom URLs

And it plays really nicely with Matrix!

Field settings allow you to:
Link It supports Matrix fields and allows you to:

* Configure what elements each field can link too.
* Set which entry/asset sources are available to each field.
* Configure what elements each field can link to.
* Set which element sources are available to each field.
* Allow fields to set custom link text.
* Allow fields to set links to open in new window.
* Set default link text.


## Installation

To install Linkit, follow these steps:

1. Upload the linkit/ folder to your craft/plugins/ folder.
2. Go to Settings > Plugins from your Craft control panel and enable the Linkit plugin.
3. Create and configure a new linkit field.

## Template Usage

Get the link object:

{% set yourLink = entry.yourLinkFieldHandle %}

Just the link - output a pre built HTML link:

{{ yourLink.link|raw }}
Build a simple custom link:

<a href="{{ yourLink.url }}" {{ yourLink.target ? ' target="_blank"' }} title="{{ yourLink.linkText }}">{{ yourLink.linkText }}</a>
Build your own:

{% 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 %}

## Template Variables

Each link returns a link object which contains the following:

{% 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

## Roadmap

* Force download option
* Rework the way link data is returned
* Improve handling of target stuff - if it's required
* More Validation Options


## Changelog
To install FruitLinkIt, follow these steps:

1. Download & unzip the file and place the `fruitlinkit` directory into your `craft/plugins` directory
2. Install plugin in the Craft Control Panel under Settings > Plugins

FruitLinkIt requires Craft 2.5, for pre 2.5 support see releases.

## Upgrading

Always ensure you have tested any new releases in a development environment.

### Upgrading FruitLinkIt (Pre Version 2.3.0)

Upgrading from a version prior to 2.3.0 please take extra care to backup and test in a development environment. FruitLinkIt will run a migration that automatically updates any existing field settings and content after which it will remove the old version.

NB. Existing templates will not break but you will get a load of deprecator errors, take a look at the readme file for updated usage guides.

## Configuring FruitLinkIt

Add a new Link It field and configure it. Easy.

## Using FruitLinkIt


### Template Variables (Basic Use)

Just output the custom field to get a ready built html link

{{ entry.linkItField }}

or in full

{{ entry.linkItField.htmlLink }} or {{ entry.linkItField.getHtmlLink() }}

Customised html link

{% set attributes = {
title: 'Custom Title',
target: '_self',
class: 'my-class',
"data-custom": 'custom-data-attribute'
} %}
{{ entry.linkItField.htmlLink(attributes) }}


### Template Variables (Advanced Use)

Each Link it field returns a LinkIt model with the following attributes / methods available

{{ entry.linkItField.type }} (email, custom, tel, entry, category or asset)
{{ entry.linkItField.target }}
{{ entry.linkItField.url }} or {{ entry.linkItField.getUrl() }}
{{ entry.linkItField.text }} or {{ entry.linkItField.getText() }}

If your link is an element link (asset, entry, category) you also have access to the following:

{{ entry.linkItField.element }} or {{ entry.linkItField.getElement() }}

or specific element types

{{ entry.linkItField.entry }} or {{ entry.linkItField.getEntry() }}
{{ entry.linkItField.asset }} or {{ entry.linkItField.getAsset() }}
{{ entry.linkItField.category }} or {{ entry.linkItField.getCategory() }}

### Deprecated Template Variables

{{ linkItField.linkText }} use {{ linkItField.text }} instead.
{{ linkItField.link }} use {{ linkItField }} or {{ linkItField.htmlLink }} instead.
{{ linkItField.email }} use {{ linkItField.url }} instead.
{{ linkItField.custom }} use {{ linkItField.url }} instead.
{{ linkItField.tel }} use {{ linkItField.url }} instead.

## FruitLinkIt Roadmap

Some things to do, and ideas for potential features:

* Add front end template support
* More validation options
* Force download options
* Improved cp field layout

## FruitLinkIt Changelog

### 2.3.0

Complete rewrite for Craft 2.5.x, same functionality with some UI tweaks and

* Improved: Now returns a custom validated link model to the template
* Improved: Validation of the link model
* Improved: Template usage - __toSting method now returns full html link
* Improved: Field settings layout
* Added: Facility to customise the html link attributes
* Added: Fully translate Link It
* Fixed: Locale settings bug

Amongst other stuff :)


### 1.0

* Updated: Plugin renamed to bring it inline with the rest of our plugins.


### 0.9.1

* Fixed: Input field not displaying correctly when set to single type when field had previously been saved.
* Fixed: Input field not displaying correctly when set to single type when field had previously been saved.
* Fixed: Custom text returning false.

### 0.9

* Added: Removed the requirement to use the |raw filter when using the link variable.
* Fixed: Input field now corectly displays when on one link type is setup.
* Fixed: Input field now correctly displays when on one link type is setup.

### 0.8.1

Expand All @@ -146,6 +162,8 @@ Each link returns a link object which contains the following:

* Initial beta release

Brought to you by [Fruit Studios](http://fruitstudios.co.uk)

## Licence

Copyright 2014 Fruit Studios Ltd
46 changes: 46 additions & 0 deletions fruitlinkit/FruitLinkItPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
namespace Craft;

class FruitLinkItPlugin extends BasePlugin
{
public function getName()
{
return 'Link It';
}

public function getVersion()
{
return '2.3.0';
}

public function getSchemaVersion()
{
return '2.3.0';
}

public function getDeveloper()
{
return 'Fruit Studios';
}

public function getDeveloperUrl()
{
return 'http://fruitstudios.co.uk';
}

public function getPluginHandle()
{
return StringHelper::toLowerCase($this->classHandle);
}

public function onAfterInstall()
{
$migrationClass = 'm160208_010101_FruitLinkIt_UpdateExistingLinkItFields';
$migration = craft()->migrations->instantiateMigration($migrationClass, $this);
if (!$migration->up())
{
FruitLinkItPlugin::log("Link It Upgrade Error. Could not run: " . $migrationClass, LogLevel::Error);
}
}

}
Loading

0 comments on commit 5ac8324

Please sign in to comment.