Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for SuperTable field #10

Open
xavianaxw opened this issue Jul 13, 2021 · 0 comments
Open

Adding support for SuperTable field #10

xavianaxw opened this issue Jul 13, 2021 · 0 comments

Comments

@xavianaxw
Copy link

With the current state of the plugin, there was no way to get a matchedValue when working within a SuperTable field even though the plugin managed to determine that the searched keyword exists in the field.

Looking at the source code.

elseif (is_object($fieldContents) && $fieldContents instanceof \verbb\supertable\elements\db\SuperTableBlockQuery)
{
//TODO: fix this somehow
}

it seems that it has been omitted. I did some tinkering within my vendor/ and came up with this.

elseif (is_object($fieldContents) && $fieldContents instanceof \verbb\supertable\elements\db\SuperTableBlockQuery){
  $relatedValues = [];
  $matchedValue = '';
  foreach ($fieldContents->all() as $stBlock) {
    $stMatches = $this->findMatchesInFieldSet($stBlock, $term, $length);
    if (!is_null($stMatches)) {
      $matchedValue = $stMatches[1];
    }
  }
  return [$fieldHandle, $matchedValue, $relatedValues];
}

which is the exact replica to the MatrixBlockQuery if statement. I'm not really sure how to set this up myself to work with composer so was hoping if this could get updated with the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant