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

Add ability for dropdowns in style properties

Discussion in 'XenForo Suggestions' started by Russ, Mar 24, 2014.

  1. Russ

    Russ Well-Known Member

    I'd love the ability to add drop downs in the style properties, could add some really nifty things to them and organize my properties quite a bit too.

    Not really much else to say... I hope it's considered (y)

    UPDATE: So via admin templates it's possible but considering I want to use dropdown via style properties in styles I release to the public, it's not. Suggesiton either let you export admin templates with a style, or simply get the example provided below to work on normal styles.
    Last edited: Mar 25, 2014
  2. Chris D

    Chris D XenForo Developer Staff Member

    As in just a <select> drop down with a single selection?

    Should be possible, I think.
  3. Russ

    Russ Well-Known Member

    Yep, where I define a list for the user to select, each item has of course a value and text value.
  4. Chris D

    Chris D XenForo Developer Staff Member

    Pretty sure it's possible with a named template. I'll do an example for you when not on my phone.

    The trick is probably getting the name attribute of the select box right so it saves the data correctly.
    Russ likes this.
  5. Chris D

    Chris D XenForo Developer Staff Member

    Yeah this is already possible using a named template:



    Example template:

    <input type="hidden" name="checkboxes[]" value="{$property.property_definition_id}" />
    <xen:selectunit name="properties[{$property.property_definition_id}]" value="{$property.propertyValueScalar}" label="{$property.title}">    
        <xen:hint>Pick a colour</xen:hint>
        <xen:option value="" label="" />
        <xen:option value="red" label="Red" />
        <xen:option value="blue" label="Blue" />
        <xen:option value="pink" label="Pink" />
        <xen:option value="green" label="Green" />
        <xen:option value="yellow" label="Yellow" />
        <xen:html><xen:include template="style_property_unit_extra"><xen:set var="$reset">{xen:phrase reset}</xen:set></xen:include></xen:html>
    The bits in red, you probably should include in each new template you create. Also, only one style property per template. It's unlikely you'd get multi select lists or checkboxes working because they would require the value to be stored as an array but they're stored as a scalar value instead.

    And the definition is set up like this:


    style_property_russ is the template name.
    Jeremy, Amaury, Russ and 2 others like this.
  6. Russ

    Russ Well-Known Member

    Beautiful Chris thanks a bunch man
  7. Russ

    Russ Well-Known Member

    Sorry to bug @Chris D

    But I'm a little confused or am missing the obvious.

    When attempting to do this, I'm getting an error every time I try creating a template.

    I copied directly from your code, and assumed all the "property_definition_id" and other property_ect were simply placeholders to pull text from the style property itself.

    When creating though I'm getting this:

  8. Chris D

    Chris D XenForo Developer Staff Member

    You need to create it as an admin template...

    And therein lies the problem I've just realised... You can't export Admin Templates with a style, can you?
  9. Russ

    Russ Well-Known Member

    Nope :(, so maybe the suggestion stands.
  10. Chris D

    Chris D XenForo Developer Staff Member

    Not really, because what you suggested is already possible.

    The suggestion would have to be the ability to export admin templates with a style.
  11. Russ

    Russ Well-Known Member

    Or... the ability to do the exact process without touching admin templates would be the suggestion? Either way I hope they address the ability to do either your method(export admin templates with a style) or even better... make the process work without admin templates.
  12. Mike Creuzer

    Mike Creuzer Well-Known Member

Share This Page