Am trying to understand shortcode creation by copying examples in shortcode-core and shortcode-ui. Am using the files in shortcode-core as a base. Keep hitting my head against an error and need a nudge in the right direction.
Debugger is returning the error:
RuntimeException (404)
Template "partials/sc-bluebox.html.twig" is not defined.
Created two directories inside the shortcode-core directory: templates/partials
Inside /partials is a file called sc-bluebox.html.twig:
For some reason (unknown to me), the twig file seems to be not found (404)? At least that’s how I’m reading the error message. I’ve tried a variety of path changes to no avail.
FYI, the markdown text is something like this:
[blubox]This is the content that we're going to insert into the nested blue box.[/blubox]
@rhukster, thank you for your generous reply to my query. However, there may have been a misunderstanding. I wasn’t creating a new plugin, but, rather, simply adding an additional shortcodeinto the already existing shortcodes directory:
/user/plugins/shortcode-core/shortcodes
This is a learning exercise for me. It’s obvious that I need to study more working shortcode examples. Thanks.
I had created the sc-bluebox.html.twig file with the intent of learning about creating more complex shortcodes. My issue was that this .html.twig file I created was apparently not being recognized. The following simplified shortcode (BlueBoxShortcode.php) works fine.
Basically the short answer is that shortcode-core doesn’t support the Twig templates like shortcode-ui because it’s not adding the twig paths like I described in the original reply.
This is why it won’t work when you drop it into shortcode-core. However, it probably would of worked if you dropped it into shortocode-ui
The best approach is to create your own plugin with any shortcodes you might wish to use like the example php file I gave before.