Hot answers tagged

8

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 }} {% endfor %}


4

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 import plugin to bring in the data. The plugin allows you to map the data to the fields in Craft. Craft supports tables natively but you need a way to import ...


4

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


4

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 ala .myRedactorWrapper th etc.


3

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 tables need different classes, this isn't a solution, though.


3

Reverse it! <ul> {% for row in entry.myTableFieldHandle|reverse %} <li>{{ row.columnHandle }}</li> {% endfor %} </ul>


2

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 %} {% case 'day' %} <h2>{{ block.day.format('l - F j, Y') }} </h2> {% case 'event' %} <table> <tbody> <tr&...


2

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 block.getFieldLayout().getFields() %} {% set type = field.getField().type %} {% switch type %} {% case 'Table' %} ...


2

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 wrong order. Something like the following (although my syntax might be off a bit). {% set blocksByDate = entry.scheduleMatrix|group(day|date("Y-m-d") ) %} {% for ...


2

How about this one? It's a table field type.


2

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 address, city, etc.) To leverage Craft's relations, create a new field (Organization) that relates back to the Organization channel you just created and add it ...


2

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


2

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 your plugin. For the people that already have your plugin installed, you need to create a migration that also creates the table. The code for the table ...


2

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 to use the first row as his/her column headings. I've found that it works quite well!


2

Assuming your example code, something along these lines will help... {% if entry.yourTable | length %} <table> {% for row in entry.yourTable %} <tr> <td>{{ row.column1 }}</td><td>{{ row.column2 }}</td><td>{{ row.column3 }}</td> </tr> {% endfor %} </table> {% endif %} ...


2

The name to use to hide the Strikethrough button is deleted.


1

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 would argue this is possibly more confusing and brittle since an admin could accidentally update the answer choices without updating the correct answer field. The ...


1

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 block.caption %} <caption class="caption">{{ block.caption }}</caption> {% endif %} {# Setup #} {% set rows = block....


1

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.column1 }} - {{ row.column2 }}){% if not loop.last %},{% endif %} {% endfor %}' {% endjs %} Output: <script>var table = '(Value 1-1 - Value 1-2),(...


1

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 whatever you want with: {{ columnValue }}</p> {% endif %} {% endfor %} {% endfor %}


1

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 cover the client requirement, as that will also allow you to better control the way tables are created and also set up some client-friendly table styles.


1

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 row in entry.howItWorksTable %} and in that loop each time you display a row, you can get the corresponding image (using the loop variable index0): {% set ...


1

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 checking {% if block.type == "innhold" %} which will fail, as a SuperTableBlock doesn't have an attribute type at all, unlike Matrix.


1

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/last consecutive block of this type #} {% set type = block.type.handle %} {% set isFirstConsecutiveBlockOfType = (loop.first or type != block.getPrev().type....


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