Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2017, 09:03 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 126,581
Kyttias is on a distinguished road
Default

I know that thread is a lot to follow through, but I helped them with the basics before moving on. Here it is with just what you wanted:

To make a favpet display in the 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");
    
$profile $mysidia->user->getprofile();
    
    if (
$profile->getFavpetID() == "0"){ // In case the user's fav pet isn't set...
        
$this->FavPetSB = new Paragraph
        
$this->FavPetSB->add(new Comment("

            <br>
            <b>No Favorite Pet!</b>
            <br>
            <a href='
{$mysidia->path->getAbsolute()}account/activepet'>Choose Favorite Pet?</a>

        "
));
    } else { 
// It must be set, so let's pull information from it.
        
$favpet = new OwnedAdoptable($profile->getFavpetID());
        
$this->FavPetSB = new Paragraph;
            
$this->FavPetSB->add(new Comment("

            <br>    
            <img src='
{$favpet->getImage()}'>
            <br>
            
{$favpet->getName()} the {$favpet->getType()}
            <br>
            <a href='
{$mysidia->path->getAbsolute()}myadopts/manage/{$favpet->getAdoptID()}'>View</a> | <a href='{$mysidia->path->getAbsolute()}account/activepet'>Change</a>

        "
));
    }

Try that and let me know how it goes? For some clarification, if it helps--

$mysidia = Registry::get("mysidia"); // $mysidia is like god

$profile = $mysidia->user->getprofile(); // $mysidia->user is an instance of the member class, so the function getprofile() is actually being called from class_member.php -- and what getprofile() does is create a new instance of the class_userprofile, which basically pulls information about (the current) user from the database

$profile->getFavpetID() // so now our variable $profile is calling getFavpetID() from, you guessed it, class_userprofile.php, to get the id of the favorite pet (from here we check whether or not its set to anything past the default value of 0 and then move on)

$favpet = new OwnedAdoptable($profile->getFavpetID()); // now we're creating $favpet as a new instance of the class "OwnedAdoptable" so we can call up functions from class_ownedadoptable.php and use them - but create a new instance of this class requires a parameter, and in this case, what it wants is the adoptable's ID number, so, that's exactly what we feed it

$favpet->getImage() and $favpet->getName() and $favpet->getType() // these are all functions found in class_ownedadoptable.php -- so definitely check out that file to see what other kind of information you can dig up -- in addition, 'public' variables set at the top are also immediately accessible without a function call

$mysidia->path->getAbsolute() // this one's really handy - $mysidia knows exactly what the root of your url is from when you installed, so you never have to worry if you change hosts or whatever - here we're using it to make sure our links definitely go to the right place every single time
__________________
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.

Last edited by Kyttias; 04-24-2017 at 09:45 PM.
Reply With Quote
  #2  
Old 04-24-2017, 09:31 PM
aquapyrofan aquapyrofan is offline
Member
 
Join Date: Apr 2017
Posts: 48
Gender: Unknown/Other
Credits: 10,832
aquapyrofan is on a distinguished road
Default

Quote:
Originally Posted by Kyttias View Post
I know that thread is a lot to follow through, but I helped them with the basics before moving on. Here it is with just what you wanted:

To make a favpet display in the 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");
    
$profile $mysidia->user->getprofile();
    
    if (
$profile->getFavpetID() == "0"){ // In case the user's fav pet isn't set...
        
$this->FavPetSB = new Paragraph
        
$this->FavPetSB->add(new Comment("

            <br>
            <b>No Favorite Pet!</b>
            <br>
            <a href='
{$mysidia->path->getAbsolute()}account/activepet'>Choose Favorite Pet?</a>

        "
));
    } else { 
// It must be set, so let's pull information from it.
        
$favpet = new OwnedAdoptable($profile->getFavpetID());

        
$this->FavPetSB->add(new Comment("

            <br>    
            <img src='
{$favpet->getImage()}'>
            <br>
            
{$favpet->getName()} the {$favpet->getType()}
            <br>
            <a href='
{$mysidia->path->getAbsolute()}myadopts/manage/{$favpet->getAdoptID()}'>View</a> | <a href='{$mysidia->path->getAbsolute()}account/activepet'>Change</a>

        "
));
    }

Try that and let me know how it goes? For some clarification, if it helps--

$mysidia = Registry::get("mysidia"); // $mysidia is like god

$profile = $mysidia->user->getprofile(); // $mysidia->user is an instance of the member class, so the function getprofile() is actually being called from class_member.php -- and what getprofile() does is create a new instance of the class_userprofile, which basically pulls information about (the current) user from the database

$profile->getFavpetID() // so now our variable $profile is calling getFavpetID() from, you guessed it, class_userprofile.php, to get the id of the favorite pet (from here we check whether or not its set to anything past the default value of 0 and then move on)

$favpet = new OwnedAdoptable($profile->getFavpetID()); // now we're creating $favpet as a new instance of the class "OwnedAdoptable" so we can call up functions from class_ownedadoptable.php and use them - but create a new instance of this class requires a parameter, and in this case, what it wants is the adoptable's ID number, so, that's exactly what we feed it

$favpet->getImage() and $favpet->getName() and $favpet->getType() // these are all functions found in class_ownedadoptable.php -- so definitely check out that file to see what other kind of information you can dig up -- in addition, 'public' variables set at the top are also immediately accessible without a function call

$mysidia->path->getAbsolute() // this one's really handy - $mysidia knows exactly what the root of your url is from when you installed, so you never have to worry if you change hosts or whatever - here we're using it to make sure our links definitely go to the right place every single time
Where exactly am I supposed to put that? I get a HTTP ERROR 500 so I know something isn't right.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:11 PM.

Currently Active Users: 2285 (0 members and 2285 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636