Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Commit

Permalink
Adds Matrix, Element Editor modals, Live Preview and Commerce support…
Browse files Browse the repository at this point in the history
…. Bump to 1.2
  • Loading branch information
mmikkel committed Jul 9, 2016
1 parent a138a14 commit 21c10d2
Show file tree
Hide file tree
Showing 10 changed files with 442 additions and 223 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# CP Field Links
## v. 1.1
# CP Field Links v. 1.2 for Craft CMS ![Craft 2.5](https://img.shields.io/badge/craft-2.5-red.svg?style=flat-square)

CP Field Links is a tiny utility plugin making content modelling a little bit easier in Craft.
CP Field Links is a tiny utility plugin making content modelling a little bit easier in Craft.

For all admin users, CP Field Links will augment your element editing forms with handy links to easily edit individual fields, or even element sources and field layouts.
Did you forget a field handle? Mouse over the cogwheel next to the field title, and CP Field Links will tell you.

_Did you forget what that one field's_ handle _was, again?_ Mouse over the cogwheel; CP Field Links will tell you.
Need to adjust some field settings? Click the cogwheel; CP Field Links will redirect you to the relevant field's settings page – and back to the content when you're done.

Additionally, CP Field Links will add a link in your element edit forms to manage source settings (e.g. entry type, category group) in the same manner.

Note that CP Field Links will only be active for **admin** users.

**Recent updates**
* Now working inside Live Preview, Matrix and Element Editor modals
* Full Craft Commerce support (including variants)

![Easily inspect field handles and edit fields](http://g.recordit.co/i8SOUKWYpq.gif)

Expand All @@ -16,11 +23,20 @@ _Did you forget what that one field's_ handle _was, again?_ Mouse over the cogwh

## Disclaimer

This plugin is totally free, and you can do whatever you want with it (and to it). CP Field Links is unlikely to mess up your stuff, but if it does, the author takes absolutely no responsibility.
This plugin is totally free, and you can do whatever you want with it (and to it). CP Field Links is unlikely to mess up your stuff, but if it does, the author takes absolutely no responsibility.
Please direct any bug reports or feature requests [here](https://github.com/mmikkel/CpFieldLinks-Craft/issues).

## Changelog

### 1.2 (07.09.16)
* [Added] Matrix support
* [Added] Element Editor modals support
* [Added] Full support for Craft Commerce (including variants)
* [Added] Added 'Edit Product Type' link to Commerce Products
* [Improved] Plugin now works as intended in Live Preview
* [Improved] Field cogwheels are no longer tabbable
* [Improved] Fixed position for 'Edit Entry Type' cogwheel

### 1.1 (05.23.16)
* [Added] CP Field Links is now active/visible for all logged in admin users, regardless of devMode status
* [Fixed] Defined schema version
Expand Down
35 changes: 27 additions & 8 deletions cpfieldlinks/CpFieldLinksPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class CpFieldLinksPlugin extends BasePlugin
{

protected $_version = '1.1',
protected $_version = '1.2',
$_schemaVersion = '1.0',
$_minVersion = '2.3',
$_pluginName = 'CP Field Links',
Expand Down Expand Up @@ -66,11 +66,15 @@ public function init()
$request = craft()->request;
$currentUser = craft()->userSession->getUser();

if (!$currentUser || !$currentUser->admin || !$request->isCpRequest() || $request->isAjaxRequest() || craft()->isConsole() || !$this->isCraftRequiredVersion()) {
if (!$currentUser || !$currentUser->admin || !$request->isCpRequest() || craft()->isConsole() || !$this->isCraftRequiredVersion()) {
return false;
}

$this->addResources();
if (craft()->request->isAjaxRequest()) {
$this->ajaxInit();
} else {
$this->addResources();
}

}

Expand All @@ -79,6 +83,24 @@ protected function isCraftRequiredVersion()
return version_compare(craft()->getVersion(), $this->_minVersion, '>=');
}

protected function ajaxInit()
{

if (!craft()->request->isPostRequest()) {
return false;
}

$segments = craft()->request->segments;
$actionSegment = $segments[count($segments) - 1];

if ($actionSegment !== 'getEditorHtml') {
return false;
}

craft()->templates->includeJs('Craft.CpFieldLinksPlugin.initElementEditor();');

}

protected function addResources()
{

Expand All @@ -94,6 +116,7 @@ protected function addResources()
'baseEditEntryTypeUrl' => rtrim(UrlHelper::getCpUrl('settings/sections/sectionId/entrytypes'), '/'),
'baseEditGlobalSetUrl' => rtrim(UrlHelper::getCpUrl('settings/globals'), '/'),
'baseEditCategoryGroupUrl' => rtrim(UrlHelper::getCpUrl('settings/categories'), '/'),
'baseEditCommerceProductTypeUrl' => rtrim(UrlHelper::getCpUrl('commerce/settings/producttypes'), '/'),
];

$sectionIds = craft()->sections->allSectionIds;
Expand All @@ -118,17 +141,13 @@ protected function addResources()
];
}

$data = json_encode($data);
craft()->templates->includeJs('window._CpFieldLinksData='.$data.';');

// Include resources
$cssFile = 'stylesheets/CpFieldLinks.css';
$jsFile = 'javascripts/CpFieldLinks.js';

craft()->templates->includeCssResource('cpfieldlinks/' . ($manifest ? $manifest->$cssFile : $cssFile));
craft()->templates->includeJsResource('cpfieldlinks/' . ($manifest ? $manifest->$jsFile : $jsFile));


craft()->templates->includeJs('Craft.CpFieldLinksPlugin.init('.json_encode($data).');');

}

Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cpfieldlinks/resources/rev-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"javascripts/CpFieldLinks.js": "javascripts/CpFieldLinks-bf43da5d7bf035becd11.js",
"stylesheets/CpFieldLinks.css": "stylesheets/CpFieldLinks-33dff2a276.css"
"javascripts/CpFieldLinks.js": "javascripts/CpFieldLinks-f67305e6b68309713390.js",
"stylesheets/CpFieldLinks.css": "stylesheets/CpFieldLinks-89aff73de7.css"
}

This file was deleted.

Loading

0 comments on commit 21c10d2

Please sign in to comment.