I am implementing the adminLTE layout for part ( or maybe all… ), of my project.
It is up and running, and I am switching to the adminLTE layout on a per action bases by adding the following code to my controller action.
// change layout for this page
$this->layout = 'adminlte';
That is working fine. My form is wrapped by the adminLTE layout.
Now I want to start activating all those wonderful goodies.
I figured I would start with something simple, like the user name.
So in my view, I create a block with the following code:
// get user name
$this->beginBlock('username');
echo Yii::$app->user->identity->username;
$this->endBlock();
Then in the header.php file of the layout I add the following code in place of the hardcoded name of the user.
<?php if (isset($this->blocks['username'])): ?>
<?= $this->blocks['username'] ?>
<?php else: ?>
Unknown User!!!
<?php endif; ?>
This works just fine. However, I am expecting to have a LOT of stuff like this. The adminLTE has a lot of goodies, and some of them are going to be rather complex. They are also going to be the same for all pages.
I am thinking that widgets would be the best way to do this. But I have not done anything much with widgets yet.
Can I do pretty much anything with a widget that I can do with a controller and its associated views?
What sort of directory layout should I use for these widgets to keep them together. I may want to package them up at some point.
I was thinking something like
basic
|
+--components
|
+--adminLTE
|
+--userinfowidget
|
+--notificationwidget
|
+--messageswidget
|
+--otherwidget
|
+-- ...
Thanks
-John