Combining two snippets into one Master Snippet

I'm creating a Snippet for two different situations (similar but for different depts). Eg if you pick option one (with specific options) or option 2 (with specific options). I want to be able to pick option 1 and only option one's options can be answered and inserted or pick option 2 and only option two's questions can be answered & inserted. Maybe there is a tutorial for this already and you could direct me to it.

1 Like

Hi Andrea! You can easily do this with if commands. Good luck!

3 Likes

Hi @Andrea_McNamee

In addition to what Laren suggested, you could use the {import} command.

Here's an example:

{formmenu: name=choice; Option 1; Option 2}

{if: choice=="Option 1"}{import: /snippet1}{elseif: choice=="Option 2"}{import: /snippet2}{endif}

In the example above, I have two snippets (one for each scenario), and I'm importing them into the main snippet I want to use.

The dropdown menu asks me to choose my preferred option, while the {if} command gives me the contents of the respective imported snippet based on my choice.

Let me know if anything is unclear :slight_smile:

3 Likes

Oh yes! That's something that I do a lot of. By using imported snippets you can make it so much easier to change just one snippet without going through a lot of scrolling and searching!

2 Likes

Thank you Cedric - this was a massive help and helped me understand more about imports and {if} option. Seeing your example made it very easy to work with both situations.

One other questions - if you use 2 imported snippets and made a master snippet, which you make available to a team - can you hide the other snippets so that they aren't available to/ seen by the team (only the master snippet should be used).

Thank you Laren for pointing me in the right direction.

Hi @Andrea_McNamee,

If someone wants to use a snippet that is importing other snippets, they will need to have access to all of them.

However, you could set the user permissions to "Viewer" and uncheck the box that says "Allow viewers to see snippet source text (in addition to the preview)".

That way, people will be able to use the snippets without seeing the snippet code. Unfortunately, there is no way to restrict users from inserting snippets to which they have access.