<?php echo '<td style="width: ' . ($cell['cell_span'] / $cell_total) * 100 . '%" colspan="' . $cell['cell_span'] . '" class="' . echo $cell['cellclass'] . '">' . kirbytext($cell['cell_content']) . '</td>'; ?>
How can I take cell_class value in td?
<?php echo '<td style="width: ' . ($cell['cell_span'] / $cell_total) * 100 . '%" colspan="' . $cell['cell_span'] . '" class="' . echo $cell['cellclass'] . '">' . kirbytext($cell['cell_content']) . '</td>'; ?>
How can I take cell_class value in td?
You used an “echo” too much I think.
<?php echo '<td style="width: ' . ($cell['cell_span'] / $cell_total) * 100 . '%" colspan="' . $cell['cell_span'] . '" class="' . $cell['cellclass'] . '">' . kirbytext($cell['cell_content']) . '</td>'; ?>
I recommend not to echo HTML tags anyway. Your code will look much cleaner, is easier to understand and less error prone, if you just echo your content within the tags. You also might have a typo, “cellclass” or “cell_class”?
<td style="width:<?= ($cell['cell_span'] / $cell_total) * 100 ?>%" colspan="<?= $cell['cell_span'] ?>" class="<?= $cell['cell_class'] ?>">
<?= kirbytext($cell['cell_content']) ?>
</td>
<?php $cells = yaml($page->table());if (count($cells)): ?>
<?php
$cell_spanned = 0;
$cell_ini = 0;
?>
<?php foreach($cells as $cell): ?>
<?php
if($cell_spanned < 1) {
echo '<tr>';
}
$cell_ini++;
if($cell_ini == 1) {
$cell_total = $cell['cell_total'];
}
$cell_spanned += $cell['cell_span'];
?>
<td style="width:<?= ($cell['cell_span'] / $cell_total) * 100 ?>%" colspan="<?= $cell['cell_span'] ?>" class="<?= $cell['cell_class'] ?>">
<?= kirbytext($cell['cell_content']) ?></td>
<?php
if($cell_spanned == $cell_total) {
echo '</tr>';
$cell_spanned = 0;
}
?>
<?php endforeach ?>
<?php endif; ?>
Thank you so much Texnixe
my class: cell_class
I got this error: Undefined index: cell_class
I forgot something?
Well, then the field is not called cell_class but something else… My crystal ball doesn’t tell me what’s in your blueprint or text file…
Blueprint
table:
label: Bir Tablo OluĹźtur
type: snippetfield
style: items
snippet: panel/table
modalsize: large
fields:
cell_total:
label: HĂĽcre - Toplam
type: number
icon: calculator
required: true
width: 1/2
help: her sıradaki maks. hücre
cell_span:
label: HĂĽcre - BirleĹźtir
type: number
icon: calculator
required: true
width: 1/2
help: birleştirilecek hücre sayısı
cell_content:
label: Hücre - İçerik
type: textarea
cell_class:
label: Cell - Class
type: text
icon: code
width: 1/1
help: this cell's classname
Thank you so much for helping
What was the problem after all? The key seems to have been correct?
Seems like there’s an empty cell_class
field somewhere.
Instead of …
<td class="<?= $cell['cell_class'] ?>">…</td>
… you try to use e …
<td class="<?php e(isset($cell['cell_class']),$cell['cell_class']); ?>">…</td>
Hm, an empty value wouldn’t throw the missing key error, though. Unless the fieldname was missing from the file as well (when manually editing, because when editing via the Panel, all keys are added).
Oh yes, you’re right. But obviously there’s a missing key?!
So it seems. When editing manually, it would make sense to use e()
helper as you suggested.
Or better still anyway, use the toStructure()
method instead of yaml()
. It doesn’t throw an error if the key field doesn’t exist.
Yepppp The key was not correct
Now it works fine