Rock U - Lava - Lava Shortcodes
Transcribed Video Content
Let's take a look at how LAVA shortcodes works in Rock. So what is a shortcode? A LAVA shortcode is a simple tag that acts as a placeholder for a complex lava template written by a specialist. Think of it as an insert lava here sign that tells Rock where to place longer, more complex lava code. So you put a small marker and Rock replaces that marker with a larger amount of code.
Using shortcodes means you don't have to have an extensive knowledge of lava to do some really cool things. And once you create a shortcode, others can use it or even build new shortcodes on it. There are two types of shortcodes: inline and block. It's important to select the right kind from the start because changing them later can break other people's lava templates. The syntax for both inline and block shortcodes is the same.
It's just a curly bracket, square bracket, shortcode, end square bracket, end curly bracket. Inline shortcodes are a little simpler than block shortcodes. They don't require an end tag, just reference the shortcode and provide a list of parameters. For example, an inline shortcode for a YouTube video would look this. It has the YouTube tag and then the show info and controls parameters.
That's it. It's super easy. Now block shortcodes are a little more complex but not much. Unlike inline shortcodes, block shortcodes require an end tag. Here's an example.
So it has opening and closing tags, an image parameter the image link, height parameters, position parameters, content padding, and speed parameters as well. And then there's the content that's shown here in HTML tags. In Rock, short codes are found in CMS configuration under Lava short codes. And Rock ships with several short codes ready to use, but we hope you'll create your own and share them with the Rock community. If you click on the show details button, we'll do that for the YouTube short code here.
It'll show you the short code to use to embed a YouTube video as well as the parameters you can use to customize that video. Okay. But what if you want to create a new short code? First, you need to decide which kind of shortcode to use, inline or block. Remember, if you want to change the shortcode in the future, you'll need to update all of your Lava templates that use the code, as will anyone else using that shortcode.
The biggest thing to consider is how much data will be passed by the short code. If there's a lot of data, use the block type. If it's just a little bit of data, use inline. So once you've decided which kind of short code you're going to use, click the add button and Rock will take you to the LAVA shortcode detail screen. Here you would give your shortcode a name, a tag name, and this is the shortcode name that LAVA will use.
It's always good to include a description so people know what the short code is. In the documentation section, this is where you'll put your technical description of the short code what we saw with the previous examples. You can include instructions, parameters, suggested uses, and any other tips you think will help others who want to use the short code or to remind yourself later. Below that is the short code markup field and this is where the actual lava goes. And below that is the parameters.
So if you wanna use parameters with your shortcode, you would click the add button and it'll let you add a parameter. If you include a value, that value will be used as the default if the parameter is left blank. On the right, you'll see there's enabled lava commands. This is where you can make Lava commands available to your shortcode by checking any of these options. If you're interested in diving deeper into shortcodes, please read our the long and short on shortcodes manual.
It gets more into the specifics and the powerful possibilities of shortcodes. In the meantime though, jump in and see what cool things you can do.