• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Save a value in the database and retrieve the value

Zephyr

Well-known member
#1
Hello, I would like to know how to create a field in the admin panel, save a value in the database and retrieve the value please :)

This is just to record information "on" or "off" in the database (button on/off) and enable or disable elements accordingly.
 

Chris D

XenForo developer
Staff member
#2
I'm not exactly sure I fully understand...

But you can create Options in the Admin CP.

You'd want to create an option, give it a unique ID, a title, type on/off checkbox, value boolean, default value either 1 or 0. (1 for on, 0 for off).

So if you give it an ID of myCheckBox then you can reference that in a template using:

{$xenOptions.myCheckBox}

You can check if it's on or off...

<xen:if is ="{$xenOptions.myCheckBox}">
Do stuff if checkbox on
<xen:else />
Do stuff if checkbox off
</xen:if>

Or you can just check if it's on:

<xen:if is ="{$xenOptions.myCheckBox}">
Do stuff if checkbox on
</xen:if>

Or check if it's off:

<xen:if is ="!{$xenOptions.myCheckBox}">
Do stuff if checkbox off
</xen:if>
 

Zephyr

Well-known member
#3
Ok thank you very much, XenForo is very intuitive that side! :)

I have another question, is it possible to outsource its addon to share?

Example:

MySkin.rar
- Upload
- XenCreaSkin
- XenCreaAddon (Is it possible to export my addon ?)

Thank for help :)