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

How to add a option to "Notice Options"?

Discussion in 'XenForo Development Discussions' started by Slind, Mar 31, 2014.

  1. Slind

    Slind Active Member

    hey,

    where can I find a tutorial how I can add another option to the defualt "Notice Options"?
    I would like to add a drop down menu which allows to select a style. Or is there alrady an addon which adds this? :)
     
  2. Slind

    Slind Active Member

    Bump :notworthy:
     
  3. tyteen4a03

    tyteen4a03 Well-Known Member

    A style? Display notice only if in certain styles?
     
  4. Slind

    Slind Active Member

    I mean a own style for the notice, at the moment I can change it only global but I would like to have a other style/css depending on choice.
    For example:
    notice 1 is a warning notice so I select the red style for the notice. Notice 2 is a information, then I select my blue style.

    Altogether I want to add a dropdown menu where I can select my style which I created before with css.
     
  5. tyteen4a03

    tyteen4a03 Well-Known Member

    Are the styles predefined or user-defined?
     
  6. Slind

    Slind Active Member

    I want to predefine it in a css template
     
  7. tyteen4a03

    tyteen4a03 Well-Known Member

    I mean, where do the options come from? From a predefined array or can users add their own style using a form in the ACP?
     
  8. Slind

    Slind Active Member

    I don't know if I understood you correctly.
    You have such menut with the styles: [​IMG]
    In this notice options:
    [​IMG]
     
  9. tyteen4a03

    tyteen4a03 Well-Known Member

    Yes, but where do the option values come from? They can come from a constant in your php files (like you can only order a preset chicken menu at KFC) or from a database table (like everybody can submit posts to a forum)
     
  10. Slind

    Slind Active Member

    From a php file.
     
  11. tyteen4a03

    tyteen4a03 Well-Known Member

    OK, so predefined.

    1. Add an admin template modification to add in the option.
    2. Extend ControllerAdmin_Notice::actionSave so it accepts your new options.
    3. Extend DataWriter_Notice to add your option to the field list.

    You can see from my Custom Markup for User add on to see how it is done.
     
  12. Slind

    Slind Active Member

    For which template should I create the modification and what should I add there?
     
  13. tyteen4a03

    tyteen4a03 Well-Known Member

    notice_edit. You should add your options template code there.

    I highly recommend looking at existing code to see how it is done - XF's code is very self-explanatory.
     
  14. Slind

    Slind Active Member

    I already looked in your code but I have no overview about the many files.

    And it can't find an template called notice_edit
     
  15. Milano

    Milano Well-Known Member

    There is an option called User is browsing with the following style in User Criteria tab, maybe it's what're you looking for. And you can find a template called notice_edit in Admin Templates in Development tab
     
  16. Slind

    Slind Active Member

    No it is not. It does not matter which style the user has selected. It matters only which notice style the admin has selected in the creation.

    Ah found the template but how can I create a template modification with a admin template?
     
  17. tyteen4a03

    tyteen4a03 Well-Known Member

    See Admin Template Mods.

    Also, not my code, XenForo's own code. My Usergroup Ranks addon also edits the notice templates, but it's rather outdated.

    He is defining a set of styles to be applied to the notices.
     
  18. Slind

    Slind Active Member

    I created now this Template Modification:
    HTML:
    <xen:spinboxunit label="{xen:phrase display_order}:" name="display_order" value="{$notice.display_order}" min="0" step="10" />
    HTML:
    <xen:spinboxunit label="{xen:phrase display_order}:" name="display_order" value="{$notice.display_order}" min="0" step="10" />
       
                    <xen:selectunit label="Style:">
                                         <xen:option name="style" value="" label="Testing"
                                                 <xen:option value="">(Default)</xen:option>
                                            <xen:options source="$searchContentTypes" />
                            hint="Explain" />
                                    </xen:selectunit>
    But it get not applied. Did I something wrong?
     

Share This Page