You need to override this model: Mage_Cms_Model_Template_Filter
Mage_Widget_Model_Template_Filter
and add a method for your own shortcode.
Let's assume your short code is called 'custom', you need to add a method called customDirective($construction)
that handles your shrotcode.
To get an idea on how that method should look like, take a look at Mage_Core_Model_Email_Template_Filter::storeDirective()
. This method handles the store
shortcode.
To get the parameters passed to the short code use this:
$params = $this->_getIncludeParameters($construction[2]);
After processing them you need to return a string value that will replace the {{custom ...}}
placeholder.
[Edit]
I realized my mistake. The Widget
module changes the template processor. Here is the piece of code that worked for me.
file app/etc/modules/Easylife_Widget.xml
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Widget>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Widget />
</depends>
</Easylife_Widget>
</modules>
</config>
file app/code/local/Easylife/Widget/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Widget>
<version>0.0.1</version>
</Easylife_Widget>
</modules>
<global>
<models>
<widget>
<rewrite>
<template_filter>Easylife_Widget_Model_Template_Filter</template_filter>
</rewrite>
</widget>
</models>
</global>
</config>
file app/code/local/Easylife/Widget/Model/Template/Filter.php
<?php
class Easylife_Cms_Model_Template_Filter extends Mage_Widget_Model_Template_Filter{
public function customDirective($construction){
$params = $this->_getIncludeParameters($construction[2]);
return print_r($params, 1);
}
}
Clear the cache.
Now when I enter {{custom}}
in the page content I get back Array()
.
If I enter {{custom var1="6"}}
I get Array ( [var1] => 6 )
.