Bridge.CMSVals
CMS Vals is the internal name for the values we get/set in Presomanager, allowing Content Admins and Managers to globally apply changes to a deck for all new presos.
This is a much more direct method to access these values than Bridge.Companywide and is recommend to be used over the functionality there.
Keep in mind for an any argument on this page that accepts a key:
It is not necessary to include the full key name for a template (regardless of the context it's rendering in). To make sure a template's editable keys are unique in PresoManager or user templates, a unique identifier is added to it.
If you register the key foo
on a template, it's not necessary to figure out where
it's in the context of a template preview, a template dragged in to create a section
or slide, or a user template, just the key
is enough and the command will figure out
the unique identifier if there is one.
You can call .getFullKey("foo")
in any context to figure out the full key if you need to.
.get(key, [{ slidePath = null }])
Retrieves a registered cms saved value by key. Optionally specify a slidePath to retrieve the cmsval of a specific slide, using the same pathing strings as Bridge.Navigation.gotoSlide(), otherwise the current slide is used by default.
Returns:
Returns the saved value if found, otherwise it returns null if:
- the slide doesn't exist (if using slidePath)
- the key hasn't been registered
- the value has not yet been set
Example:
// Get the value for the current slide
Bridge.CMSVals.get("my-key");
// Get the value for a specific slide
Bridge.CMSVals.get("my-key", {
slidePath: "{{ deck }}/my-section/my-slide",
});
.set(key, value, [{ slidePath = null }])
Sets a registered cms value by key.
Optionally specify a slidePath to set the cmsval of a specific slide, using the same pathing strings as Bridge.Navigation.gotoSlide(...), otherwise the current slide is used by default.
Bridge.CMSVals.set("my-key", "Hello world!");
Bridge.CMSVals.set("my-key", "Hello world!", {
slidePath: "{{ deck }}/my-section/my-slide",
});
Events:
It might be beneficial to know when the cmsval has been updated, if so:
Bridge.presenter.getPresentation().on("cmsValChanged", (key, value) => {
// This will fire any time a cmsval has been changed using Bridge.CMSVals.set
});
.getKeys([{ slidePath = null }])
Returns the list of registered keys for the slide.
Optionally specify a slidePath to set the cmsval of a specific slide, using the same pathing strings as Bridge.Navigation.gotoSlide(...), otherwise the current slide is used by default.
If using gulp, editables are registered with html on your slide.
If using webpack, you must register editables within the project file.
Bridge.CMSVals.getKeys(); // ["foo", "bar", "baz"]
Bridge.CMSVals.getKeys({
slidePath: "{{ deck }}/my-section/my-slide",
}); // ["foo", "bar", "baz"]
.getFullKey(key, [{ slidePath = null }])
Get the unique representation of the slide key. For the welcome slide,
sections and slides this will just be the key
that you pass in - but
for slides that unique keys like a template slide, this will have
a unique identifier attached to it.
Optionally specify a slidePath to set the cmsval of a specific slide, using the same pathing strings as Bridge.Navigation.gotoSlide(...), otherwise the current slide is used by default.
// If it's a slide, section, welcome slide, no change
Bridge.CMSVals.getFullKey("my-key"); // my-key
Bridge.CMSVals.getFullKey("my-key", {
slidePath: "{{ deck }}/{{ section }}/my-slide",
}); // my-key
// If it's a template slide
Bridge.CMSVals.getFullKey("my-key"); // my-key-autoadjunct-123
Bridge.CMSVals.getFullKey("my-key", {
slidePath: "{{ deck }}/autoadjunct-my-template",
}); // my-key-autoadjunct-123