I'm building a table seating view. I have n guests(i), i=1..n and m chairs(j), j=1...m (n=<m). Guests are defined in a CPT with a custom field chair_number. The table layout is defined with a CSS GRID. In this grid, chair fields are assigned with n classes .chair1 .... chairn, so a class per seat. In the grid other elements are defined, such as tables. So it is not a simple table. You can see a temporary example here: hidden link (the images in this example are put in manually)
What I know try to accomplish is to add class(chair_number(i) to a div that contains featured image of guest(i)). That would place the image of the guest on its assigned chair. So, something that would function like this quasi-code
for i=1:n
<div class(chair_number(i)>
[wpv-post-featured-image](i)
</div>
endif
Is it possible to create something like this with Toolset Views? If not, do you have suggestion to achieve such a view via another route?
After a night of sleep, it occured to me that I could add something.
For me, it;s safe to assume that chairs are continuously filled starting from 1 to m. So, I could also sort on the custom field "chair" and create a loop from there. Creating the loop in Toolset is not difficult. In the end, I need two things in this approach:
1) acces to the index i or j in the loop
2) a means to concatenate the string "chair" with index i into a string "chair_i" (as the class I need)
Thanks for your prompt reply. The links you provide help me to a certain extent. The remaining challenge is how to concatenate the chair number, obtained with the shortcode [types field='deelnemer-stoel' format='FIELD_VALUE'][/types] with the prefix string "chair_" to obtain the string "chair_XX" (with XX the chair number from the shortcode). "chair_XX" is to be used in a piece of HTML like:
<div class="chair_XX"> ...... </div>
Being a markup language, HTML does not provide such a concatenation function, so I expect that a bit of (inline) PHP or Javascript is needed. I expect this to be trivial for an experienced programmer, but unfortunately, it is beyond my expertise. Can you help me out how to do this?
Blimey! I just didn't try that! It never occurred to me that it could be that simple. I just assumed it wouldn't work as attribute. But it does. I was thinking way to complex.