Since this is my blog, and no one really reads it, I'm just gonna start posting a lot of stuff in here. I want to see what I can accumulate.

Then I'll check what is useful to keep posting.

That is all for right now.

Today at work I had really little to address but had to stay there, so I started thinking about digital preservation.

I want to be recording my stuff in a public space, I want to experiment with it. I want to do whatever I want. And I want to have everything together but classified.

I want a stream of all my stuff but also my publications in its own place, easy to find by its own url structure and such.

I want to own my shit.

This post was originally posted in spanish, to see that version go to the spanish blog.

This entry is dedicated to describing a little annoyance with the grid fieldtype in Statamic and how I (temporarily) solved the issue.

First of all, a little introduction: Statamic is a file based CMS that is currently under heavy development, is very powerful, and has a very straightforward and responsive control panel, perfect for clients who tend to get lost in other (more complex) CMS control panels.

So, while I was building my portfolio I wanted to show the "responsibilities" I had been in charge of in every project, so I wanted to describe them in a p, with every responsibility separated by a ',' like this:

<p>
HTML, 
CSS,
Logo Design
</p>

So in my entry file I used the grid, with a name of responsibilities and individual grid elements named responsibility, like this:

responsibilities:
  - 
      responsibility: HTML
  - 
      responsibility: CSS
  - 
      responsibility: Logo Design

The idea was to use a variable helper with an if statement, {{ if last }} was the logical choice:

{{ responsibilities }} {{# my grid element #}}
<p>
{{ responsibility }} 
    {{# my grid individual entry #}}
{{ if last }}{{ else }},{{ endif }} 
    {{# show a ',' after every grid entry except for the last one #}}
</p>
{{ /responsibilities }}

But this had no effect at all.

My (temporary) solution

So while 1.2 was still the most current version I found myself a workaround. I used two calls to the grid. the first as is, using a limit="1", the second using an offset="1" and including the ',' before every grid entry in the second call:

<p>
    {{ responsibilities limit="1" }} 
    {{ # the first call on the grid # }}
{{responsabilidad}}
{{/responsabilidades}}

{{responsibilities offset="1"}}
    {{ # the second call call on the grid # }}
, {{responsibility}} 
    {{ # using a , in front of the responsibility # }}
{{ /responsibilities }}
</p>

Another solution (available from 1.3)

In my bug report on this issue Jack McDade suggested the use of {{ if index == total_results }}{{else}}, {{ endif }} which totally works on version 1.3.

I'm still waiting to be able to use it with {{ if last }}, but for now, any of these two works perfectly.

So, if you have something to add to this, a comment would be greatly appreciated.

Another simplified solution (Thanks to Ian Pitts)

Thanks to Ian Pits for the comment below, in which he tells me about a simpler way to do it:

{{ unless index == total_results }},{{ endif }}