1

I’m trying to allow the author to over ride the default of 7 grid rows to be displayed on main page of article.

I have a drop down filed (limit_override) with “default,25,50,75” to start with.

I would like to have something like this, below does not work

{if limit_override =="default"}

{grid limit="7"}

{if:else}

{grid limit="{limit_override}"}

{/if}

stuff...

{/grid}

I have tried stash

Thanks

0

You should be able to work this out using something like:

{grid_field_name}
    {if limit_override == "default"}
        {if grid_field_name:count <= 7}
            {grid_field_name:grid_col_name}
        {/if}
    {if:else}
        {if grid_field_name:count <= limit_override}
            {grid_field_name:grid_col_name}
        {/if}
    {/if}
{/grid_field_name}

Or with Stash you could set_list for the grid output and then get_list with a conditional limit. Or in a separate channel:entries tag get and save the value of limit_override and use that as the limit parameter in the grid field in the main channel:entries. Haven't tested, and not sure which of those 3 ways is the fastest / most efficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.