Converting CCS to L&L Templates: How to pass in information for Fields

I’m using Custom Content Shortcodes and looking into converting over to Loops & Logic. I have CCS’ Shortcodes template feature enabled and have several templates that are used throughout the site.
Example template:
<div class="custom-checkbox {CLASS}"><label class="checkbox"><input type="checkbox" id="{ID}"> {TEXT}</label></div>

This gets used as a shortcode on a page like this - ID, text, and class info is passed in on the shortcode:

[checkbox id="two-or-more" text="Two or more cases" class="pale-purple"]

How would I convert this into a Loop& Logic template? How can I pass in my IDs, classes, and text information?

Hey Ben, welcome to the forum! I’m not super familiar with CCS, but if I understand correctly, you’re trying to pass data from a shortcode to a template. Is that right?

If so, L&L’s [template] shortcode works the same way as its Template tag, so this is the page you’ll want to read up on, specifically the part about how tag attributes are passed local variables. In other words, you could write the shortcode [template name=my_checkbox_template checkbox_text="Two or more cases"] and then in your L&L template called my_checkbox_template you’d write <Get local=checkbox_text /> to get the local variable you created in the shortcode which in this example would render “Two or more cases” in your L&L template.

Hope that points you in the right direction!

Thank you! That page you linked to looks very helpful - and I appreciate your explanation. Let me explore this and hopefully this gets me to where I need to be!

1 Like

Unfortunately it doesn’t seem to be working for me - it doesn’t appear to be passing in my variables. I wonder if the custom content shortcode plugin is interfering?

Hi @MPHI_Dev, the CCS plugin and L&L shouldn’t interfere with each other, they work quite differently.

The template shortcode passes its attributes as local variables to the template being called.

[template name=checkbox id="two-or-more" text="Two or more cases" class="pale-purple"]

Oh, I notice there’s an attribute called id. That could be the problem, because the shortcode uses name or id to search for the template. You can rename to something like input_id.

Then, in the L&L template:

<div class="custom-checkbox {Get local=class}">
  <label class="checkbox">
    <input type="checkbox" id="{Get local=input_id}">
    <Get local=text />

Thank you! It was indeed the id variable that was causing issues! Renaming it resolved the issue and now the template renders as expected.