About Wordpress like Shortcodes

It brings Wordpress like shortcodes to Processwire.

Category Markup Generation
Markup modules that are called upon to generate or parse markup (like HTML). Markup modules are most often used on the front-end of a site (rather than admin).
Release StateStable
Should be safe for use in production environments. *
Authornico
Module Version1.04
Class NameMarkupShortcodes
Compatibility2.4, 2.5, 2.6, 2.7
Date AddedSeptember 26, 2012
Last UpdatedMay 7, 2015
Recommended ByNew recommendations may take up to 1 day to appear.

Instructions

W A R N I N G:
This Module requires PHP 5.3



This module's files should be placed in /site/modules/MarkupShortcodes/
How to install or uninstall modules

---

A quick example:

Code:
<?php$shortcode = $modules->get('MarkupShortcodes'); $shortcode->add('login', function($atts){ return '<form><h3>'.$atts['content'].'</h3><label>Enter password for "'.$atts['name'].'":</label> <input type="pass"></form>'; }); $content = 'Lorem ipsum dolor [login name="user"]Login[/login]'; echo $shortcode->render($content); ?>


You can:

add a shortcode:

Code:
$shortcode->add('login', function($atts){return '<form><h3>'.$atts['content'].'</h3><label>Enter password for "'.$atts['name'].'":</label> <input type="pass"></form>'; });


remove a shortcode:

Code:
$shortcode->remove('login');


remove all shortcodes:

Code:
$shortcode->remove_all();


and use them:

Code:
$shortcode->render('Lorem [ipsum /] hello. [dolor name="nico" /]. Third possibility: [abc def="hij"]a text[/abc]. ');


As seen above there are three different possible syntaxes:

Code:
1.: [shortcode] or [shortcode /]2.: [shortcode key="value" /] or [shortcode key="value"] or [shortcode key="value" second="bla" /] 3.: [shortcode]lorem ipsum[/shortcode] or [shortcode key="value"]lorem ipsum[/shortcode] or [shortcode key="value" second="bla"]lorem ipsum[/shortcode]

README

MarkupShortcodes

W A R N I N G:

This module requires PHP 5.3.

Comments

No comments yet. Be the first to post!

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.