Blog-plugin: Support Shortcode?

Created on 18 Nov 2019  路  7Comments  路  Source: rainlab/blog-plugin

Hello,

I am working on a project which requires me to use the blog plugin, but I noticed there isn't a way for me to add a shortcode (change the editor to add codes) in the blog content area.

Is there a way I could work around this?

i am also using the custom fields plugin to insert the shortcode.
https://octobercms.com/plugin/pkurg-customfields

Question

Most helpful comment

I'm actually working on a shortcode plugin right now. I'll ping this issue when it's available 馃憤

Blog Shortcodes demo |
--- |
|

All 7 comments

@nycparking October doesn't have "shortcodes", so I have no idea what you're talking about.

I'm actually working on a shortcode plugin right now. I'll ping this issue when it's available 馃憤

Blog Shortcodes demo |
--- |
|

@drmzio is that going to be matching shortcodes to components?

@LukeTowers Not sure I quite understand, but it will pull from your theme's partials

@drmzio I mean will it allow you to pull in a component? Say you have a forms component, would you be able to do [forms form=contact]?

@LukeTowers Haven't really thought about using components yet. All it does is pull a custom partial from your theme and renders it on the blog post, then saves the rendered partial into the blog content_html column.

It's still a very early work in progress, but here are the steps:

  1. Register shortcode name (e.g. [youtube-embed])
  2. Create the partial under the partials/shortcodes theme directory (e.g. partials/shortcodes/youtube-embed.htm)
  3. Add your custom HTML data to the partial (e.g. The youtube embed code would go here)
  4. Call the shortcode in the blog post editor (e.g. [youtube-embed] would render the youtube embed code from the partial)
  5. On save, only the rendered partial code gets stored in the DB Blog plugin column content_html

You can pass arguments like video="xxx" or name="John" to reuse a shortcode in many ways. See https://github.com/thunderer/Shortcode for more on what can be done with shortcodes.

@drmzio This is great, this is what I actually needed a few days ago, but I went ahead and found a developer to get it done for me.

But I think a lot of people would find this useful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcomessa picture marcomessa  路  7Comments

MaTToX3 picture MaTToX3  路  6Comments

mateoprifti picture mateoprifti  路  3Comments

rodrigogoncalves picture rodrigogoncalves  路  9Comments

HugoBossOD picture HugoBossOD  路  5Comments