1

I'm curious if anyone has used Matrix Column Labels in their templates before?

SCENARIO:

I have tabular data showing table headers: ROOM #, ROOM NAME, etc...

Those double as my Matrix Column Labels. Instead of having:

<tr>
        <th width="101">Room #</th>
        <th width="223">Room Name</th>
</tr>

I'd rather have something like:

{MATRIX_FIELD}<tr>
            <th width="101">{column_number}</th>
            <th width="223">{column_name}</th>
</tr>{/MATRIX_FIELD}

I didn't see anything in the Matrix documentation to pull the column labels and was curious if anyone has done this before. Obviously I can pull in the COLUMN NAME but nothing for LABELS.

Thanks everyone!

3

I don't know of a way to get the labels in the traditional Matrix tag pair, but Matrix does have the {your_matrix_field:table} tag, which prints out a full HTML table. I believe this table uses your column names as the table headers. This might not give you the granular control over the markup that you need, but maybe it'll be good enough?

  • Thanks for the suggestion but that's going to work for me :/ I suppose I could write a SQL statement to possibly do it, but embedding the Room #, Name, etc... into my template isn't the worst thing either. I was just hoping to change the name of those th's in my field group rather than in the templates. No biggie but thanks for the help! – Mark Busnelli Jr Jan 15 '13 at 20:42
  • There is definitely no tag for it, and that data is serialized, so you'd need to grab it and unserialize the data to use that information in the template. It has come up a few times before so I'll bring it to the team for future ideas. – Lisa Jan 15 '13 at 20:56
  • Thanks Lisa! I can see that it could be very beneficial to having that option :) I appreciate the comment! – Mark Busnelli Jr Jan 15 '13 at 21:35
1

In addition to everything the others have noted...

I have used JS to create custom UI's for Matrix fields, even breaking Matrix out of a table into separate div's. A very simple solution would be to use JS to override the data you don't want.

  • Thanks Justin. I think that might be a little bit of overkill for this simple build, but I appreciate you taking the time to respond :) Makes the EE community one of the best! Cheers – Mark Busnelli Jr Jan 15 '13 at 21:36

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.