-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efee210
commit 57dea04
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
namespace verbb\feedme\fields; | ||
|
||
use verbb\feedme\base\Field; | ||
use verbb\feedme\base\FieldInterface; | ||
use verbb\feedme\helpers\DataHelper; | ||
|
||
use Cake\Utility\Hash; | ||
|
||
class SmartMap extends Field implements FieldInterface | ||
{ | ||
// Properties | ||
// ========================================================================= | ||
|
||
public static $name = 'SmartMap'; | ||
public static $class = 'doublesecretagency\smartmap\fields\Address'; | ||
|
||
|
||
// Templates | ||
// ========================================================================= | ||
|
||
public function getMappingTemplate() | ||
{ | ||
return 'feed-me/_includes/fields/smart-map'; | ||
} | ||
|
||
|
||
// Public Methods | ||
// ========================================================================= | ||
|
||
public function parseField() | ||
{ | ||
$preppedData = []; | ||
|
||
$fields = Hash::get($this->fieldInfo, 'fields'); | ||
|
||
foreach ($fields as $subFieldHandle => $subFieldInfo) { | ||
$preppedData[$subFieldHandle] = DataHelper::fetchSimpleValue($this->feedData, $subFieldInfo); | ||
} | ||
|
||
return $preppedData; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{# ------------------------ #} | ||
{# Available Variables #} | ||
{# ------------------------ #} | ||
{# Attributes: #} | ||
{# type, name, handle, instructions, attribute, default, feed, feedData #} | ||
{# ------------------------ #} | ||
{# Fields: #} | ||
{# name, handle, instructions, feed, feedData, field, fieldClass #} | ||
{# ------------------------ #} | ||
|
||
{% import 'feed-me/_macros' as feedMeMacro %} | ||
{% import '_includes/forms' as forms %} | ||
|
||
{# Special case when inside another complex field (Matrix) #} | ||
{% if parentPath is defined %} | ||
{% set prefixPath = parentPath %} | ||
{% else %} | ||
{% set prefixPath = [handle] %} | ||
{% endif %} | ||
|
||
{% set classes = ['complex-field'] %} | ||
|
||
<tr class="complex-field complex-field-header"> | ||
<td class="col-field" colspan="3"> | ||
<div class="field"> | ||
<div class="heading"> | ||
<label class="">{{ name }}</label> | ||
</div> | ||
|
||
<div class="additional-mapping-fields"> | ||
{% namespace 'fieldMapping[' ~ prefixPath | join('][') ~ ']' %} | ||
<input type="text" name="field" value="{{ className(field) }}"> | ||
{% endnamespace %} | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
|
||
{% for key, col in field.settings.layout %} | ||
{% set nameLabel = craft.smartMap.labelFromHandle(key) %} | ||
{% set instructionsHandle = handle ~ '[' ~ key ~ ']' %} | ||
|
||
{% set path = prefixPath | merge ([ 'fields', key ]) %} | ||
|
||
{% set default = default ?? { | ||
type: 'text', | ||
} %} | ||
|
||
{% embed 'feed-me/_includes/fields/_base' %} | ||
{% block additionalFieldSettings %} | ||
|
||
{% endblock %} | ||
|
||
{% block fieldSettings %} | ||
|
||
{% endblock %} | ||
{% endembed %} | ||
{% endfor %} |