wbrowar / craft-grid

A field that lets you content manage CSS Grid in Craft CMS.
Other
18 stars 2 forks source link

Get column / row value. #15

Closed Geestig closed 4 years ago

Geestig commented 4 years ago

Is it possible to get the row or column value from certain items in the twig template? Or do you have an idea on how to fix ie11 compatibility issues? I should be as easy as adding the -ms- prefixes to make it work actually.

EDIT: I did find them when I dump the entry grid field but I cant seem to reach them.

wbrowar commented 4 years ago

Hey @Geestig have you tried the .value() Twig variable? https://github.com/wbrowar/craft-grid#getting-a-grid-value

Let me know if that works fro you.

Geestig commented 4 years ago

Yes, that's how I found it in the first place. I was wondering where the array name comes from. For example in my case it's '_pr71x3dnf' which is pretty random.

Wouldn't it be easier to add something along the lines of {{item.value.rowStart}} // {{item.value.rowEnd}} ?

{% set id = 'id' ~ item.content.id %}

{% set startRow = entry.projectGrid.value._pr71x3dnf[id].rowStart %}
{% set endRow = entry.projectGrid.value._pr71x3dnf[id].rowEnd %}
{% set startCol = entry.projectGrid.value._pr71x3dnf[id].columnStart %}
{% set endCol = entry.projectGrid.value._pr71x3dnf[id].columnEnd %}

This is how I can currently do it. This does not feel all that good though.

wbrowar commented 4 years ago

Hey @Geestig, the random identifiers match up to breakpoints and it's admittedly a big mess. If it wasn't for the amount of breaking template changes and the migrations needed, I would go back and refactor how the field values are stored to be easier to work with the field data.

At this point my plan is to see where Craft 3.x and 4.x go before making any big changes.