Nodes As Tabs

Nodes As Tabs 1.5.1

No permission to download
I made an XF Page and enabled it as a Tab.
Made a secondary tabs template for it and the links in it show OK on the 2nd toolbar when I click the top tab.
But there's no dropdown.
The links are functions not nodes. Things like Search, Mark All Read, What's New?

Basically I want to duplicate the secondary tabs on Forums, but have the top tab point to this XF Page I call "HOME."
 
Hey there - I am trying to output the results of a query to a page (the query is on a new table i created that takes all the results of the Simple Forms add on).

What I want to do, on my new page is output the data in a simple table (the query is contained in a php file)

I have spent some time looking into php callbacks but just cannot figure out how to do this - i don't need to write anything, just output a pretty simple query as a table on a page...

Can anyone point me in the right direction? What I have read so far seems very complex for a simple task, so I am sure I am 'barking up the wrong tree'

Thanks.
 
Jake I have had some success with what i am trying to do..

I have the code

PHP:
<?php
class SummaryRatings_Model_SummaryRatings
    {
        public static function getRatings()
            {
                $mysqli = new mysqli("***", "***", "***",  "***");
 
                /* check connection */
                if (mysqli_connect_errno()) {
                    printf("Connect failed: %s\n", mysqli_connect_error());
                    exit();
                }
 
                $query = "SELECT title, player_name, rating FROM ratings";
                $result = $mysqli->query($query);
 
                /* associative and numeric array */
                $row = $result->fetch_array(MYSQLI_BOTH);
                echo "<table CELLPADDING=30 border =5 >";
                echo "<tr>";
                echo "<td>".$row['title']."</td>";
                echo "<td>".$row['player_name']."</td>";
                echo "<td>".$row['rating']."</td>";
                echo "</tr>";
                echo "</table>";
 
                /* free result set */
                $result->free();
 
                /* close connection */
                $mysqli->close();
            }
           
    }
?>

This is set up as a call back with SummaryRatings_Model_SummaryRatings::getRatings as my php callback.
It connects to the database fine
It reads the data fine and displays it on screen

However it is displaying it at the top of the screen above the header...

I am pretty sure that I am doing something fundamentally wrong here, but I can't for the life of me figure out how to get this on screen on the page...

Any help would be appreciated as I am stuck - though happy enough that I can read my data and print it to the screen using a php progress - thats some progress at least!:p
 
Your function signature should be:

Code:
public static function getRatings(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)

That way you have access to the controller response. Then you can set view params in the response (instead of echoing):

Code:
$response->params['row'] = $row;

That will allow you to reference {$row} in your page template. Example:

Code:
<table CELLPADDING=30 border =5 >
<tr>
<td>{$row.title}</td>
<td>{$row.player_name}</td>
<td>{$row.rating}</td>
</tr>
</table>
 
Your function signature should be:

Code:
public static function getRatings(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)

That way you have access to the controller response. Then you can set view params in the response (instead of echoing):

Code:
$response->params['row'] = $row;

That will allow you to reference {$row} in your page template. Example:

Code:
<table CELLPADDING=30 border =5 >
<tr>
<td>{$row.title}</td>
<td>{$row.player_name}</td>
<td>{$row.rating}</td>
</tr>
</table>

Thanks - do I need to reference the params['row'] in my query statements somewhere in order for $response to recognise it... i have used pretty typical php (for me anyway) and sql statements in teh code i posted... is there xenforo specific code I need to execute before $response->params['row'] = $row;
 
Jake - thanks a million - I now get what you were saying

The table statements go in the html template - not the php(y)
Its working.

I have one final issue.

One of the fields I am calling is a blob image - the output currently is just a bunch of text... can the template handle converting the blob to an image?

Using PHP I would write

PHP:
echo '<img src="data:image/jpeg;base64,' . base64_encode( $row['player_image'] ) . '" />';
 
In the callback:

Code:
$row['player_image'] = base64_encode( $row['player_image'] );

$response->params['row'] = $row;

In the template:

Code:
<img src="data:image/jpeg;base64,{$row.player_image}" />
 
Jake thank you - brilliant.

I am amazed at just how much can be done - and I am starting to get the hang of the call backs and templates (woohoo!:D )

I am currently trying out the <xen:foreach> statement in my template so that I can list all rows of the table.

Here is my template so far.

HTML:
<xen:sidebar>
</xen:sidebar>
 
<style>
  #wrapper {
    width: auto !important;
    width: 100%;
}
 
  #div1 {
    float:left;
    color:blue;
    width:48%;
 
    }
 
  #div2 {
    float:left;
    width:48%;
    margin-left:3%;
}
 
</style>
 
<div id = "div1">
    <h2 class="subHeading">Team Rating : Average scores over all games</h2>
</div>
<div id="div2">
    <h2 class="subHeading">Manager Rating : Average scores over all games</h2>
</div>
</br>
</br>
</br>
<div style="width:99%">
    <h2 class="subHeading">Player Ratings : Average scores over all games</h2>
    <table border="1" bordercolor="#a5cae4"width="100%" >
        <xen:foreach loop="$row" key="$key" value="$value" i="$i">
        <tr>
        <td ALIGN="center" BGCOLOR="#d7edfc">{$i} </td>
                <td ALIGN="center" style="width:15%;"><img src="data:image/jpeg;base64,{$row.player_image}"/></td>
                <td style = "padding-left:30px;  font-size: 12pt;">{$row.player_name}</td>
                <td style = "padding-left:30px;  font-size: 16pt; width:15%;"> {$row.rating}</td>
        </tr>
        </xen:foreach>
    </table>
</div>

I still have one problem - the data being brought back is only the first row of my table repeated 8 times :unsure:, as seen here:

http://arsenaltalk.net/pages/ratingsummary/

The php I am using to return the data via the callback is :

PHP:
<?php
class SummaryRatings_Model_SummaryRatings
    {
        public static function getRatings(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
            {
                $mysqli = new mysqli("x", "x", "x",  "x");
 
                /* check connection */
                if (mysqli_connect_errno()) {
                    printf("Connect failed: %s\n", mysqli_connect_error());
                    exit();
                }
 
                $query = "SELECT title, player_name, player_image, rating FROM ratings";
                $result = $mysqli->query($query);
 
                /* associative and numeric array */
                $row = $result->fetch_array(MYSQLI_BOTH);
                $row['player_image'] = base64_encode( $row['player_image'] );
                $response->params['row'] = $row;
   
                /* free result set */
                $result->free();
 
                /* close connection */
                $mysqli->close();
            }
       
    }
?>

That table currently has about 80 rows and the first 8 are different...

Is there something in the query that is limiting the output, or am I misusing the <xen:foreach>?
 
Top Bottom