Answers.Body: <p>You've got a little ways to go before that will work as a plugin... I'd highly recommend getting a little more familiar with the basic anatomy of a plugin...</p>
  
  <p><a href="http://buildwithcraft.com/docs/plugins/introduction#anatomy-of-a-plugin">Craft Docs - Anatomy of a Plugin</a></p>
  
  <p>Basically, you'll want to take the "task" method that you have and move it to a *Variable.php file. Then you will be able to call that variable via a Twig template...</p>
  
  <pre><code>{{ craft.taskShortcut.task(attributes, content, tag) }}
  </code></pre>
  
  <p>You can learn more about variables here: <a href="http://buildwithcraft.com/docs/plugins/variables">Template Variables</a></p>
  
  <p>However, you'll still need your main *Plugin.php file, but the methods inside will be different (<a href="http://buildwithcraft.com/docs/plugins/setting-things-up#your-primary-plugin-class">Your Primary Plugin Class</a>).</p>
  
  <p>This will most likely be the folder structure of your plugin:</p>
  
  <pre><code>/craft/plugins/taskshortcut
                             /TaskShortcutPlugin.php
                             /variables/TaskShortcutVariable.php
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T09:11:07.040Z
Answers.LastActivityDate: 2014-06-13T09:35:24.853Z
Answers.LastEditDate: 2014-06-13T09:35:24.853Z
Answers.UserDisplayName: Lindsey D
Body: <p>I tried to write next class:</p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class TaskShortcutPlugin extends BasePlugin
  {
      // ...
      // Shortcut sample [task id="42"]Reference to task with id = 42[/task]
      public function task($attributes, $content, $tag)
      {
               $id = $attributes['id'];    // 42
               $content;                   // Reference to task with id = 42
               $tag;                       // 'task'
  
               return '&lt;a href="/task/'.$id.'" class="' .$tag. '"&gt;'.$content.'&lt;/a&gt;';
      }
  }
  </code></pre>
  
  <p>So, what next, how to implement it into CMS? Or I should use it into Twig templates?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-13T16:41:42.940Z
Comments.Text: Barif, could you be more specific about what you'd like to do? The code sample's extremely helpful, it's just tough to answer "what's next" without understanding your master plan for the plugin.
Comments.UserDisplayName: Matt Stein
Tags: <templating><filter>
Title: Custom Plugin implementation
ThreadText: # Custom Plugin implementation
  
  (Asked by: username_0 on 2014-06-13)
  
  I tried to write next class:
  
  ```
  <?php
  namespace Craft;
  
  class TaskShortcutPlugin extends BasePlugin
  {
      // ...
      // Shortcut sample [task id="42"]Reference to task with id = 42[/task]
      public function task($attributes, $content, $tag)
      {
               $id = $attributes['id'];    // 42
               $content;                   // Reference to task with id = 42
               $tag;                       // 'task'
  
               return '<a href="/task/'.$id.'" class="' .$tag. '">'.$content.'</a>';
      }
  }
  
  ```
  
  So, what next, how to implement it into CMS? Or I should use it into Twig templates?
  
  **Tags:** templating, filter
  
  > **Comments:**
  > **username_1**: username_0, could you be more specific about what you'd like to do? The code sample's extremely helpful, it's just tough to answer "what's next" without understanding your master plan for the plugin.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-06-13. Score: 7 | Accepted answer
  
  You've got a little ways to go before that will work as a plugin... I'd highly recommend getting a little more familiar with the basic anatomy of a plugin...
  
  [Craft Docs - Anatomy of a Plugin](http://buildwithcraft.com/docs/plugins/introduction#anatomy-of-a-plugin)
  
  Basically, you'll want to take the "task" method that you have and move it to a \*Variable.php file. Then you will be able to call that variable via a Twig template...
  
  ```
  {{ craft.taskShortcut.task(attributes, content, tag) }}
  
  ```
  
  You can learn more about variables here: [Template Variables](http://buildwithcraft.com/docs/plugins/variables)
  
  However, you'll still need your main \*Plugin.php file, but the methods inside will be different ([Your Primary Plugin Class](http://buildwithcraft.com/docs/plugins/setting-things-up#your-primary-plugin-class)).
  
  This will most likely be the folder structure of your plugin:
  
  ```
  /craft/plugins/taskshortcut
                             /TaskShortcutPlugin.php
                             /variables/TaskShortcutVariable.php
  
  ```
  
  
  ---
  
  