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

understand php callback

Discussion in 'XenForo Development Discussions' started by Kintaro, Apr 2, 2012.

  1. Kintaro

    Kintaro Well-Known Member

    I'm trying to understand php callback but I miss something.

    I have to make a new page in xenforo with a form and then manipulate the form's data.

    form example:

    <form action="#" name="compute" method="post">
            <input type="checkbox" name="won" /><br />
            <input type="text" name="myRank" /><br />
            <input type="text" name="opponentRank" /><br />
            <input type="radio" name="geo" value="national" /><br />
            <input type="radio" name="geo" value="regional"/><br />
            <input type="radio" name="geo" value="provincial" /><br />
            <input type="submit" name="compute" value="Go!" />
            <a href="<?php echo $_SERVER["SCRIPT_NAME"];?>">Refresh</a>
    compute data example (same page):
    $points = ($_POST["won"] == "on") ? win($_POST["myRank"], $_POST["hisRank"]) : defeat($_POST["myRank"], $_POST["hisRank"]);
    now It's correct to use Xenforo Page to do something like this or is better make an add-on?
  2. Floris

    Floris Guest

    Create a plugin is what you want to do.
  3. Kintaro

    Kintaro Well-Known Member

    Thank you Floris.
    For plug-in do you mean an add-on, right?

    So what are the limits of pages?
  4. Floris

    Floris Guest

    A product, which is an add-on, in the form of a plugin. Basically we're talking about the same thing.

    The limit is: how well can you code it in PHP?

    You need to create a route, a controller, a public viewer, and code to handle the submitted data and templates to show different scenarios (form + result + potential error notices)

    I made a plugin that lets you add an extra page, this takes care of everything for you, except your custom code, you'd have to edit the template to show the form, and write php code to handle the data that's submitted.

    If you want the plugin let me know, I will open a PM with you on this site to get you the .zip
    You can find more about the extra page add-on I made here. (just can't register or download from the site).
    kintaro81 likes this.
  5. Kintaro

    Kintaro Well-Known Member

    Well, I'm a a beginner trying to learn.
    Oh I think I have your add-on! I can't remember if I was registered to xenfans before the "archiving" or maybe downloaded here. I will try giving an eye on that code.
    In case I will PM you.

    Thank you again.
  6. ragtek

    ragtek Guest

Share This Page