codefog / contao-news_categories

Extend the Contao news module with categories
MIT License
32 stars 25 forks source link

2 Filter #265

Closed Misco closed 6 months ago

Misco commented 8 months ago
image

my final goal is to have the filter to work like this. the user can select one "Handlungsfeld" and one "Jahr" kumulativ. is it possible, i try so hard...

Thanks

aschempp commented 6 months ago

as far as I now, there is no limit on the categories the user can select, you cannot fors them to select one of each parent category. You can only train them (and hope they follow the guide 🙈 ).

Misco commented 6 months ago

`var ele = $('#pub .mod_newscategories_cumulativehierarchical');

ele.find('select').on('change', function(e){ e.preventDefault();

function removeFirstHfId(href) { let match; const firstHfMatch = href.match(/hf-/g); if (firstHfMatch && firstHfMatch.length >= 2) { href = href.replace(/hf-[^_]+_/, ''); } const firstIdMatch = href.match(/id-/g); if (firstIdMatch && firstIdMatch.length >= 2) { href = href.replace(/id-[^]+__/, ''); } return href; } window.location = removeFirstHfId($(this).val()); });`

Dieser Javascript Code erreicht das gewünschte Verhalten.