<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>

CC BY-SA 3.0
2014-06-13T09:11:07.040Z
2014-06-13T09:35:24.853Z
2014-06-13T09:35:24.853Z
Lindsey D
<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>

CC BY-SA 3.0
2014-06-13T16:41:42.940Z
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.
Matt Stein
<templating><filter>
Custom Plugin implementation
# Custom Plugin implementation

(Asked by: username_0 on 2014-06-13)

I tried to write next class:
'.$content.'';
    }
}

So, what next, how to implement it into CMS? Or I should use it into Twig templates?

**Tags:** templating, filter
> **Comments:**
> **username_1**: 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.  

---

## 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
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
However, you'll still need your main *Plugin.php file, but the methods inside will be different (Your Primary Plugin Class).
This will most likely be the folder structure of your plugin:
/craft/plugins/taskshortcut
                           /TaskShortcutPlugin.php
                           /variables/TaskShortcutVariable.php


---

