IMPLEMENTED: Feedback for Components: Missing Query Loops

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.

9 Likes

Agreed this would be fantastic

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.

4 Likes

Hi,
thank you for this suggestion. I’ve recorded an idea and we will talk internally about it. I also think this would be nice to have. :slight_smile:

Matej

2 Likes

It’s more than nice to have. I’d call it essential when the feature goes live :wink:

2 Likes

Hi guys,

We’ve implemented this feature in Bricks 1.12, now available as a one-click download from your dashboard.

You can see the full changelog here: Bricks 1.12 Changelog – Bricks

Best regards,
Matej

1 Like

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)

  • EventCardComponent(event_entry.title, event_entry.startdate, event_entry.location)

Reusable with other data

  • EventCardComponent(title=“My static tilt”, startdate=“My static date”, location=“Here”)

Conclusion
That’s another reason, why my suggestion of an essential shift in Bricks loops is necessary to avoid a ton of related problems and make Bricks ready for the future. I am sure the existing structure also overcomplicates things on the implementation of Bricks itself and adds to the long development cycle e.g. for the components.
Hopefully, we see the long necessary switch in Bricks 2.0 as there’s nothing more essential than query loops and components for efficient development.

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.