How do I use yii2-dashboard? - yii2

I would like to use a dashboard for my system. I found this Yii2-dashboard module. I am not sure if it is like GII where you can create models, CRUD, etc. In short, does yii2-dashboard has a UI like GII? Or should I manually code it? Thanks a lot!

As the docs says, you have to code a little bit: Where do i go now - Yii2 Dashboard
You can start adding panels on to your dashboard using this method
\Yii::$app->dashboard->addPanel($name,$view,$section);
The addPanel() function accepts 3 parameters
$name; /** name of the panel **/
$view; /** content of the panel **/
$section; /** section where the panel will be displayed**/

Related

Android TV how to make a tab on the top of screen?

I want to make a tab on the top of screen like this :
I know that tabLayout and viewPager can solve it on the phone. However, how to do on the android tv?
There are several ways you could do this - but I think the short answer is no matter what you do, it'll have to be custom. So far leanback is the only framework offered by Google for any TV specific components and that framework only provides you with a left navigational drawer.
I can offer one solution for if you're using leanback. You could use a BrowseFragment with a custom TitleView which has tabs and keeps track of the focus of the tabs within. As long as your custom view implements TitleViewAdapter.Provider then you can use it with a BrowseFragment as the TitleView. The benefit to this is that you can have it automatically animate in and out from the top with little additional work.
As for the custom view, you can specify focusRight and focusLeft on each tab and have an listener onFocus or onClick to swap out the fragments in the BrowseFragment. This class in leanback shows how to swap fragments in the BrowseFragment (specifically PageRowFragmentFactory).
I would highly recommend you clone the leanback showcase app that the Android team put together and play around in that.
For the specifics of customizing the TitleView, it'll look something like the below:
Create your custom view
class YourTitleView extends RelativeLayout implements TitleViewAdapter.Provider {
... do custom view setup/logic here ...
}
Create an XML file named lb_browse_title.xml. This overrides leanback's layout which they use to create their TitleView.
Put your title view in this lb_browse_title.xml file and ensure it has the id of #+id/browse_title_group. This is so leanback knows to grab your title view.
<com.your.android.app.views.YourTitleView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/browse_title_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/browseTitleViewStyle" />
Then create a Fragment that extends BrowseFragment and it should apply your title view automatically. Please refer to the leanback-showcase app for how to get a BrowseFragment up and running.

PHPStorm: Auto generate the inheritdoc documentation when implementing methods of an abstract parent class

Been using PHPStorm and whenever I implement the abstract method of a parent class to some subclass I run the Implement Methods command in which it auto-generates the function blocks and its doc blocks.
It annoys me that I still need to manually modify the doc blocks to {#inheritdoc}.
My question now, Is there a way to configure PHPStorm to generate {#inheritdoc} doc block when implementing methods instead of it generating the original doc block?
In the menu go to Code > Generate > Implement method (Ctrl+I)
Check 'Add PHPDoc'
Select 'With #inheritDoc tag'
Source: https://youtrack.jetbrains.com/issue/WI-16547

Wordpress―run JS after Widget was created in Admin panel

I am developing a Wordpress Theme that includes a custom Widget, everything works out fine but there is one thing I do not know how to implement correctly:
I would like to run some Javascript after the Widget Instance was created in the admin panel, that means in the very moment after the widget was dropped in a sidebar, not after saving.
I have no Problems with running JS after the page was loaded or the Widget was saved, I want to run Javascript after the User just dropped a new Instance into the side bar, what actually can happen more than once without page reload.
Greetings philipp
Another way of doing this I just figured out --
I'm going to show a more complex example involving dependencies, though realise the bit in Custom_Widget::form() is the real answer to the question:
function add_js_deps() {
if (is_admin()) {
wp_enqueue_script('jquery-ui-accordion');
}
}
add_action( 'init', 'add_js_deps' ); // "init" because wp_enqueue_scripts is too late.
// Then in the widget....
class Custom_Widget extends WP_Widget {
public function form($instance) {
/** Collapsing accordion-y form HTML here **/
wp_enqueue_script('custom-js', plugins_url('js/my.js', __FILE__), array('jquery-ui-accordion'), '1.0.0', true);
}
}
I'd argue this is the better route as it has dependency management and you won't have a bunch of JavaScript mid-way into your DOM. Using wp_enqueue_script is generally always the more WordPressian way of doing things regardless.
Place a script tag in the widget form function.
function form($instance)
{
?><script type="text/javascript">console.log("firing javascript");</script>
<?php
//form details...
}
I eventually went a different way with this. Loaded our plugin admin script on the page using wp_enque_script and then just used jquery selectors and an event handler to target the right widget.
$('div.widgets-sortables')
.on('sortstop', function (event, ui) {
// only if this widget has the proper identifier...do something
if (ui.item.find('.my_widget').length == 0)
return;
run some function...
Still not my favourite technique...but it is cleaner then coding it in the widget. Does require a variable to track created widgets and using the "this" variable is useful

create a link that opens a page and runs a function contained in the link

I am still learning PHP so my question may seem a little obvious but...
My question relates to opencart but is probably quite a common practice on many websites. I am creating a opencart module and in that module i have several buttons that complete different tasks. Now I have assigned the button the correct 'href' with the path and appropriate action. eg
$this->data['dosomething'] = $this->url->link('module/modulename/dosomething', 'token=' . $this->session->data['token'], 'SSL');
Note: I have called the module and action a general name for the purposes of my question.
In the controller I then have a private function called 'index', followed by a private function called 'dosomething' like below
public function index() {
* insert code *
}
public function dosomething() {
*insert code*
$this->redirect($this->url->link('module/modulename', 'token=' . $this->session->data['token'], 'SSL'));
}
Now, I would like to know how do I get the button to direct to the module controller and then run the 'dosomething' function. I could put something information in the link, ie action=dosomething and do it this way but most of opencart simply uses the text of the last / as the action. If I use the href stated above I get a error as it is trying to find the controller and template located in 'module/modulename/dosomething' rather than the controller and template located in 'module/modulename' USING the function 'dosomething'.
I hope this makes sense. I see that many other scripts in opencart successfully use this method but I just cant figure out how? I am sure I missing something obvious.
What you are doing is correct. OpenCart's framework will use the third piece of the route if specified as the method. If you try
public function dosomething() {
die('OK');
}
Then go to the url you've got, it should just show a blank white page with OK written on it. My guess is the error doesn't actually relate to the controller being an issue, and more to do with something else you've done. Either that, or the method and the third part of the route aren't a match, or the dosomething method isn't public

How do you extend Kendo UI widgets

I couldn't find any official documentation about extending Kendo UI widgets or making composite controls on Kendo UI's website.
Are there any examples of how to do this?
I'm about to write a post on this, but you can checkout the following project on GitHub for creating plugins. Currently there is a composite control for this...
https://github.com/kendo-labs/kendo-plugins
Here is a live fiddle example of a compositing an AutoComplete and a ListView...
http://jsfiddle.net/burkeholland/G2f4a/embedded/result/
// thanks for making put a useless comment here stackoverflow
There's official documentation now:
How to Create a Custom Widget
Here's a link to semi-official community plugins.
And here are some examples of widgets created by John DeVight.
An SO post showing a simple example which extends the mobile list view.
Thanks! With this help I can do that:
kendo.data.DataSource.prototype.dataFiltered = function () {
// Gets the filter from the dataSource
var filters = this.filter();
// Gets the full set of data from the data source
var allData = this.data();
// Applies the filter to the data
var query = new kendo.data.Query(allData);
// Returns the filtered data
return query.filter(filters).data;
}