{"id":13756592,"url":"https://github.com/fruitstudios/LinkIt","last_synced_at":"2025-05-10T03:32:32.655Z","repository":{"id":15435903,"uuid":"18168573","full_name":"fruitstudios/linkit","owner":"fruitstudios","description":"Multi-purpose link plugin for Craft CMS ","archived":false,"fork":false,"pushed_at":"2019-01-22T16:12:54.000Z","size":60,"stargazers_count":153,"open_issues_count":48,"forks_count":29,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-03T11:02:28.917Z","etag":null,"topics":["craft","craft-plugin","craftcms","link"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fruitstudios.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-27T08:03:50.000Z","updated_at":"2023-11-01T15:44:12.000Z","dependencies_parsed_at":"2022-08-26T05:11:00.916Z","dependency_job_id":null,"html_url":"https://github.com/fruitstudios/linkit","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitstudios%2Flinkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitstudios%2Flinkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitstudios%2Flinkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fruitstudios%2Flinkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fruitstudios","download_url":"https://codeload.github.com/fruitstudios/linkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224911605,"owners_count":17390840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["craft","craft-plugin","craftcms","link"],"created_at":"2024-08-03T11:00:48.487Z","updated_at":"2024-11-16T11:31:57.034Z","avatar_url":"https://github.com/fruitstudios.png","language":"PHP","funding_links":[],"categories":["Field Types"],"sub_categories":[],"readme":"# FruitLinkIt plugin for Craft CMS ![Craft 2.5](https://img.shields.io/badge/craft-2.5-red.svg?style=flat-square)\n\nOne link field to replace them all, a multi-purpose link fieldtype for Craft CMS.\n\n## On Craft 3\n\nLinkit for Craft 3 is now available in the Plugin Store ([Linkit on GitHub](https://github.com/fruitstudios/craft-linkit))\n\n## Upgrading Pre 2.3.0?\n\nSee upgrade details below.\n\n\n## FruitLinkIt Overview\n\nThis plugin adds a fieldtype which links to all sorts of stuff, Link It can currently link to:\n\n* Entries\n* Assets\n* Categories\n* Products (Requires Commerce)\n* Emails\n* Phone numbers\n* Custom URLs\n\nLink It supports Matrix fields and allows you to:\n\n* Configure what elements each field can link to.\n* Set which element sources are available to each field.\n* Allow fields to set custom link text.\n* Allow fields to set links to open in new window.\n* Set default link text.\n\n## Installation\n\nTo install FruitLinkIt, follow these steps:\n\n1. Download \u0026 unzip the file and place the `fruitlinkit` directory into your `craft/plugins` directory\n2. Install plugin in the Craft Control Panel under Settings \u003e Plugins\n\nFruitLinkIt requires Craft 2.5, for pre 2.5 support see releases.\n\n## Upgrading\n\nAlways ensure you have tested any new releases in a development environment.\n\n### Upgrading FruitLinkIt (Pre Version 2.3.0)\n\nUpgrading 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.\n\nNB. 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.\n\n## Configuring FruitLinkIt\n\nAdd a new Link It field and configure it. Easy.\n\n## Using FruitLinkIt\n\n\n### Template Variables (Basic Use)\n\nJust output the custom field to get a ready built html link\n\n    {{ entry.linkItField }}\n\nor in full\n\n    {{ entry.linkItField.htmlLink }} or {{ entry.linkItField.getHtmlLink() }}\n\nCustomised html link\n\n    {% set attributes = {\n        title: 'Custom Title',\n        target: '_self',\n        class: 'my-class',\n        \"data-custom\": 'custom-data-attribute'\n    } %}\n    {{ entry.linkItField.htmlLink(attributes) }}\n\n\n### Template Variables (Advanced Use)\n\nEach Link it field returns a LinkIt model with the following attributes / methods available\n\n    {{ entry.linkItField.type }} (email, custom, tel, entry, category or asset)\n    {{ entry.linkItField.target }}\n    {{ entry.linkItField.url }} or {{ entry.linkItField.getUrl() }}\n    {{ entry.linkItField.text }} or {{ entry.linkItField.getText() }}\n\nIf your link is an element link (asset, entry, category) you also have access to the following:\n\n    {{ entry.linkItField.element }} or {{ entry.linkItField.getElement() }}\n\nor specific element types\n\n    {{ entry.linkItField.entry }} or {{ entry.linkItField.getEntry() }}\n    {{ entry.linkItField.asset }} or {{ entry.linkItField.getAsset() }}\n    {{ entry.linkItField.category }} or {{ entry.linkItField.getCategory() }}\n\n### Deprecated Template Variables\n\n    {{ linkItField.linkText }} use {{ linkItField.text }} instead.\n    {{ linkItField.link }} use {{ linkItField }} or {{ linkItField.htmlLink }} instead.\n    {{ linkItField.email }} use {{ linkItField.url }} instead.\n    {{ linkItField.custom }} use {{ linkItField.url }} instead.\n    {{ linkItField.tel }} use {{ linkItField.url }} instead.\n\n\n### Hooks\n\nThere are two hooks that allow plugins to add their own Element Types to Link It:\n\n#### `linkit_registerElementTypes`\n\nRegisters the ElementType(s) with LinkIt and provides all the data needed for the field settings.\n\nIt should return an array of element types you want to register and should be in the following format:\n\n```php\n/**\n * @return array\n */\npublic function linkit_registerElementTypes()\n{\n\n  return array(\n   'my_element' =\u003e array(\n     'name'                   =\u003e Craft::t('My Element'),\n     'pluralName'             =\u003e Craft::t('My Elements'),\n     'selectionLabelDefault'  =\u003e Craft::t('Select an element'),\n     'emptyInputErrorMessage' =\u003e Craft::t('Please select an element'),\n     'elementType'            =\u003e 'MyPlugin_MyElement',\n     'sources' =\u003e array(\n       array(\n         'label' =\u003e Craft::t('All of my elements'),\n         'value' =\u003e '*'\n       ),\n       array(\n         'label' =\u003e Craft::t('Element source 1'),\n         'value' =\u003e 'myElementGroup:1'\n       ),\n       array(\n         'label' =\u003e Craft::t('Element source 2'),\n         'value' =\u003e 'myElementGroup:2'\n       )\n     )\n   )\n  ),\n  'my_other_element' =\u003e array(\n    ...\n  );\n\n}\n```\n\n#### `linkit_getElementData`\n\nFetches the element data for a given `$type` and `$id`:\n\n```php\n/**\n * @param  string $type\n * @param  int    $id\n * @return array|false\n */\npublic function linkit_getElementData($type, $id)\n{\n\n  // Return false if there is no `$type` or `$id` set\n  if (!$type || !$id) {\n    return false;\n  }\n\n  switch ($type) {\n    case 'my_element':\n      $myElement = craft()-\u003emyPlugin_myElements-\u003egetMyElementById($id);\n\n      if ($myElement) {\n        return array(\n          'url'     =\u003e $myElement-\u003egetUrl(),\n          'text'    =\u003e $myElement-\u003etitle,\n          'element' =\u003e $myElement\n        );\n      } else {\n        // There was no element, so be sure to return false\n        return false;\n      }\n      break;\n\n    case 'my_other_element':\n      ...\n      break;\n\n    // We don’t want to return anything for unsupported types\n    default:\n      return false;\n      break;\n  }\n\n}\n```\n\n## FruitLinkIt Roadmap\n\nSome things to do, and ideas for potential features:\n\n* Add front end template support\n* More validation options\n* Force download options\n* Improved cp field layout\n\n## FruitLinkIt Changelog\n\n### 2.3.4\n\n* Added: Allow plugins to add their own Element Types (Thanks to Josh Angell)\n\n### 2.3.3\n\n* Added: Support For Commerce Products (Thanks to Isaac Gray)\n\n### 2.3.2\n\n* Fixed: Migration error when some settings values not defined.\n\n\n### 2.3.1\n\n* Fixed: Target not retaining it's value\n\n### 2.3.0\n\nComplete rewrite for Craft 2.5.x, same functionality with some UI tweaks and\n\n* Improved: Now returns a custom validated link model to the template\n* Improved: Validation of the link model\n* Improved: Template usage - __toSting method now returns full html link\n* Improved: Field settings layout\n* Added: Facility to customise the html link attributes\n* Added: Fully translate Link It\n* Fixed: Locale settings bug\n\nAmongst other stuff :)\n\n\n### 1.0\n\n* Updated: Plugin renamed to bring it inline with the rest of our plugins.\n\n\n### 0.9.1\n\n* Fixed: Input field not displaying correctly when set to single type when field had previously been saved.\n* Fixed: Custom text returning false.\n\n### 0.9\n\n* Added: Removed the requirement to use the |raw filter when using the link variable.\n* Fixed: Input field now correctly displays when on one link type is setup.\n\n### 0.8.1\n\n* Added: Hide the Link To... select when only one link type has been selected for the field.\n\n### 0.8\n\n* Added: Category Support\n\n### 0.7\n\n* Added: Default Text - Fieldtype setting to add default link text for a link.\n\n### 0.6\n\n* Fix: PHP Error when returning an entry or asset that has subsequently been deleted\n\n### 0.5\n\n* Initial beta release\n\nBrought to you by [Fruit Studios](http://fruitstudios.co.uk)\n\n## Licence\n\nCopyright 2014 Fruit Studios Ltd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffruitstudios%2FLinkIt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffruitstudios%2FLinkIt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffruitstudios%2FLinkIt/lists"}