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

Check boxes example?

Discussion in 'XenForo Development Discussions' started by MatthewH, May 16, 2015.

  1. MatthewH

    MatthewH Member

    I've been searching for one, I'm trying to work with check boxes in the options however I'm not finding much information on usage for it.

    Anyone have an example for it?
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Look at an existing admin option/template to see how they're used.
  3. MatthewH

    MatthewH Member

    @Brogan you're like my XenForo parent. You always seem to be the one to help me! :whistle:(y):love:

    Okay, so I'm seeing this.
    I know this is serialized, although I don't have a key to tell me what means what.
    Converted it looks like...
    array (
      'showStaff' => '1',
      'displayMultiple' => '1',
      'hideUserTitle' => false,
      'showStaffAndOther' => false,
    So is there a real difference between s:1:"1" and b:0? Well I would think b is a boolean so to match it would be b:1.

    So in code I would do something like
    if($options->formatParameter.myCheckbox) { }
    As long as the default value is...
    And my Array suboptions are just "myCheckbox"?

    Also, what about naming them? I know with other stuff you can put
    option = {xen: phrase myPhrase}
    So what about with check boxes?

    Thanks again @Brogan
    I'm trying to catch on quickly here.
  4. Brogan

    Brogan XenForo Moderator Staff Member

    For the values, s is string and i is integer.
    So these two would be the same:
    • s:1:"1";
    • ;i:1;
    In the template you use options like so:
    <xen:if is="{$xenOptions.optionId.optionValue}">
    In PHP like so:
    $options = XenForo_Application::getOptions();
    if ($options->optionId['optionValue'])
    if (XenForo_Application::getOptions()->optionId['optionValue'])
    Phrases can be used for labelling checkboxes and radio buttons.

Share This Page