[Support request] alternate between two containers on every other item of query loop

Home Forums Support [Support request] alternate between two containers on every other item of query loop

Home Forums Support alternate between two containers on every other item of query loop

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #2587764
    Jack

    I’m building a page where I want to loop through posts but want to change the layout for every other line based on the index of the query loop.

    For odd rows I’ll display container a and for even rows container b.

    Is it possible to perform logic based on the index?

    Thanks in advance

    #2588000
    Fernando
    Customer Support

    Hi Jack,

    Logic based on index design is not possible.

    What sort of change are you looking at? Can you provide an example? Perhaps we can apply a custom CSS code to implement it.

    #2589328
    Jack

    Each post describes an art exhibit. I’m using a container with a two-column grid.

    In the even rows, I want art in the left column and text in the right column.
    In the odd rows, I want text in the left column and art in the right column.

    In a for 1 = 1 to 100 loop, I would look at i being odd or even and react to that by displaying the proper container.

    #2589352
    Ying
    Staff
    Customer Support

    It will require custom CSS.

    Can you link us to your site to take a look at what you’ve built?

    #2590524
    Jack

    The site is not yet public. Link in private Info field

    #2590621
    David
    Staff
    Customer Support

    Hi there,

    would a simple CSS option work for you?
    Try adding this CSS to see how that works:

    .gb-query-loop-item:nth-child(even) .gb-grid-wrapper {
        flex-direction: row-reverse;
    }

    You may want to add some CSS Classes into the mix here, so it doesn’t affect every Query Loop.

    Let me know

    #2596584
    Jack

    Score! Thanks for the assist.

    #2597688
    David
    Staff
    Customer Support

    You’re welcome

    #2635332
    Bjorn

    I’d like every second image in the query loop under products on the below page be right-aligned. Is that possible?

    https://matheachem.com/fertilizers/

    #2635334
    Fernando
    Customer Support

    Hi Bjorn,

    For assistance, can you open a new topic here instead?: https://generate.support/

    #2635362
    Bjorn

    Ok. Done.

    #2635381
    Fernando
    Customer Support

    Thank you! Let’s continue there.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.