Answers.Body: <p>I needed to extend <code>BaseApplicationComponent</code> in my Services file:</p>
  
  <pre><code>class SiteUtilitiesService extends BaseApplicationComponent
  {
      public function videoEmbed($url, $color)
      {
          // some code to get the video ID from the $url variable
  
          return "&lt;some html embed code with the $color variable&gt;";
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-12T01:16:40.657Z
Answers.LastActivityDate: 2015-12-12T01:16:40.657Z
Answers.UserDisplayName: kmgdev
Body: <p>I'm getting this error when trying to call my plugin on a template:</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined method Craft\SiteUtilitiesService::init() in /path/to/my/site/craft/app/framework/base/CModule.php on line 394</p>
  </blockquote>
  
  <p>The template tag:</p>
  
  <p><code>{{ craft.siteUtilities.videoEmbed( block.video, '219181' ) }}</code></p>
  
  <p>Content of <code>variables/SiteUtilitiesVariable.php</code>:</p>
  
  <pre><code>class SiteUtilitiesVariable
  {
      public function videoEmbed($url, $color)
      {
          return craft()-&gt;siteUtilities-&gt;videoEmbed($url, $color);
      }
  }
  </code></pre>
  
  <p>Content of <code>services/SiteUtilitiesService.php</code>:</p>
  
  <pre><code>class SiteUtilitiesService
  {
      public function videoEmbed($url, $color)
      {
          // some code to get the video ID from the $url variable
  
          return "&lt;some html embed code with the $color variable&gt;";
      }
  }
  </code></pre>
  
  <p>What's the <code>init</code> method the error is referencing?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-12T01:00:09.143Z
Comments.Text: Stab in the dark, but if your main plugin class file extending BasePlugin?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-12T01:04:21.037Z
Comments.Text: @BradBell I actually wasn't extending `BaseApplicationComponent` in the Services file.
Comments.UserDisplayName: kmgdev
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-12T01:10:05.337Z
Comments.Text: Ahh, that's what I meant to say. :)  Would you mind adding that as an official answer?
Comments.UserDisplayName: Brad Bell
Tags: <plugin-development>
Title: Call to Undefined Method ::init Error
ThreadText: # Call to Undefined Method ::init Error
  
  (Asked by: username_0 on 2015-12-12)
  
  I'm getting this error when trying to call my plugin on a template:
  
  > Fatal error: Call to undefined method Craft\SiteUtilitiesService::init() in /path/to/my/site/craft/app/framework/base/CModule.php on line 394
  
  The template tag:
  
  `{{ craft.siteUtilities.videoEmbed( block.video, '219181' ) }}`
  
  Content of `variables/SiteUtilitiesVariable.php`:
  
  ```
  class SiteUtilitiesVariable
  {
      public function videoEmbed($url, $color)
      {
          return craft()->siteUtilities->videoEmbed($url, $color);
      }
  }
  
  ```
  
  Content of `services/SiteUtilitiesService.php`:
  
  ```
  class SiteUtilitiesService
  {
      public function videoEmbed($url, $color)
      {
          // some code to get the video ID from the $url variable
  
          return "<some html embed code with the $color variable>";
      }
  }
  
  ```
  
  What's the `init` method the error is referencing?
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: Stab in the dark, but if your main plugin class file extending BasePlugin?  
  > **username_0**: @username_1 I actually wasn't extending `BaseApplicationComponent` in the Services file.  
  > **username_1**: Ahh, that's what I meant to say. :)  Would you mind adding that as an official answer?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-12-12. Score: 3 | Accepted answer
  
  I needed to extend `BaseApplicationComponent` in my Services file:
  
  ```
  class SiteUtilitiesService extends BaseApplicationComponent
  {
      public function videoEmbed($url, $color)
      {
          // some code to get the video ID from the $url variable
  
          return "<some html embed code with the $color variable>";
      }
  }
  
  ```
  
  
  ---
  
  