Using Kirby 3.3.0-rc.2 in the same development system I followed Kirby-Docs: How to create your own KirbyTag and added /site/plugins/your-plugin/index.php
with the published content:
Kirby::plugin('your/plugin', [
'tags' => [
'wikipedia' => [
'html' => function($tag) {
return '<a href="http://wikipedia.org">Wikipedia</a>';
}
]
]
]);
When I now press the key F5
(Reload the panel), I get:
The JSON response from the API could not be parsed.
Please check your API connection.
[Added:]
I checked it with a new installed Starterkit 3.2.5 and Kirby 3.3.0-rc.2. It is the same.
I changed nothing in the content files!
Does the file start with an opening PHP tag like so:
<?php
Kirby::plugin('your/plugin', [
'tags' => [
'wikipedia' => [
'html' => function($tag) {
return '<a href="http://wikipedia.org">Wikipedia</a>';
}
]
]
]);
No, you added this line after my test, thank you very much!
I hope, this will solve my problem.
But I can check this not till tomorrow and will tell you what I get.
PHP files always need to start with an opening tag, otherwise the code is output 1:1 to the browser without being executed.
I’ve added it to the docs to make the examples clearer.
1 Like
There are many code parts in the docs, which don’t have that first line…
I have a problem with a custom code in another tags file, which I have to update from Kirby 2 to 3. I wanted to check “quick and dirty”, whether this is affected by the new Kirby version.
Normally I know about this line…
Tomorrow I will pay more attention…
Thank you very much. For the code from the docs it helped.
But my real problem was, that my tags
code
... // some code
'html' => function($tag) {
$subpages = $tag->parent()->children();
if($children == 'visible') {
$subpages = $subpages->visible();
} elseif($children == 'invisible') {
$subpages = $subpages->invisible();
}
... // some code
had some deprecated code, which I did not get reported although debug was enabled.
But that is another storry.
And I have this code now updatet too 