TheCadien / SuluNewsBundle

Simple News Bundle for Sulu 2 CMS
MIT License
14 stars 12 forks source link

SmartContent allow Filter Params #47

Open manuxi opened 1 year ago

manuxi commented 1 year ago

I'd like to filter the news by tag but it doesn't work this way:

<property name="news" type="smart_content">
<meta>
  <title lang="en">Latest FAQ</title>
</meta>

<params>
  <param name="provider" value="news"/>
  <param name="max_per_page" value="5"/>
  <param name="page_parameter" value="p"/>
  <param name="tags_parameter" value="faq"/>
</params>
</property>

Is this possible at all?

TheCadien commented 1 year ago

Currently we don't have any "resolveFilter" in the SmartContent component yet these would have to be added in the "NewsDataProvider.php", like for example in the SnippetSmartContent component

manuxi commented 1 year ago

Welll... I played around a bit, seems to work with

<params>
    <param name="provider" value="news"/>
    <param name="max_per_page" value="5"/>
    <param name="page_parameter" value="p"/>
    <param name="properties" type="collection">
        <param name="tag" value="FAQ"/>
    </param>
</params>

Would be great to have that manageable by the client, but i'm happy if it works that way. Thank you for that bundle!

manuxi commented 1 year ago

I've digged deeper into that filter issue. To get it to work I've added several methods in my repository class which are responsible for ordering and filtering for types (I made this to filter nearly every custom field, e.g. date comparison), tags and categories. See https://github.com/manuxi/SuluEventBundle/blob/afb1fab9f23f7b5a10e2ccd0c1987d31a1eac8fa/src/Repository/EventRepository.php#L221 - I think this would fit in your repository class with few adjustments...