Closed johannschopplich closed 5 years ago
I can't reproduce this in Kirby RC6 on my machine.
Thanks. I will retest in the afternoon more thourohyly. It's probably on my side then. Although I thought I had enclosed the test case into its core...
@texnixe I rechecked on a fresh starterkit (Kirby 3.0) and am able to reproduce the same error on both my local machine and a shared hosting environment. Sorry I can't narrow it down further. 🙁
Steps to reprodue:
/site/plugins/kirby-columns/index.php
About
page's text with the example provided in the cookbook articleCan reproduce it as well. I am looking into it.
I know what the problem is, there are 2 slashes missing, looks like I had something else in my local copy then what is online.
That and another issue. Could you both please try:
<?php
Kirby::plugin('kirby/columns', [
'hooks' => [
'kirbytags:before' => function ($text) {
$text = preg_replace_callback('!\(columns(…|\.{3})\)(.*?)\((…|\.{3})columns\)!is', function($matches) use($text) {
$columns = preg_split('!(\n|\r\n)\+{4}\s+(\n|\r\n)!', $matches[2]);
$html = [];
foreach($columns as $column) {
$field = new Field(page(), '', trim($column));
$html[] = '<div class="' . option('kirby.columns.item', 'column') . '">' . kirbytext($field) . '</div>';
}
return '<div class="' . option('kirby.columns.container', 'columns') . '">' . implode($html) . '</div>';
}, $text);
return $text;
}
]
]);
Basically adding two backslashes to $columns = preg_split('!(\n|\r\n)\+{4}\s+(\n|\r\n)!', $matches[2]);
And fixing $field = new Field(page(), '', trim($column));
But the really strange thing is, that the source code is ok and only if you copy from the site, the backslashes get removed.
$columns = preg_split('!(\n|\r\n)\+{4}\s+(\n|\r\n)!', $matches[2]);
In the recipe file on line 67.
@fabianmichael Sounds like a topic to have you involved.
@texnixe But also the complete code example is different from what gets explained afterwards. There the regex is $columns = preg_split('!\R\+{4}\s+\R!', $matches[2]);
@distantnative Your fixed code works in my setup. Thanks!
✅
I singly copied & pasted the code provided in the cookbook. Using it the following error will be thrown:
Trying to get property of non-object
Whoops highlights the following line:
Tested with/on: