How do I add database variables for use in Pro Editor?

I have an object key/value that I’d like to insert somewhere for X theme to allow me to ‘select’ rather than have to commit to memory the exact spelling/syntax of each object key. For instance, I am using GSAP to animate, and I’m doing so with custom attributes (e.g. ‘data-animationType’, ‘data-animateChildren’). I’d like to store the attributes in an object, along with the possible values (i.e. { ‘data-animationType’: { “slide-up”, “slide-up-small”, “slide-right”, “slide-left”, “custom-animation-name”, …}

That way, when I’m adding elements to Pro, instead of remembering what to type, I can click on the db icon under attributes, and then select the animationType object for the key, and then whatever value I’ve added (or add in the future). Hopefully, that makes sense.

In the place where the global stuff is (pos name, author, date, etc).

I don’t mind using ACF, and I don’t mind adding a function in my functions.php to declare the object. There aren’t many advanced documentation notes available yet it seems. Thanks in advance! :slight_smile:

Hi @jrhager84,

Please check the following documentation for guidance:

https://theme.co/docs/element-api-primer
https://theme.co/docs/element-api-reference

You can add those values as an option in a custom element.

Hope this helps.

So I essentially have to create an entire custom element in order to hook my variables into the {{fields}}? I just need an object added to the dynamic content. Is there no action hook that I can hook into to just add my field in functions.php?

my Object:

obj = array(
  "animationType" => array("slide-up", "slide-up-small", "slide-left", "slide-right"),
  "animateChildren" =>  array("true", "false")
)

I don’t even mind adding each of those values separately if I have to. But that’s the only functionality I need. I don’t need to render anything – I just want to be able to use these custom values in the dynamic content portion of the other elements for data attributes.

Hello @jrhager84,

If you want to add some custom meta fields so that you can use it in the dynamic content, please go to X/Pro > Validation > Extensions and install ACF Pro plugin instead. This will allows you to create custom fields and that you can in the dynamic content. Feel free to check more information about the ACF Pro in our documentation here:

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.