Skip to Content Skip to Menu

Plugin Code Help

  • land35
  • land35
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
14 years 8 months ago #126461 by land35
Plugin Code Help was created by land35
Hi all, made my first plugin to display some data from a database and no matter what I try it will only show one row, it will short the columns.

Can someone have a look and see were I'm going wrong, I used the Helloworld plugin as a start point.

[code:1]<?php

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );


class gethelloworldTab extends cbTabHandler {
function gethelloworldTab() {
$this->cbTabHandler();
}

function getDisplayTab($tab,$user,$ui) {
global $my, $database;
$pagingParams = $this->_getPaging(array(),array("events_"«»));
switch ($pagingParams["events_sortby"]) {
case "date":
$order = "date ASC";
break;
case "venue":
$order = "venue ASC";
break;
case "club":
$order = "club ASC";
break;
case "class":
$order = "class ASC";
break;
case "overall":
$order = "overall ASC";
break;
case "place":
$order = "class_place ASC";
break;
default:
$order = "date ASC";
break;
}
// Set parameters
$params = $this->params;
$pagingenabled = getLangDefinition($params->get('pagingEnabled', '0'));
$eventsnumber = getLangDefinition($params->get('eventsNumber', '0'));
$return = "";

//Query for event count
$query = "SELECT COUNT(*)"
. "\n FROM #__my_results"
. "\n WHERE userid=". $user->id ."" ;
$database->setQuery( $query );
$total = $database->loadResult();
if (!is_numeric($total)) $total = 0;
if (!$total>0) {
$return .= "<br /><br /><div class=\"sectiontableheader\" style=\"text-align:left;width:95%;\">";
$return .= "This user has not published any results";
$return .= "</div>";
return $return;
}

if ($pagingParams["events_limitstart"] === null) $pagingParams["events_limitstart"] = "0";
if ($eventsnumber > $total) $pagingParams["events_limitstart"] = "0";
if ($tab->description != null)
{
$return .= "\t\t<div class=\"tab_Description\">".unHtmlspecialchars(getLangDefinition($tab->description))."</div>\n";
}

// Query for a user's results
$query = "SELECT date,venue,club,class,overall,class_place"
. "\n FROM #__my_results"
. "\n WHERE userid=". $user->id .""
. "\n LIMIT ".($pagingParams["events_limitstart"] ? $pagingParams["events_limitstart"] : "0"«»).",".$eventsnumber;


$database->setQuery( $query );
//print $database->getQuery();
$items = $database->loadObjectList();

// Output table header
$return .= "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
$return .= "<tr class=\"sectiontableheader\">";
$return .= "<th>".$this->_writeSortByLink($pagingParams,"events_","date",'Date')."</th>";
$return .= "<th>".$this->_writeSortByLink($pagingParams,"events_","venue",'Venue')."</th>";
$return .= "<th>".$this->_writeSortByLink($pagingParams,"events_","class",'Class')."</th>";
$return .= "<th>".$this->_writeSortByLink($pagingParams,"events_","club",'Organiser')."</th>";
$return .= "<th>".$this->_writeSortByLink($pagingParams,"events_","overall", 'Overall')."</th>";
$return .= "<th>".$this->_writeSortByLink($pagingParams,"events_","place",'In class')."</th>";
$return .= "</tr>";

$i = 1;
foreach($items AS $item) {
$i = ($i==1) ? 2 : 1;

$return .= "<tr class=\"sectiontableentry$i\">";
$return .= "<td>".$item->date." </td>";
$return .= "<td>".$item->venue." </td>";
$return .= "<td>".$item->class." </td>";
$return .= "<td>".$item->club." </td>";
$return .= "<td>".$item->overall." </td>";
$return .= "<td>".$item->class_place." </td>\n";
$return .="</tr>\n";
$return .= "</table>\n";
if ($pagingenabled == 1 && ($eventsnumber < $total)) {
$return .= "<div style='width:95%;text-align:center;'>"
.$this->_writePaging($pagingParams,"events_",$eventsnumber,$total)
."</div>";
}
return $return;


}


} // end or getDisplayTab function
} // end of gethelloworldTab class

?>[/code:1]

Sorry if I put it in the wrong section:)

Please Log in or Create an account to join the conversation.

  • land35
  • land35
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
14 years 8 months ago #126609 by land35
Replied by land35 on topic Re:Plugin Code Help
Any clues? I am proper stuck.

What does this bit of code do? Referring to the question mark

[code:1] $i = ($i==1) ? 2 : 1;
[/code:1]

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum