Closed ghost closed 6 years ago
My suggestion would be to add something like this:
if ($arrConfig['linkurl']) {
$link = $arrConfig['linkurl'];
$link = str_replace('[id]', $result->id, $link);
$matches = [];
if (preg_match('/\[[a-z]+\]/', $link, $matches)) {
foreach ($matches as $key => $value) {
$replacedValue = str_replace('[', '', $value);
$replacedValue = str_replace(']', '', $replacedValue);
if ($result->$replacedValue) {
$replacedValue = $result->$replacedValue;
}
$matches[$key] = $replacedValue;
}
$link = preg_replace(['/\[[a-z]+\]/'], $matches, $link);
}
}
and then use the $link
instead of $objLayer->loc_linkurl
to build the array for the JSON structure.
I pushed a possible fix in the feature-branch. I tried your solution and added a few tweaks to make it more viable with different links using the contao redirect targets. That should not affect your solution. Thank you for your suggestion.
Totally cool! Thank you for this great extension!
I think there is a bug in the
LayerContentApi.php
file. I collect markers from an external table (in this case an Isotope shop). The markers should link directly to the product details and an appropriate config is present:In sum, this leads to the correct markers being placed on the map, but without links. The JSON looks like this:
As one can see, the
loc_linkurl
field is empty. I read through the PHP class for a while and found that the results from the database query are mainly parsed inside a conditional structure for the popup. But there is no popup in my configuration.I think a new, separate block is needed which takes care of the
linkurl
field. If somebody acknowledges this as a bug, I could write a fix. But first I'd like some confirmation I'm heading in the right direction.