Site Daemon
1. File Structure
myfirstwidget/Controller.php
myfirstwidget/manifest.php
myfirstwidget/index.tpl
2. File Content : myfirstwidget/Controller.php
<?php
class Widget_MyfirstwidgetController extends Engine_Content_Widget_Abstract
{
public function indexAction()
{
// do nothing
}
}
?>
3. File Content : myfirstwidget/manifest.php
<?php
return array(
'package' => array(
'type' => 'widget',
'name' => 'myfirstwidget',
'version' => '1.0.0',
'path' => 'application/widgets/myfirstwidget',
'repository' => '',
'meta' => array(
'title' => 'My First Widget',
'description' => 'My First Widget.',
'author' => 'Me',
),
'directories' => array(
'application/widgets/myfirstwidget',
),
),
// Backwards compatibility
'type' => 'widget',
'name' => 'myfirstwidget',
'version' => '1.0.0',
'title' => 'My First Widget',
'description' => 'My First Widget.',
'category' => 'Widgets',
)
?>
4. File Content : myfirstwidget/index.tpl
<?php
// Get user id viewing page
$user_id = $this->viewer()->getIdentity();
// display user id
echo $user_id;
// this is just a dummy settings just to get the database link
$sTable = Engine_Api::_()->getDbtable('forgot', 'user');
$db = $sTable->getAdapter();
// get the user information
$sql = "select * from engine4_users where user_id='$user_id'";
$stmt = $db->query($sql);
$arr = $stmt->fetch();
echo $arr['displayname'];
?>
5. Upload your widget folder to application/widgets/
6. Go to your admin Layout Editor you should see there a widget name My First Widget.