Is there a method where I could generate a heading using a grid column value?

My grid is output as a table sorted by the column “sport” with values like “hockey, baseball, soccer” etc.

So as I loop through the different sports, I’d like a heading for each. So when it shows the entries sorted with the value ‘hockey’ there would be a heading ‘Hockey’ displayed. Any thoughts on doing that?

1 Answer 1


One way to do this. You add a grid field for the heading value, then when you input data ensure that field is only present in the first row of a group.

The template code would then go something like this:

Lets say your grid name is sport_grid, and the grid has two field, grid_heading and grid_item

{if sport_grid:sport_heading}<h1>{sport_grid:sport_heading}</h1{/if}

So what the tenplate is doing is only outputting the heading if it exists.

  • Works, thanks! One of those things when you see it you slap your forehead and say "of, course".
    – Jeremy
    Nov 17, 2013 at 19:36
  • Actually that doesn't quite work, now that I've added more data. It just spits out the heading title for as many rows their are in the grid. So if I have 10 entries, it shows the header 10 times then shows the data below. The idea is I have grid:
    – Jeremy
    Nov 17, 2013 at 20:34
  • If I have a grid: PlayerName Number Sport I want to output: Sport (Heading) --- PlayerName Number PlayerName Number PlayerName Number Sorry hard to show without linebreaks.
    – Jeremy
    Nov 17, 2013 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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