Answers.Body: <p>I feel quite embarrassed, but I have finally got this thing working. The error that I had made was within <code>AdLister_AluWidget.php</code>. I had written at line 4: <code>class Adlister_AluWidget extends BaseWidget</code> instead of what it should have been: <code>class AdLister_AluWidget extends BaseWidget</code>. So, AdLister should have been written with an UPPER-CASE 'L' and not lower-case. If anyone else is struggling, hopefully my error will help them.</p>
  
  <p>The correct code in full:</p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class AdLister_AluWidget extends BaseWidget
  {
      public function getName()
      {
          return Craft::t('Adlister Update');
      }
  
      public function getBodyHtml()
      {
          return craft()-&gt;templates-&gt;render('adlister/AluWidget');
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-24T16:33:06.083Z
Answers.LastActivityDate: 2016-08-24T16:33:06.083Z
Answers.UserDisplayName: ADigitalMark
Body: <p>I am hoping that somebody can help with this issue.</p>
  
  <p>I followed <a href="https://craftcms.stackexchange.com/questions/1286/how-to-create-a-simple-widget">this excellent tutorial</a> on creating a custom widget in Craft. On completion, I uploaded the plugin to the <code>/craft/plugins/</code> directory, visited the page at <code>/admin/settings/plugins</code> and installed the plugin. All fine so far. Then, on returning to the dashboard, I clicked on New Widget, and selected the name of the widget. Following this, a message flashed up saying 'An unknown error occurred.' and little else happened.</p>
  
  <p>It's probably user error, but if you could point out what I might have done incorrectly, that'd be useful.</p>
  
  <p><strong>My Plugin Structure</strong></p>
  
  <p>The plugin's called <code>Adlister</code> and the widget's called <code>Alu</code>, so in <code>/craft/plugins/adlister/</code> I have two folders ( <code>templates/</code> and <code>widgets/</code> ), and a file: <code>AdListerPlugin.php</code>. Within <code>templates/</code> is a file: <code>AluWidget.html</code> and within <code>widgets/</code> is <code>AdLister_AluWidget.php</code>.</p>
  
  <p><strong>File Contents</strong></p>
  
  <p><strong><em>AdListerPlugin.php</em></strong></p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class AdListerPlugin extends BasePlugin
  {
      function getName()
      {
           return Craft::t('AdLister');
      }
  
      function getVersion()
      {
          return '1.0';
      }
  
      function getDeveloper()
      {
          return 'Mark Syred';
      }
  
      function getDeveloperUrl()
      {
          return 'http://www.sypo.uk';
      }
  }
  </code></pre>
  
  <p><strong><em>AluWidget.html</em></strong></p>
  
  <pre><code>&lt;p&gt;Click to perform &lt;a href="http://example.co.uk/adlister-update.php?numDays=1"&gt;a daily update&lt;/a&gt;.&lt;/p&gt;
  &lt;p&gt;Click to perform &lt;a href="http://example.co.uk/adlister-update.php?numDays=3"&gt;an update on a Monday&lt;/a&gt;.&lt;/p&gt;
  &lt;p&gt;Click to perform &lt;a href="http://example.co.uk/adlister-update.php?numDays=7"&gt;a weekly update&lt;/a&gt;.&lt;/p&gt;
  &lt;p&gt;Click to perform &lt;a href="http://example.co.uk/adlister-update.php?numDays=30"&gt;a monthly update&lt;/a&gt;.&lt;/p&gt;
  </code></pre>
  
  <p><strong><em>AdLister_AluWidget.php</em></strong></p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class Adlister_AluWidget extends BaseWidget
  {
      public function getName()
      {
          return Craft::t('Adlister Update');
      }
  
      public function getBodyHtml()
      {
          return craft()-&gt;templates-&gt;render('adlister/AluWidget');
      }
  }
  </code></pre>
  
  <p>Any help that anyone could provide would be much appreciated.</p>
  
  <p>With kind regards,</p>
  
  <p>Mark</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I don't know if this has any bearing, but the version of Craft I'm running is 2.6.2911.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-24T09:54:10.943Z
Comments.Text: I actually set up your plugin by using the code in your question, and adding the widget worked fine on my end. Are these stubs – i.e. anything else in your code besides the stuff you posted? Or is this the complete thing?
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-24T09:55:04.163Z
Comments.Text: Also, did you check your log files under `/craft/storage/runtime/logs` (search for `[error]` and possibly your server error log files as well – might be a clue in there.
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-24T10:05:21.217Z
Comments.Text: @MatsMikkelRummelhoff Thanks for your comment. The code in my question displays the complete code. It's good to know it works for someone! I will go ahead now and check the error logs...
Comments.UserDisplayName: ADigitalMark
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-24T10:06:21.220Z
Comments.Text: Yeah, I set it up exactly like you describe, so without being able to reproduce the issue it's hard to advise. Hopefully there's a more helpful error message in the logs :)
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-24T10:30:23.060Z
Comments.Text: @MatsMikkelRummelhoff I've checked the error logs - both on craft and in the server - and there's nothing relevant that I can see. I've resorted to contacting Pixel & Tonic via the Dashboard in Craft. Thanks anyway for your support.
Comments.UserDisplayName: ADigitalMark
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-24T10:35:40.730Z
Comments.Text: Also check the network and console tabs in your browser's dev tools when you attempt to create the widget. Might be a JS error or something else you can spot there.
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-24T11:41:25.320Z
Comments.Text: @MatsMikkelRummelhoff Thanks for pointing that out. I get: `"NetworkError: 500 Internal Server Error - http://www.singletrack-distribution.co.uk/index.php/admin/actions/dashboard/createWidget"` as an error. Any ideas?
Comments.UserDisplayName: ADigitalMark
Tags: <plugin-development><error-message>
Title: 'An unknown error occurred.' when trying to add new custom widget
ThreadText: # 'An unknown error occurred.' when trying to add new custom widget
  
  (Asked by: username_0 on 2016-08-24)
  
  I am hoping that somebody can help with this issue.
  
  I followed [this excellent tutorial](https://craftcms.stackexchange.com/questions/1286/how-to-create-a-simple-widget) on creating a custom widget in Craft. On completion, I uploaded the plugin to the `/craft/plugins/` directory, visited the page at `/admin/settings/plugins` and installed the plugin. All fine so far. Then, on returning to the dashboard, I clicked on New Widget, and selected the name of the widget. Following this, a message flashed up saying 'An unknown error occurred.' and little else happened.
  
  It's probably user error, but if you could point out what I might have done incorrectly, that'd be useful.
  
  **My Plugin Structure**
  
  The plugin's called `Adlister` and the widget's called `Alu`, so in `/craft/plugins/adlister/` I have two folders ( `templates/` and `widgets/` ), and a file: `AdListerPlugin.php`. Within `templates/` is a file: `AluWidget.html` and within `widgets/` is `AdLister_AluWidget.php`.
  
  **File Contents**
  
  ***AdListerPlugin.php***
  
  ```
  <?php
  namespace Craft;
  
  class AdListerPlugin extends BasePlugin
  {
      function getName()
      {
           return Craft::t('AdLister');
      }
  
      function getVersion()
      {
          return '1.0';
      }
  
      function getDeveloper()
      {
          return 'Mark Syred';
      }
  
      function getDeveloperUrl()
      {
          return 'http://www.sypo.uk';
      }
  }
  
  ```
  
  ***AluWidget.html***
  
  ```
  <p>Click to perform <a href="http://example.co.uk/adlister-update.php?numDays=1">a daily update</a>.</p>
  <p>Click to perform <a href="http://example.co.uk/adlister-update.php?numDays=3">an update on a Monday</a>.</p>
  <p>Click to perform <a href="http://example.co.uk/adlister-update.php?numDays=7">a weekly update</a>.</p>
  <p>Click to perform <a href="http://example.co.uk/adlister-update.php?numDays=30">a monthly update</a>.</p>
  
  ```
  
  ***AdLister\_AluWidget.php***
  
  ```
  <?php
  namespace Craft;
  
  class Adlister_AluWidget extends BaseWidget
  {
      public function getName()
      {
          return Craft::t('Adlister Update');
      }
  
      public function getBodyHtml()
      {
          return craft()->templates->render('adlister/AluWidget');
      }
  }
  
  ```
  
  Any help that anyone could provide would be much appreciated.
  
  With kind regards,
  
  Mark
  
  **UPDATE**
  
  I don't know if this has any bearing, but the version of Craft I'm running is 2.6.2911.
  
  **Tags:** plugin-development, error-message
  
  > **Comments:**
  > **username_1**: I actually set up your plugin by using the code in your question, and adding the widget worked fine on my end. Are these stubs – i.e. anything else in your code besides the stuff you posted? Or is this the complete thing?  
  > **username_1**: Also, did you check your log files under `/craft/storage/runtime/logs` (search for `[error]` and possibly your server error log files as well – might be a clue in there.  
  > **username_0**: @username_1 Thanks for your comment. The code in my question displays the complete code. It's good to know it works for someone! I will go ahead now and check the error logs...  
  > **username_1**: Yeah, I set it up exactly like you describe, so without being able to reproduce the issue it's hard to advise. Hopefully there's a more helpful error message in the logs :)  
  > **username_0**: @username_1 I've checked the error logs - both on craft and in the server - and there's nothing relevant that I can see. I've resorted to contacting Pixel & Tonic via the Dashboard in Craft. Thanks anyway for your support.  
  > **username_1**: Also check the network and console tabs in your browser's dev tools when you attempt to create the widget. Might be a JS error or something else you can spot there.  
  > **username_0**: @username_1 Thanks for pointing that out. I get: `"NetworkError: 500 Internal Server Error - http://www.singletrack-distribution.co.uk/index.php/admin/actions/dashboard/createWidget"` as an error. Any ideas?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-08-24. Score: 2 | Accepted answer
  
  I feel quite embarrassed, but I have finally got this thing working. The error that I had made was within `AdLister_AluWidget.php`. I had written at line 4: `class Adlister_AluWidget extends BaseWidget` instead of what it should have been: `class AdLister_AluWidget extends BaseWidget`. So, AdLister should have been written with an UPPER-CASE 'L' and not lower-case. If anyone else is struggling, hopefully my error will help them.
  
  The correct code in full:
  
  ```
  <?php
  namespace Craft;
  
  class AdLister_AluWidget extends BaseWidget
  {
      public function getName()
      {
          return Craft::t('Adlister Update');
      }
  
      public function getBodyHtml()
      {
          return craft()->templates->render('adlister/AluWidget');
      }
  }
  
  ```
  
  
  ---
  
  