We are building a site that is using CMS Nest to dynamically nest the related items to each collection, this has come to a point where the CMS Collection that is used to nest is over 100+ CMS item. We have tried using CMS Load but is fixing it.
Hey @Support-Luis , great solution!
Is there a way to load the script regularly and āre-loadā it again after all scripts are loaded?
Asking, since I have multiple CMS lists that have a nested element in them, and the first item is at the top of the page. With the current solution it takes long time for the nested items to load.
Hey @koptiz! You do not have the complete setup for CMS Load, you are just missing the load mode value. You could use fs-cmsload-mode=render-all but be mindful that this will load ALL items, if there are too many or the elements might slow the page down you can opt to use āfs-cmsload-mode=paginationā.
CMS Load will also cache the items automatically for better performance.
Iāve tried this solution but it still doesnāt render everything. Iām hoping itās something simple that Iām missing. It also behaves differently depending on the sort option on the nested collection.
UPDATE: I figured it out. I had the attributes code in the Head code section of the site custom code. I took a shot and moved it to the individual pages I was having problems with. It now works.
But when you view it on this page where I have cms nest and cms load set up (theh Bay Area section ends at Monte Rio). It only shows the first 100. I know there are a lot of items here, but the client ultimately wants this functionality.
Hey @nnnathaniel! I see the items being nested as they should but with pagination set, you can inspect the element and youāll see the navigation buttons with the style display: none.
Is there any extra setup you used for the working page? Iām curious on what might be causing this as the setup is correct otherwise
@Support-Luis Honestly, I have no extra set ups on those pages except for them to load completely on the template pages for the counties. I agree its strange especially because it loads all of them before it does the nesting. Once the nesting occurs then it forces pagination. Are there any other ideas you have that might solve for this?
Hey @nnnathaniel! I tried some custom code but it seems to not be working. I also noticed your Countiesā collection items do not have the multireference fields for the Cities.
Hey @Support-Luis, I couldnāt get this to work by the finsweet default functionality. Iām trying to simply nest the correct items within their corresponding county parent. I did that using Finsweetās nesting + load features. Theoretically it should work, but as you can see it wonāt nest past 100 items for whatever reason.
I ended up just using ajax to pull the data in from the correct url. We donāt have many counties that have more than 100 items, so I just have to do it for Bay Area. This is a bandaid solution, but wanted to share in case anyone comes across this problem:
<script>
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'cmsload',
(listInstances) => {
console.log('cmsload Successfully loaded!');
window.fsAttributes.cmsnest.init();
},
]);
// Function to check if Bay Area section is not empty
function checkBayAreaLoaded() {
var bayArea = $('.bay-area').parent().siblings().find("[fs-cmsload-element='list']");
// Check if Bay Area section is not empty
if (bayArea.length > 0) {
clearInterval(checkInterval); // Stop the interval
// Make the AJAX request
$.ajax({
url: 'https://petehealth.webflow.io/county/bay-area?efea0dd4_page=2',
method: 'GET',
success: function(response) {
// Parse the response HTML content
var $responseHtml = $(response);
// Extract the desired selector and its contents
var newItemsHtml = $responseHtml.find("[fs-cmsload-element='list']").html();
// Replace the existing items on the page with the fetched items
$(bayArea).append(newItemsHtml);
},
error: function(xhr, status, error) {
// Handle errors
console.error(status, error);
}
});
}
}
// Check if Bay Area section is loaded every 500 milliseconds
var checkInterval = setInterval(checkBayAreaLoaded, 500);
</script>
Obviously when I update to the live server, Iāll be updating the urls, but seems to be my best option at the moment.
Hey @nnnathaniel! Can you share a read-only? Iād like to take a look at the setup. There should be no need to write the request yourself to fetch the data as CMS Nest does this.
@nnnathaniel Iāve taken a look at the setup once more. Interesting issue but I think it boils down to the solution only fetching the items loaded (by loaded I mean published and available in the HTML without the page loading, as the page is not loaded CMS Load can not load all items on the same page) natively by Webflow, as the limit is 100 items per page only the first 100 are fetched correctly.
Your solution is the best approach as you are nesting 189 items on one single item which is also the first time I have seen this use case.