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

Default value for data type array

Discussion in 'XenForo Development Discussions' started by SchmitzIT, Feb 11, 2011.

  1. SchmitzIT

    SchmitzIT Well-Known Member

    So, where culd I find some additional information on how to use/implement the default values when using arrays and relying on a template to create the display?

    XenForo has it implemented, for instance, in the Terms of Service option. optionID = tosUrl, which in turn relies on admin template option_template_tosUrl to display three options, with the third one showing a textbox to enter a custom value.

    The default value shown for this is:

    Code:
    a:2:{s:4:"type";s:7:"default";s:6:"custom";b:0;}
    How would I translate that into something meaninful, exactly? What does the a represent, what does the s represent, and what does the b represent? What about the numbers 2, 4, 7 and 6?

    Thanks :)
     
  2. ragtek

    ragtek Guest

    That's a serialized array/object
    you can use unserialize to get an array back


    s means string
    a means array
    b means bool
    ...

    and the number means the following chars


    s:4:"type"
    means
    type => is a string with 4 chars


    CHeck http://php.net/manual/en/function.unserialize.php for more infos
     
    DarkSign and SchmitzIT like this.
  3. SchmitzIT

    SchmitzIT Well-Known Member

    Sorry to revive this old of a thread, but I still seem to be having trouble with this, and would appreciate a bit more help.

    Here's my admin_template:

    Code:
    <xen:radiounit label="{$preparedOption.title}" hint="{$preparedOption.hint}" name="{$fieldPrefix}[{$preparedOption.option_id}][type]">
        <xen:explain>{xen:raw $preparedOption.explain}</xen:explain>
        
        <xen:option label="{xen:phrase si_links_sidebar_location}" value="" selected="{$preparedOption.option_value.type} == ''" />
            
        <xen:option label="{xen:phrase si_links_footer_location}" value="default" selected="{$preparedOption.option_value.type} == 'default'" />
    
        <xen:option label="{xen:phrase si_links_header_location}" value="" selected="{$preparedOption.option_value.type} == ''" />
            
        <xen:html>
            <input type="hidden" name="{$listedFieldName}" value="{$preparedOption.option_id}" />
            {xen:raw $editLink}
        </xen:html>
    </xen:radiounit>
    
    My edit format has been set to Named Template, with Format Parameters pointing to the template above.

    Data Type has been set to Array, with the default value field containing the following:

    Code:
    a:2:{s:7:"sidebar";s:7:"default";s:6:"header";}
    The Arra Sub-Options contain the alues "sidebar" and "header", on seperate lines.

    This ends up in the Header value being checked. Any clues as to why, or how I can change this?

    Thanks in advance :)
     
  4. Fuhrmann

    Fuhrmann Well-Known Member

    Yes, I like to know this too.
     
  5. Sean Kendle

    Sean Kendle Member

    Any luck with this?
     

Share This Page