cbHasField support for Layout ID

Hi,

I would like to add a css class in a CB layout template, but only if there is a specific field used in that layout.
Since there is already an input for a specific resource id in the cbHasField snippet, I was wondering if this might be a good way to limit the testing for a specific layout id as well.

Any suggestions? Maybe I already think too complicated…

Best regards

I’m not sure if this is an easy change to make to the cbHasField snippet. For what you’re describing, it would need to be limited to a specific instance of a layout as well; you wouldn’t want it to return a value from a different instance of the layout further down the page.

Perhaps simply a layout setting can be used to toggle the behaviour you’re looking for?

Thanks, Mark!

I managed to change the cbHasField snippet to look for specified fields in a layout, assuming that only one instance of the layout is used. For the moment this works for me.

If you’ve changed the cbHasField snippet, you may want to consider duplicating it instead and changing your duplicated version; otherwise, your changes may be overwritten when you update the ContentBlocks package.

1 Like

of course, thanks Isaac!