1. 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

Discussion in 'XenForo Development Discussions' started by Zephyr, Sep 6, 2012.

  1. Zephyr

    Zephyr Well-Known Member

    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.
  2. Chris D

    Chris D XenForo Developer Staff Member

    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:


    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

    Or you can just check if it's on:

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

    Or check if it's off:

    <xen:if is ="!{$xenOptions.myCheckBox}">
    Do stuff if checkbox off
    Jake Bunce and Zephyr like this.
  3. Zephyr

    Zephyr Well-Known Member

    Ok thank you very much, XenForo is very intuitive that side! :)

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


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

    Thank for help :)

Share This Page