Started playing with components and first major drawback I noticed is I can’t create a card and then put a query loop on it! I can get around it by wrapping the card with a div and putting the query there but now I feel I’m just adding extra divs to my builds.
I’d like to use the same cards in several places across my site but have them using different queries (related posts in one place, recent posts in another, etc.). I think if the primary parent element is a container of some kind (div, block, container) it should have the typical query options.
Yes, this is an essential feature. A single instance must support the query loop. Otherwise, the components lose their utility. Without this functionality, I might only use a template. There is no extra setup time. Let say when I set the card as <li> and save as component, it becomes problematic—I’d have to wrap it in another <div> to get query loop and switch it to <li> again. This adds unnecessary effort and bloats the markup, which is far from ideal.
Unfortunately, the implementation has severe drawbacks and there’s no way to resolve it without reworking and enhancing the query loop flexibility in bricks.
Solely providing loop functionality as an element property “query” leads to severe restrictions on creating reusable components and following best practices. It’s simply not possible with Bricks, and also nestable components can’t solve that.
Example
I have an event card component, which is looped on the event archive page. It uses my CPT “events” and ACF fields. To use it with Bricks, the component requires the “query” property and inside the component the start_date, title, location need to be statically tied to the according ACF fields.
Immediately the component becomes quite restricted in its reusability and there’s no way to use the component with static data, a different post type e.g. The Events Calendar or looping over a JSON, PHP list etc. (not available anyways).
You can’t copy & paste the component and simply reuse it on other sites.
Current state
EventCardComponent(query)
Event card with data tied to ACF
Best practice (and expected for upcoming Bricks version):
Special LOOP element to loop event_entry (CPT event and ACF fields)
P.S. Etch will do it right and provide a special loop element. If Bricks doesn’t wake up and provide an improvement on the essential query loos, I have to jump off the boat.