Widget position

Hello everyone,
I’m trying my hand at creating a widget.
I created a simple button with graphics equal to that of the collections etc.
I would like to place the button inside the block as phpLite is doing.

The button simply goes to the frontend of the site.

$this->on("admin.dashboard.widgets", function($widgets) {

  $widgets[] = [
      "name"    => "amfrontbutton",
      "content" => $this->view("amfrontbutton:views/widgets/dashboard.php", compact('amfrontbutton')),
      "area"    => 'main'
  ];

  }, 100);

Thank you

Because you mentioned the phpLiteAdmin addon - have a look at it’s source code:

The menu item appears both in the modules widget and in the top bar.

I have tested this but route field does not link to an external link.

As I wrote, I want to make a button to get the customer to the frontend

I can’t look at the source right now. I’m in the middle of switching to a new computer. This may take a while…

My best bet is to try it with a full url and if that doesn’t work, you have to create your own widget with a button.

One option, maybe a bit dirty is to inject the link via javascript, for example, create in addons a folder, e.g. CustomBarAction with two files:

addons/CustomBarAction/bootstrap.php

<?php

if (COCKPIT_ADMIN && !COCKPIT_API_REQUEST) {
  $this->helper('admin')->addAssets('custombaraction:custom-action.js');
}

addons/CustomBarAction/custom-action.js

window.setTimeout(function() {
  App.$('.app-modulesbar').append(App.$('<li><a target="_blank" href="https://your-fe-url/">frontend</a></li>'));
}, 500);

and you should have:

1 Like