-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Wordpress is amazing CMS, shortcodes is an interesting API which make wordpress more amazing just put tags in you content will be parsed by shortcodes and gives you formatted output of your content, now this shortcode api is now ported to FuelPHP framework a really good framework to develop and deploy application really fast. here how shortcodes work in FuelPHP.
here is simple example of short tag with foo bar
[footag foo="bar"]
above short tag has the following points just like normal HTML tags
- [ start of tag
- footag tag name
- foo="bar" tag attributes 4 ] end or close tag
To process above tag in view or content and make it proper out put we need to add tag name and attach a method which will format this tag name.
Shortcode::add('footag', 'Codes::footag_func');
above code we are calling add function of shortcode class adding tag name and function attached to this tag name.
render view output
$html = render('welcome/index');
now process the shortcodes
$this->response->body = Shortcode::run($html);
run method of shortcode class will process all short tags with their attached shortcode function will return formatted output.
you can add shortcodes in config file
'codes' => array(
'tabgroup' => 'Codes::jqtools_tab_group',
'tagname' => 'Codes::tag_attached_function'
)
);```
here is example short tag for jquery tabs
http://scrp.at/avM
attached function is already part of shortcode package.
for more information you can use wordpress shortcodes API
http://codex.wordpress.org/Shortcode_API