4

The problem is that you are doing .relatedTo(category) but the variable you are passing is called relatedTo, not category. Just like with limit, based on your code, it should be .relatedTo(relatedTo). Also, it should be part of the same hash as your limit. However, you can't pass a category object to a component and will need to pass its id instead (docs). ...


3

This is oddly similar to this question. The problem is that your Sprig component includes the wrapper (the div with the masonry class), so reloading the Sprig component not only replaces the items, but also the wrapper itself. Masonry keeps a reference to this wrapper (the element masonry was initialized with) and uses it to find new children. Since the ...


3

Looking at the example from the Sprig Cookbook, it looks like the results container should live outside the sprig.isInclude: {% if sprig.isInclude %} <select sprig s-target="#results" name="verdict" id="verdict"> {# loop through options #} </select> <select sprig s-target="#results" ...


3

That's a lot of code to post in a question! The basic gist is that instead of merging new related params with relatedParams|merge and then applying to the query, you can call andRelatedTo(newParams) directly on the query. {% set productsQuery = craft.products %} {% set someEntryId = craft.app.request.queryParam('someEntryId') %} {# BEFORE #} {% if ...


2

My suggestion would be to give the Select All Values checkbox a unique name. That way, you can easily detect whether it was selected or not. You should also break dropdown_field out into 2 variables to avoid confusion. {% set select_all_values = select_all_values ?? false {% set dropdown_field_options = ['dropdown_value_1', 'dropdown_value_2', '...


2

The problem that you expect your qty variable to be an array of guests and initialize it like that, but once you set a quantity it will be an integer, so the loop won't work correctly. See this line: {% set qty = qty ?? [['']] %} This initializes qty to an array containing another array containing an empty string (by the way, why do you need the nested ...


2

I ended up using the following code - I just didn't come up with it earlier. I had to index the newsCat array used to denominate the single checkbox names. {% set newsCat = newsCat ?? '' %} {% set relatedTo = newsCat|join(',') %} {% set entryQuery = craft.entries .section('news') .limit(5) .relatedTo(relatedTo) %} {% for category in craft....


2

Checkbox input field names should be in array format (not specific to Sprig), so I expect this should work. <input sprig type="checkbox" class="filter_checkbox" name="newsCat[]" id="checkbox_{{ category.id }}" value="{{ category.id }}" {{ category.id in newsCat ? 'checked' : '' }}>


2

Sprig will use whatever your site's base URL is set to, to construct the action URL. Ensure in Settings → Sites that the base URL is either set to an absolute path starting with https://, or if an alias or environment variable, that it is defined as an absolute path starting with https://. Also be sure to either force the www subdomain or force a naked ...


2

Because of your component's element structure this is slightly more complex. I just added a new recipe to the Sprig cookbook called "Load More Complex" which should provide you with the solution, although you may want to move the button outside of the #results div. https://putyourlightson.com/sprig/cookbook#load-more-complex


2

Do you get any error messages in the console? This will tell you what's going wrong with Swiper internally. Educated guess: Swiper probably stores some state with references to existing DOM nodes / cards. When sprig re-renders an element, it completely replaces the subtree in its scope, so this will invalidate the state stored in the Swiper instance. You ...


1

Turns out the error was elsewhere in the template where I had forgotten to add the .all() statement. The code in the example is error free.


1

One thing that stands out is that you're checking myQuery | length instead of items | length. Though I've tested it and this doesn't actually cause a deprecation error in my setup. Have you tried clearing the deprecation warnings in the backend manually? They won't disappear automatically if you change the template, but will stay visible until cleared ...


1

You need to apply the category filter to the entry query. {% set categoryId = categoryId ?? '' %} {% set entryQuery = craft.entries ({ search: search, section: 'articles', limit: 2, relatedTo: categoryId, }) %} And also update the select field to match. <select sprig name="categoryId" id="category" value="{{ ...


1

Duplicate of https://github.com/putyourlightson/craft-sprig/issues/118 The code is correct and what you are experiencing is likely due to local browser caching.


1

From your code sample it looks like you may be using Blitz to cache the page, in which case this is likely neither a Sprig issue nor a Snaptcha issue. A CSRF token is a dynamic token which should not be statically cached. You would normally use the {{ craft.blitz.csrfInput() }} tag but since you are using Sprig, I'd recommend you look into implementing the ...


Only top voted, non community-wiki answers of a minimum length are eligible