View Single Post
  #2  
Old 03-05-2016, 05:18 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,345
Kyttias is on a distinguished road
Default

To make a favpet display inthe sidebar, first in the AdminCP you'll create a module (surprisingly not a widget):


Then in classes/class_sidebar.php you'll need to add these functions:
PHP Code:
public function getFavPetSB(){
        return 
$this->FavPetSB;
    }

protected function 
setFavPetSB(){
        
$mysidia Registry::get("mysidia");

        
$userfavpet $mysidia->db->select("users_profile", array("favpet"), "username = '{$mysidia->user->username}'")->fetchColumn(); 
        if (
$this->userfavpet == "0"){
            
$this->FavPetSB = new Paragraph
            
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
        }
        else{
            
$adopt = new OwnedAdoptable($userfavpet);
            
$this->FavPetSB = new Paragraph
            
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b> <br/>
                <a href='/myadopts/manage/
{$userfavpet}'><img src='{$adopt->getImage()}'></a>
                "
));
        }

        
$this->setDivision($this->FavPetSB);
    } 
Using "$adopt = new OwnedAdoptable($userfavpet);" you can also pull up data like {$adopt->getName()} and {$adopt->getCurrentLevel()} - these are functions found in classes/class_ownedadoptable.php, but you should also be able to use {$adopt->type} (which is not a function) to pull raw data from the database from the 'type' column - this holds the species.

But I'll get back to that. Let me know if you can at least get the pet into the sidebar and then I'll be back later help you set up a switch statement to display random phrases for pets to say.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote