View Full Version : Display different stats on Stats page
Abronsyth
11-06-2016, 11:06 AM
The title essentially says it all.
I would like to display an adoptable's "trophies" under the stats page. Trophies are stored in the owned_adoptables table as "trophies".
Right now in class_ownedadoptables.php all I have is this, but it is not calling the trophies;
public function getTrophies(){
return $this->trophies;
}
So I am not really sure what to do ^^; If anyone has any insight I'd greatly appreciate it!
Dinocanid
11-06-2016, 11:45 AM
Well just putting the function in the class file alone won't make it show up, you have to go to the view file for that. Then you could add something like:
$document->add(new Comment("Trophies: {$adopt->getTrophies()}"));
If you're talking about the stats page that shows the random adoptables (I get it mixed up with levelup sometimes ^^;), then you would add something like:
<?php
use Resource\Native\String;
use Resource\Collection\LinkedList;
class StatsView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle($this->lang->title);
$document->addLangvar($this->lang->default.$this->lang->top10.$this->lang->top10_text);
$document->add($this->getTable("top10", $this->getField("top10")));
$document->addLangvar($this->lang->random.$this->lang->random_text);
$document->add($this->getTable("rand5", $this->getField("rand5")));
}
private function getTable($name, LinkedList $list){
$table = new TableBuilder($name);
$table->setAlign(new Align("center", "middle"));
$table->buildHeaders("Adoptable Image", "Adoptable Name", "Adoptable Owner", "Total Clicks", "Current Level", "Trophies"); #edited this part
$table->setHelper(new AdoptTableHelper);
$iterator = $list->iterator();
while($iterator->hasNext()){
$adopt = $iterator->next();
$cells = new LinkedList;
$cells->add(new TCell($table->getHelper()->getLevelupLink($adopt)));
$cells->add(new TCell($adopt->getName()));
$cells->add(new TCell($table->getHelper()->getOwnerProfile($adopt->getOwner())));
$cells->add(new String($adopt->getTotalClicks()));
$cells->add(new TCell($adopt->getCurrentLevel()));
$cells->add(new TCell($adopt->getTrophies())); #added this part
$table->buildRow($cells);
}
return $table;
}
}
?>
(No need to replace everything, just the parts I commented)
Abronsyth
11-06-2016, 03:03 PM
I do already have it in the statsview.php file, but for some reason it is unable to call the trophies.
An excerpt of my getTable function within statsview.php:
private function getTable($name, LinkedList $list){
$table = new TableBuilder($name);
$table->setAlign(new Align("center", "middle"));
$table->buildHeaders("Image", "Name", "Owner", "Total Clicks", "Trophies");
$table->setHelper(new AdoptTableHelper);
$iterator = $list->iterator();
while($iterator->hasNext()){
$adopt = $iterator->next();
$cells = new LinkedList;
$cells->add(new TCell($table->getHelper()->getLevelupLink($adopt)));
$cells->add(new TCell($adopt->getName()));
$cells->add(new TCell($table->getHelper()->getOwnerProfile($adopt->getOwner())));
$cells->add(new String($adopt->getTotalClicks()));
$cells->add(new TCell($adopt->getTrophies));
$table->buildRow($cells);
}
return $table;
}
Dinocanid
11-06-2016, 03:06 PM
Ahh, I think I see the possible problem. Did you try changing:
$cells->add(new TCell($adopt->getTrophies));
into:
$cells->add(new TCell($adopt->getTrophies()));
Abronsyth
11-17-2016, 04:17 PM
Only just saw your reply!
Trying it now...and I am getting this error:
Fatal error: Call to a member function select() on null in /home/inekelmy/public_html/classes/class_ownedadoptable.php on line 89
Lines 88-90 in class_ownedadoptable.php looks like this:
public function getTrophies(){
return $this->trophies;
}
Abronsyth
11-17-2016, 04:25 PM
Wait a minute, I may have figured it out. I added this (copied from totalclicks and such) and modified it under the get function:
public function setTrophies($trophies, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("trophies", $trophies);
$this->trophies = $trohpies;
}
Yes!! It is working 8D:
https://i.gyazo.com/c5364f292a998d44a360dd97f5ea7963.png
This is great!
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.