Forum
Best way to create HTML tables
Hi,
I'm using a collection to store some products. Some of the products need to have spec tables on their product detail pages. I won't know in advance how many rows or what headings will be required for the different products.
I started handling this by giving the user a text area for the whole table and essentially getting them to create a CSV. I then output the content using skip-template and loop through the lines to create my table. This works OK, but for longer or complicated tables it's a bit difficult for the admin to manage.
Can you suggest a better way to manage this while still giving me control over styling?
Thanks.
Will the tables always have a fixed number of columns? If so, I'd create a template for one row of columns, then put it in a repeater.
I like using Zurb Foundation for this kind of thing. One cool feature of Foundation is the ability to have rows with more then 12 cols or less then 12 cols and it won't sink the ship.
This might be of use to you, a custom table fieldtype:
https://github.com/siansell/perch-cms-fieldtype-table
Nice Job Michael. I think this could be quite useful to many.
I have forked on github, I hope you dont mind.
RK :)
Hi,
Not my work, another Percher from the Slack chat. But I am sure he won't mind :)
Yep it's a good one.
Mike
Thanks for the replies. I don't use Foundation at the moment because I still need to support IE8. I've loaded up the custom table field type and it looks really good, I think I'm going to use that.