5
votes
Accepted
How to get a Super Table relation in PHP?
$element = Craft::$app->getUser()->getIdentity()->priceTable->relatedTo([
'targetElement' => $product->id,
'field' => 'product'
])->one()
But to be honest your code in ...
5
votes
Dynamic upload location for Super Table within a Matrix field?
Have you tried using {owner.owner.slug}? If you've got Matrix > Super Table > Asset, and you're trying to get an attribute on the Entry/Element, you'll need to go two level out from the Super Table ...
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?
4
votes
Accepted
Using Element API to output Super Table fields
Here is a solution I found. Define an empty array, then loop over it, providing whatever keys you want to return from the Super Table fields. Simply by looping over $block->columnTextBlocks (the ...
4
votes
Accepted
Editing SuperTable inside Matrix block
So you'll want to update the Super Table Block's content and to do that when in a Matrix field is a little tricky, but it can be done.
$matrixBlocks = $entry->matrixField->all();
foreach ($...
3
votes
Accepted
Entries query by Super Table field
It's basically the same as Find entries that use a specific block in their Matrix field?
You can use the base query and left join your Super Table content row
{% set entries = craft
.entries()
...
3
votes
Craft 3 CP performance
Is this a problem with only the dashboard, or the front-end also? Although this is a bad answer, waiting a few seconds to load the dashboard shouldn't be a huge deal. You will only need to access it a ...
3
votes
Accepted
Why is my Super Table field returning the ID for existing blocks?
I think the key thing here is that its a static Super Table field, which is treated differently to a repeatable one. Instead of looping through each block, there's only one. Fortunately, you have all ...
3
votes
Accepted
How can I loop through the values of a drop down within a SuperTable?
You'll likely want to do something like this:
{% for fieldtype in blocktype.getFieldLayout.fields %}
{% set field = fieldtype.field %}
Handle: {{ field.handle }}
{% if field.type == '...
3
votes
Accepted
How to show details on linked entry in CP (another field inside related entry)
Basically, what you want to do isn't possible – there's no hook for modifying the content in a relational field's input HTML.
The getEntryTableAttributeHtml hook is meant for element indexes (such as ...
3
votes
How to find the block type of Super Table field that is inside a Matrix field
That's more complicated, because fields in a Matrix are scoped to the Matrix field, which is why you can't just go:
{% set field = craft.fields.getFieldByHandle('superTableFieldInMatrix') %}
You'll ...
3
votes
Accepted
SuperTable queries on fields in fields
I think I followed this breakdown, but a screenshot of the admin could be helpful as well if this answer isn't accurate...
{% set speakers = entry.eventSpeakerList.all() %}
{% for speaker in speakers ...
3
votes
Accepted
Need to run the super table fix-content-tables from CLI
Under the hood, the Super Table fix is running a migration behind a controller, which you can call in a content migration directly in your project. I have done the same, due needing to script it in a ...
2
votes
How to use Super Table to create an Image Carousel?
Welcome to Craft!
Is it essential that you use SuperTable for this? The behavior you are describing is exactly what Matrix fields are designed to do, so you could quite easily achieve this without ...
2
votes
Accepted
Related Entry within SuperTable
You can’t use this special Twig function to get reverse related entries at all, as you’re not dealing with reverse relations in that context.
From a stageEvent entry you can just loop through the ...
2
votes
Accepted
Remove duplicated entries from SuperTable related entries
The simplest way is to create a "filtered" array, containing the unique cables, and then loop through that.
For example:
{# Build the "filtered" array of cables #}
{% set filteredCables = [] %}
{% ...
2
votes
Accepted
Sort entries by custom date in Matrix field / Super Table
I did something like this as a workaround:
Loop over entries, fetching all data you need and adding it to an array. Sorting that array with SuperSort and than displaying all info by looping over the ...
2
votes
Sorting SuperTable Field with SuperSort?
I think you need to add 'object' to your syntax if you're using {{ }}:
{{ object.tourDates.tourDate }}
Else it's { tourDates.tourDate } I believe.
See the plugins docs under Advanced sorting.
2
votes
Accepted
Matrix Field Count Records
You mean how many rows the table has?
{{ matrixblock.superTableFieldHandle|length }}
Or the number of blocks of a matrix field?
{{ parent.matrixFieldHandle|length }}
To get the number of blocks ...
2
votes
Accepted
SuperTable Field returning null
The reason the attribute for your Super Table is null is because the field is an element, which doesn't have 'simple' content. You'll find this is the exact same case for any other element like an ...
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 ...
2
votes
Accepted
Is defined conditional passing, yet causes a "do not have a method or closure named" error
This is a weird twig behavior. You have to do if stRow['caption'] is defined to make it work because of the object syntax of twig.
Sometimes the if defined statement becomes true when you don't use ...
2
votes
Accepted
Set SuperTableFields programatically
So it looks like you must get the correct block type in order for this to create new rows in the SuperTable.
First get the block type using the SuperTable service:
//you'll need to reference ...
2
votes
Accepted
Bootstrap 4 Accordion with Matrix (and SuperTable)
I'd break up the forloops a bit so you're outputting the panel container and the accordion wrapper markup once. Then for each accordion (supertable row) you're outputting that markup as many times as ...
2
votes
Accepted
Craft CMS 3 data structure advice for vehicle make, model, trim, year tagging
Goal: Filter documents by related vehicle characteristics.
My first idea would be to create it as such:
Create an assets volume where all your documents will be uploaded to.
Create a vehicle ...
2
votes
Accepted
Looping Related Entries with a Super Table
The issue is: you don't really loop your entries at all.
{# get all super table rows #}
{% set superTableRows = block.related.all %}
{% if superTableRows is not empty %}
<div class="{{ ...
2
votes
Accepted
How to remove a Super Table row on the front end?
I got a solution!
<input class="remove" type="hidden" name="fields[{{ fieldHandle }}][{{ row.id }}][type]" value="{{ blocktype }}">
So the output will be "1" if you change it to "0" and safe ...
2
votes
How to place assets in plain text fields?
Matrix fields in Craft are much more powerful than EE. In EE each Matrix row has a single set of fields available to it (a limitation of using a table-based UI). But in Craft you can set up multiple “...
2
votes
Accepted
how to create Super Table field programmatically
Not sure if this is the answer without playing, but try saving the plain text field before adding it to the super table:
// Create the super table field
$superTable = new SuperTableField([
...
2
votes
Accepted
How to exclude Super Table rows matching given entry
Where did you get this id NOT 874 syntax? I don't think that's supported. Entry fields already allow you to serach for related entries by ID, so one of those should work:
{% set myMoviesExceptJaws = ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
plugin-supertable × 82matrix × 18
craft3 × 17
templating × 11
plugin-development × 7
assets × 5
relations × 5
table × 4
forloop × 3
relatedto × 3
array × 3
entries × 2
plugins × 2
localization × 2
search × 2
elementcriteriamodel × 2
filter × 2
plugin-feedme × 2
craft2 × 2
query × 2
custom-fieldtype × 2
custom-field × 2
frontend-form × 2
table-field × 2
plugin-neo × 2