Shortcodes


Shortcodes, like the Wordpress counterpart, are inherited from BB Code. You can add tags that have callbacks that will parse the content.

One existing example is the [form] tag. You can paste the shortcode inside your page or entry content and it will get parsed.

Tags can also have attributes like [form id="1" show_title="true" ] . The attributes will be passed to your callback.

'short_codes' => [
        [
            'name' => 'Form', 
            // The tag name
            'tag' => 'form',
            // Your callback 
            'callback' => 'Newelement\\Neutrino\\Http\\Controllers\\ContentController::form_short_code' 
        ],
    ],

Your callback:

public static function form_short_code( $attrs = [] ){
        $args = [];

        $args['show_title'] = isset($attrs['show_title']) && $attrs['show_title'] === 'true'? true : false;

        $form = getFormHTML($attrs['id'], $args);
        // Return the altered content
        return $form;
    }