Oetzie / SocialMedia

MODX Revolution Social Media Component
http://www.oetzie.nl
0 stars 1 forks source link

Mogelijkheid tot filteren op keywords in content #3

Closed sdrenth closed 7 years ago

sdrenth commented 7 years ago

Niet alleen excluden van resultaten, maar ook juist alleen content ophalen die bepaalde content bevatten.

Ik heb bijvoorbeeld als volgt LIKE filters toegevoegd op content veld

$filters     = [];
$filterCount = 0;
foreach (array_filter(explode(',', $this->properties['filter'])) as $filter) {
    $search = '%' . trim($filter, '%') . '%';
    if ($filterCount === 0) {
        $filters[]['content:LIKE'] = $search;

        $filterCount++;
    } else {
        $filters[0][]['OR:content:LIKE'] = $search;
    }

    /* If search contains spaces, also add search for string without spaces. */
    if (strpos($filter, ' ') !== false) {
        $filters[0][]['OR:content:LIKE'] = str_replace(' ', '', $search);
    }
}

Bij snippet dan:
&filter=`keyword1,keyword2`
Oetzie commented 7 years ago

Fixed in 1.1.1