Display different stats on Stats page

Forum
Last Post
Threads / Messages

Abronsyth

A Headache Embodied
Member
Joined
Aug 25, 2011
Messages
1,012
Points
36
Location
NY
Mysidian Dollar
73,285
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;
PHP:
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!
 
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:
PHP:
$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:
<?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)
 
Last edited:
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:
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;
    }
 
Ahh, I think I see the possible problem. Did you try changing:
PHP:
$cells->add(new TCell($adopt->getTrophies));
into:
PHP:
$cells->add(new TCell($adopt->getTrophies()));
 
Only just saw your reply!

Trying it now...and I am getting this error:
Code:
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:
PHP:
	public function getTrophies(){
	    return $this->trophies;
	}
 
Wait a minute, I may have figured it out. I added this (copied from totalclicks and such) and modified it under the get function:
PHP:
	public function setTrophies($trophies, $assignMode = ""){
		if($assignMode == Model::UPDATE) $this->save("trophies", $trophies);
		$this->trophies = $trohpies;
	}

Yes!! It is working 8D:
c5364f292a998d44a360dd97f5ea7963.png


This is great!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top