Skip to content

Commit

Permalink
Merge pull request #60 from dommmel/patch-1
Browse files Browse the repository at this point in the history
Quick fix for #58
  • Loading branch information
engram-design committed Mar 16, 2016
2 parents d18ed3c + 8dc4363 commit c83cb4f
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions supertable/fieldtypes/SuperTableFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,38 +356,40 @@ public function validate($blocks)

public function getSearchKeywords($value)
{
$keywords = array();
$contentService = craft()->content;

if ($this->settings->staticField) {
$value = array($value);
}

foreach ($value as $block) {
$originalContentTable = $contentService->contentTable;
$originalFieldColumnPrefix = $contentService->fieldColumnPrefix;
$originalFieldContext = $contentService->fieldContext;

$contentService->contentTable = $block->getContentTable();
$contentService->fieldColumnPrefix = $block->getFieldColumnPrefix();
$contentService->fieldContext = $block->getFieldContext();

foreach (craft()->fields->getAllFields() as $field) {
$fieldType = $field->getFieldType();

if ($fieldType) {
$fieldType->element = $block;
$handle = $field->handle;
$keywords[] = $fieldType->getSearchKeywords($block->getFieldValue($handle));
if ($value)
{
$keywords = array();
$contentService = craft()->content;

if ($this->settings->staticField) {
$value = array($value);
}

foreach ($value as $block) {
$originalContentTable = $contentService->contentTable;
$originalFieldColumnPrefix = $contentService->fieldColumnPrefix;
$originalFieldContext = $contentService->fieldContext;

$contentService->contentTable = $block->getContentTable();
$contentService->fieldColumnPrefix = $block->getFieldColumnPrefix();
$contentService->fieldContext = $block->getFieldContext();

foreach (craft()->fields->getAllFields() as $field) {
$fieldType = $field->getFieldType();

if ($fieldType) {
$fieldType->element = $block;
$handle = $field->handle;
$keywords[] = $fieldType->getSearchKeywords($block->getFieldValue($handle));
}
}

$contentService->contentTable = $originalContentTable;
$contentService->fieldColumnPrefix = $originalFieldColumnPrefix;
$contentService->fieldContext = $originalFieldContext;
}

$contentService->contentTable = $originalContentTable;
$contentService->fieldColumnPrefix = $originalFieldColumnPrefix;
$contentService->fieldContext = $originalFieldContext;
return parent::getSearchKeywords($keywords);
}

return parent::getSearchKeywords($keywords);
}

public function onAfterElementSave()
Expand Down

0 comments on commit c83cb4f

Please sign in to comment.