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 (static) text field (PHP callback) to the ACP options?

Discussion in 'XenForo Development Discussions' started by rugk, Aug 29, 2015.

  1. rugk

    rugk Active Member

    I've followed Creating an Addon. to create an ACP settings page.
    However in edit format there is no 'label' or some other kind of (fake) 'option' which just displays text. (in my case it would be some kind of status text, which is taken from a PHP callback)

    So how can I make this (the best way)?
  2. rugk

    rugk Active Member

    Does anyone has an idea?
  3. rugk

    rugk Active Member

    Sorry for bumping this, but is this really that difficult?
  4. Vincent Gabriel

    Vincent Gabriel Active Member

    Sorry i might be able to help but not sure what you are talking about. maybe a visual representation will be of a help?
  5. rugk

    rugk Active Member

    I just want to show some information returned by a PHP callback in the ACP options. For this a "fake option" which only shows this information and does not save something (it does not allow user interaction) would be nice.
    I've got out I may use an admin template and a renderHtml method for returning this template.
    So what is the best way to accomplish this?

    It could possibly look like this:
  6. SneakyDave

    SneakyDave Well-Known Member

    I think you could create a custom admin template that refers to the string variable you want to populate, and use your callback to populate it.

    I think you'd need a listener created in order to avtually load that template though.

    I'll look to see if I can find some examples.
  7. rugk

    rugk Active Member

    Thanks. And no I used no listener - to select the PHP callback function as an option is enough.
    Filling the template with values in an PHP callback is no problem, but the option template itself is complicated, because it makes much use of the Xen Admin syntax. Especially the option type is controlled by the "<xen:<option>unit".
    But finally I found an example in option_template_censorWords where there is also used a custom option template and I saw you can use <xen:controlunit for this:
    <xen:controlunit label="{$preparedOption.title}" hint="{$preparedOption.hint}">
        <xen:explain>{xen:raw $preparedOption.explain}</xen:explain>
            <xen:comment>You can put any custom HTML here.</xen:comment>
            <input type="hidden" name="{$listedFieldName}" value="{$preparedOption.option_id}" />
            {xen:raw $editLink}
    This finally solves my problem.
    SneakyDave likes this.
  8. SneakyDave

    SneakyDave Well-Known Member

    Thanks, this is a good help to me, I have to do something similar with an input box that I'd like to replace with a text message based on certain criteria, and this example might help me out.

Share This Page