Hi there!
I’ve created a new widget for the dashboard (just a link to a user guideline customized for a client) and although it’s working perfectly in my local instance, when i’ve uploaded the files i’ve the next error.
Notice: Undefined index: html in …/panel/app/views/dashboard/index.php on line 42
Fatal error: Method Kirby\Panel\View::__toString() must not throw an exception, caught Error: Function name must be a string in …/panel/app/layouts/app.php on line 0
Any help or suggestion will be extremely appreciated.
Does it work if you remove the widget again? If so, could you please post the code of your widget’s main PHP file?
So sorry! I should explain myself better.
The panel is still working. I’ve the error just below the widget content. Like this:
And the widget content is a veeeery easy php
<?php
return array(
'title' => array(
'text' => 'Manual de ayuda',
'link' => 'link to page',
'target' => '_blank',
'compressed' => true
),
);
That’s all.
Thank you very much @lukasbestle !
Do you have take a look in the widget docs section?
1 Like
texnixe
September 26, 2016, 4:37pm
5
You probably want something like this:
<?php
return array(
'title' => 'Manual',
'html' => function() {
return '<a href="link" target="_blank">Link to manual</a>';
}
);
You can place the HTML in a separate template file as well.
1 Like
The html function is the key!
I don’t know why is working right in local without the HTML function
Anyway your code works perfectly right in the remote server @texnixe . Even mine with the HTML function, but I prefer your option anyway
Thank you guys, learning everyday thank you all.
1 Like
texnixe
September 26, 2016, 5:01pm
7
The undefined index message is thrown, because in line 42 of /panel/app/views/dashboard/index.php
there is this line:
<?php echo $widget['html']() ?>
So the index html
is expected to be in the return array.
Roger that! I will check better the error thrown next time.
Do you have any idea why is working locally? I think that got me confused and maybe i can learn something more today
Thank you again!
texnixe
September 26, 2016, 5:14pm
9
Unfortunately not, in my local environment it doesn’t work.
Maybe your local PHP setup doesn’t display errors while your server does? It should probably be the other way around.
1 Like
Hum! That’s a very interesting idea. Going to check it!
1 Like