Hot answers tagged

8 votes

Templating SuperTable

There's no block types with SuperTable, so no need to check that. Other that that it works just the same as Matrix fields. {% for row in superTableField %} {{ row.textFieldInSuperTableField }} {% ...
user avatar
  • 35.9k
4 votes

Importing tables and Tablepress like plugin functionality

How do you plan to manage it in Craft? If you want each row as a separate entry, create a section to hold the data, setup the fields you want to use to match each column, then use Bob Olde Hampsink's ...
user avatar
  • 6,477
4 votes
Accepted

Adding Columns to a table

With the supercool table maker you can create dynamic tables. Is this what you are looking for?
user avatar
4 votes

Is there a better way to make tables in Craft?

I'd use a Table or SuperTable field But if you want to stick to a Redactor Rich Text field, put a wrapper <div> around the {{ entry.redactorField }} Twig markup, and use CSS to style the table ...
user avatar
3 votes

Redactor settings: stripping out classes from table

If all your tables should use the same class or classes, you could use my Retcon plugin to add the classname(s) in Twig: {{ entry.body|retconAttr('table', {class: 'someclassname'}) }} If different ...
user avatar
3 votes
Accepted

How to reverse the rows in a table?

Reverse it! <ul> {% for row in entry.myTableFieldHandle|reverse %} <li>{{ row.columnHandle }}</li> {% endfor %} </ul>
user avatar
  • 66.5k
2 votes

Opening and closing table within a switch

I think the opening and closing tags in the table are in the wrong spot. Try opening and closing the table inside the event case. {% for block in entry.scheduleMatrix %} {% switch block.type %} {% ...
user avatar
2 votes
Accepted

How do I get the column headers of a table in a matrix?

Updated code to output the entire table (headers and data). Try this: {% set entry = craft.entries.section('sectionHandle').first %} {% for block in entry.matrixFieldHandle %} {% for field in ...
user avatar
2 votes

Opening and closing table within a switch

An alternate solution would be to add a date field to each event block, you can then group blocks by date on output, and wouldn't have to worry about the client accidentally putting an event in the ...
user avatar
2 votes

Importing tables and Tablepress like plugin functionality

How about this one? It's a table field type.
user avatar
  • 6,298
2 votes

How to make a sortable table in frontend?

I can think of a couple ways to pull this off but Craft has many of the pieces already in place. I'd create a new Channel, name it Organizations. You can add whatever fields you want in there (like ...
user avatar
  • 6,477
2 votes

Multiple editableTable in a CP page

I think you are looking for a plugin called Table Maker. I've never tried it but it looks like it lets your users create tables in the cp. Table Maker
user avatar
  • 1,517
2 votes

how to create a new table in database

Not sure I'm following 100%, but in Craft 3, you can add the code necessary to create the new table in your plugin's Install migration. That will run every time someone does a fresh installation of ...
user avatar
  • 66.5k
2 votes

Adding Columns to a table

I used the method described here: "A User-Friendly Table Field" http://www.drivesimplicity.com/blog/a-user-friendly-table-field -- instruct the user to leave columns that he/she doesn't want blank and ...
user avatar
  • 176
2 votes
Accepted

Cannot hide redactor strikethrough button when table plugin is enabled

The name to use to hide the Strikethrough button is deleted.
user avatar
  • 7,200
2 votes
Accepted

Conditionals and outputting tables

Assuming your example code, something along these lines will help... {% if entry.yourTable | length %} <table> {% for row in entry.yourTable %} <tr> <td>{{ row....
user avatar
1 vote

Table Field fixed column content(placeholder) for all entries

You can set default field values in Settings → Fields → your table field. Scroll down on the page and you will see a Default Values section (docs). Add the rows/values you need, save your field and ...
user avatar
  • 7,200
1 vote

Allow Author to Build Multiple Choice Question?

There isn't a field type or plugin I know of that will let an admin choose only 1 correct answer. One possibility would be to number the correct answer in another field like piotrpog suggests. I ...
user avatar
  • 2,573
1 vote
Accepted

How to tell whether a SuperTable column has data or is empty?

I forget who solved this for me! I think it was Michael van Dorth. <div class="table-overflow content-row"> <table class="table {{ table_class }}"> {# Caption #} {% if ...
user avatar
1 vote

Access table from Globals in script

If you want to get the values of your global table field, you need to loop through it. somewhere in a template: {% js %} var table = ' {% for row in global.tableFieldName %} ({{ row....
user avatar
1 vote

Loop by column from a table

Is this what you're after? {% for row in block.tableHandle %} {% for columnHandle, columnValue in row %} {# If not col1 #} {% if loop.index != 1 %} <p>Do ...
user avatar
  • 419
1 vote
Accepted

Redactor advanced table formatting?

There is a tables plugin for Redactor, to easily create tables direct in the editor. On top of that, I think I'd approach this using the Redactor Clips plugin to pre-create a number of tables that ...
user avatar
1 vote

Pull in images to table rows using craft.assets wilst looping through a table field

Here is what I would do: First, make an actual array of all the images (using find to make the array): {% set imageArray = craft.assets.folderId('2').find() %} Then, loop over the entries: {% for ...
user avatar
1 vote

Templating SuperTable

There are a few templating examples via the documentation - https://verbb.io/craft-plugins/super-table/docs/guides/templating-examples But as @carlcs states, I believe the issue is that you're ...
user avatar
  • 3,402
1 vote

Opening and closing table within a switch

Brandon sent over another post that answer this exact problem: Solution for Matrix-within-Matrix (or More Robust Table Fields) {% for block in entry.myMatrixField %} {# Find out if this is the first/...
user avatar
  • 1,685

Only top scored, non community-wiki answers of a minimum length are eligible