How to create a simple widget? I have limited knowledge of PHP but I would like to try and create a widget. Basically all it needs to do is provide some text and a link to the user profile page as you can't route directly to that page on login. Would someone be able to point me in the write direction please. I have in my grWidget.php file:

&lt;?php

namespace Craft;

class GrWidget extends BasePlugin
{
  function getName()
    {
      return Craft::t('Gareth Widget');
    }

    function getVersion()
    {
      return '1.0';
    }

    function getDeveloper()
    {
      return 'Gareth Redfern';
    }

    function getDeveloperUrl()
    {
      return 'http://garethredfern.com';
    }
}
I think you are mixing up your Primary Plugin Class with your Dashboard Widget.

Plugin Structure:

Assuming your plugin is called Gareth and your widget Gr, this files should be in your /craft/plugins/gareth/ directory:


GarethPlugin.php
templates/


GrWidget.html

widgets/


Gareth_GrWidget.php





Primary Plugin Class: GarethPlugin.php


  Your primary plugin class defines all of the things that Craft needs
  to know about your plugin, such as the plugin’s name, version number,
  developer’s name and URL, and Global Settings.


&lt;?php
namespace Craft;

class GarethPlugin extends BasePlugin
{
    function getName()
    {
         return Craft::t('Gareth');
    }

    function getVersion()
    {
        return '1.0';
    }

    function getDeveloper()
    {
        return 'Gareth Redfern';
    }

    function getDeveloperUrl()
    {
        return 'http://garethredfern.com';
    }
}




Widget Class: Gareth_GrWidget.php

This class defines the widget types name getName() and its content getBodyHtml().

&lt;?php
namespace Craft;

class Gareth_GrWidget extends BaseWidget
{
    public function getName()
    {
        return Craft::t('Gr');
    }

    public function getBodyHtml()
    {
        return craft()-&gt;templates-&gt;render('gareth/GrWidget');
    }
}




Widget Template: GrWidget.html

This is just some text which will be shown inside the GrWidget.
&lt;a href="{{ url('myaccount') }}"&gt;A link to my user profile&lt;/a&gt;




Result:





More:

Check out the Widget documentation. Also take a look at Craft's default widgets which can be found in the craft/app/widgets directory.