Uploading a widget and getting an "Undefined index"

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


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

You probably want something like this:


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 :confused:

Anyway your code works perfectly right in the remote server @texnixe. Even mine with the HTML function, but I prefer your option anyway :slight_smile:

Thank you guys, learning everyday thank you all.

1 Like

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 :smiley:

Thank you again!

Unfortunately not, in my local environment it doesn’t work.

Oki. So problem solved!

Maybe your local PHP setup doesn’t display errors while your server does? It should probably be the other way around. :wink:

1 Like

Hum! That’s a very interesting idea. Going to check it!

1 Like