Hello @arthur.xuan.vu, it’s not possible to limit the number of items when using combine using attributes. Anyway you could limit number of cms items rendered using webflow before publishing and our attributes library will only combine the limited items
There are two instances of CMS Combine on the page which are working also with CMS filter and Static item.
I need to limit the first feature list to only show 1 item, so where it says “Secure the branding budget you need to unlock the next phase of growth” and “Helping an NGO secure $3.6m in revenue in a single month with an always-on brand campaign approach” – this would only show the most recently added item
@tristanpringle, one question. Between these two items, how are you doing the sorting to know which is the newest? To avoid a whole new CMS Sort setup you might want to add the dates to the items and we can sort with some JS.
Even though the list is the first to show on the page, it is the second instance of the CMS Combine Attribute. Having this in mind this script should do what you are after
<script>
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'cmscombine',
(listInstances) => {
console.log('cmscombine Successfully loaded!');
if (listInstances.length > 1 && listInstances[1].items.length > 1) {
const listInstance = listInstances[1];
// Add sorting to ensure the first newest item is shown first
for (let index = 1; index < listInstance.items.length; index++) {
const element = listInstance.items[index].element;
element.style.display = 'none';
}
} else {
console.log('Not enough items in the list to hide.');
}
},
]);
</script>
The script is working perfectly on the first feature list. However, I need to repeat this functionality for 2 more combined feature lists on the page (there are 3 feature lists in total on the page).
Could you help update the script that you gave me to have the same functionality on all three feature lists?
I’ve also added the date text into each of the CMS items so that we can add the sorting using that.
Hey @Support-Luis , sure thing, thank you – a screen recording is attached.
The desired behaviour is that the content of the feature lists is included and filtered by the CMS filters at the top of the page. E.g. when ‘Guide’ is toggled, only items with the category of ‘Guide’ should show.
However, at the moment, even if a Guide item is not the first item in a feature-list, when that category filter is active, the feature list still shows with a ‘Case Study’ item at the top.
The way the page is set up is that each of the combined CMS feature lists are nested inside a div with the class of ‘static-item’. These static items use Attributes to get positioned at position 1, 8 and 24 within the main combined (non-featured) collection list on the page.
The Static items are given the attribute of ‘fs-cmsstatic-interactive = true’, so that they should interact with the CMS filters are the top.
Before adding the scripts you created, the CMS filter was functioning correctly on both the featured and non-featured lists, so I’m wondering if something can be added to the script to get that functionality working again?
Hey @tristanpringle! Yes, I’ve been taking a look the whole day. I’ll report back when I find a possible solution…
I can’t fully test as when I override the content the filters stop working on my end. To give you an idea of a possible fix, I am trying to remove from the page the items instead of hiding them as I believe CMS Filter finds a match inside the static item corresponding to the other categories.
That method of removing items from the page instead of hiding them in the featured lists sounds exactly like what I thought we need, like you say it seems like the CMS Filter still finds a match inside the static item even if it isn’t the first one shown.
All that’s missing now is making the Static items fit into the combined collection list.
The divs that should be static are called ‘static-item’ – the first one on the page should be at position 1 in the combined list, and the second one should be at position 8.
This will be awesome when it’s working and will use all of these attribute solutions: Combine/Sort/Filter/Static
Can you see how I can get the Static functionality working?