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

XF 1.2 PHP Callback

Discussion in 'Troubleshooting and Problems' started by Secretchaos, Mar 7, 2014.

  1. Secretchaos

    Secretchaos Member


    I'm very new to XenForo en starting to work with the php callback function. It was a little bit strugling to get started. But now I have a problem, wich I can't solve myself.

    First I will show the callback.

    class problemen_db
        public static function 
    respond(XenForo_ControllerPublic_Abstract $controllerXenForo_ControllerResponse_Abstract &$response)
    // Check connection
    if (mysqli_connect_errno()) {
    "De server kon geen verbinding maken met de database, error: " mysqli_connect_error();
    // Query
    $Query mysqli_query($con,"SELECT * FROM Problems");
    $Result mysqli_fetch_array($Query))
    $response->params['id'] = $Result['id']; 
    $response->params['Server'] = $Result['Server'];
    $response->params['Problem'] = $Result['Problem'];
    $response->params['Solved'] = $Result['Solved'];
    $response->params['Player'] = $Result['Player'];
    $response->params['Date'] = $Result['Date'];         
    $response->templateName 'problemen';
    And my template:
    <!-- This CSS is specific to each page and can either modify the existing classes or be used in isolation -->
    <style type="text/css">
    text-align: justify;
    padding:0 0 10px!important;
    overflow: hidden;
    zoom: 1;
    margin-top: 0 !important;
    float: left;
    margin-right: 10px;
    clear: both;
    text-align: center;
    word-wrap: break-word;
    width: 122px;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    text-align: justify;
    <div class="baseHtml messageText"> <!-- All content must be wrapped in these default classes to enable pages to use the same CSS as forum posts and automatically update with each style -->
    <!-- Introduction section -->
        <div class="sectionMain">
            <div class="page_generalText">
            Op deze pagina enzo :)
                Deze mensen zorgen ervoor dat jullie de beste speelervaring hebben, en dit allemaal vrijwillig.
                <br />
    <!-- Problem section -->
        <div class="sectionMain">
            <div class="page_generalText">
            <table border='1'>
    This works fine, except it only displays one record. In stead of the whole tabel. And I can't find out how to solve this.

    I want to thank you, for your time.
    (Sorry for the bad grammar, I'm from the netherlands)
  2. Slavik

    Slavik XenForo Moderator Staff Member

    Your table is only set to show 1 row, you need to use a foreach statement to process each result into a new row.
    Secretchaos likes this.
  3. Secretchaos

    Secretchaos Member

    What is the best way to do this with XenForo? A friend of me said loop the table, so put that in a different tpl. En create a callback wich loops it.

    Anyone have a better option? Otherwise I will try the method of that friend.

    Thanks for your reaction @Slavik !
  4. Slavik

    Slavik XenForo Moderator Staff Member

    Take a look at the member_list template as an example.

    <ol class="section memberList">
     <xen:foreach loop="$users" value="$user">
     <xen:include template="member_list_item">
     <xen:set var="$noOverlay">1</xen:set>
    Secretchaos likes this.
  5. Secretchaos

    Secretchaos Member

    I maybe very noob, but I can't get it to work. What do I have to do in my instance?

Share This Page