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
  #11  
Old 04-25-2017, 03:10 AM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 10,863
KatFennec is on a distinguished road
Default

What would I use to create a variable to pull from the owned adoptables table in the SQL database?
Reply With Quote
  #12  
Old 04-25-2017, 04:10 AM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 10,863
KatFennec is on a distinguished road
Default

Ok, so I got it working. Cludged a little of the code from here together with some of Kyttias' code.

PHP Code:
$profile $mysidia->user->getprofile();
$owned = new OwnedAdoptable($profile->getFavpetID());
$profile->getFavpetID();
$Name $owned->getName();
$Type $owned->getType();
$texta = new Paragraph;
$texta->add(new Comment(

<br> 
<img src='
{$owned->getImage()}'> 
<br> 
{$Name} the {$Type} 
<br> 
<a href='
{$mysidia->path->getAbsolute()}myadopts/manage/{$owned->getAdoptID()}'>View</a> | <a href='{$mysidia->path->getAbsolute()}account/activepet'>Change</a> 
"
)); 
$moduleContainer->add($texta); 
Reply With Quote
  #13  
Old 04-25-2017, 04:52 PM
aquapyrofan aquapyrofan is offline
Member
 
Join Date: Apr 2017
Posts: 48
Gender: Unknown/Other
Credits: 10,831
aquapyrofan is on a distinguished road
Default

The reason the above code works is because we could get it working as a module in the ACP, which won't accept if else statements. Don't know if that's the case with coding it in the file, but it's likely.
Reply With Quote
  #14  
Old 04-25-2017, 05:43 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 151,163
Abronsyth is on a distinguished road
Default

That is certainly curious, I have the favpet in my sidebar (and elsewhere on my site) using Kyttias's code without any issues.

Did you make sure to leave the code sections in the widget blank? The widget only exists for you to actually place within the sidebar, but no code goes into it via the ACP.
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #15  
Old 04-25-2017, 07:43 PM
aquapyrofan aquapyrofan is offline
Member
 
Join Date: Apr 2017
Posts: 48
Gender: Unknown/Other
Credits: 10,831
aquapyrofan is on a distinguished road
Default

Quote:
Originally Posted by Abronsyth View Post
That is certainly curious, I have the favpet in my sidebar (and elsewhere on my site) using Kyttias's code without any issues.

Did you make sure to leave the code sections in the widget blank? The widget only exists for you to actually place within the sidebar, but no code goes into it via the ACP.
We tried that and it showed absolutely nothing when the pet was set and broke the site when it wasn't. On a mod-free install of Mysidia as well. Kat was able to get it working with the code she posted plus an "if else" statement in the ACP, but the site still throws a 500 error if no pet is set.
Reply With Quote
  #16  
Old 04-25-2017, 07:48 PM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 10,863
KatFennec is on a distinguished road
Default

Quote:
Originally Posted by Abronsyth View Post
That is certainly curious, I have the favpet in my sidebar (and elsewhere on my site) using Kyttias's code without any issues.

Did you make sure to leave the code sections in the widget blank? The widget only exists for you to actually place within the sidebar, but no code goes into it via the ACP.
Yes, I did. I copied the code that Kyttias provided, pasted it into class_sidebar.php as per the instructions, then created a blank module, with the name FavPetSB, exactly as per instructions.

As it stands, I have the following code, emplaced within the PHP box of a new module. However, it seems that the if statement is causing some manner of issue - it works flawlessly if the user HAS set a favourite pet, but the entire site returns a 500 error if not, and they are logged in.
PHP Code:
$profile $mysidia->user->getprofile();
$owned = new OwnedAdoptable($profile->getFavpetID());


if(
$profile->getFavpetID() == 0){
$texta = new Paragraph;
$texta->add(new Comment(
<br>
Unfortunately, you don't seem to have a favourite pet set.
"
));
}
else {
$Name $owned->getName();
$Type $owned->getType();
$texta = new Paragraph;
$texta->add(new Comment(

<br> 
<img src='
{$owned->getImage()}'> 
<br> 
{$Name} the {$Type} 
<br> 
<a href='
{$mysidia->path->getAbsolute()}myadopts/manage/{$owned->getAdoptID()}'>View</a> | <a href='{$mysidia->path->getAbsolute()}account/profile'>Change</a> 
"
)); 
}
$moduleContainer->add($texta); 
EDIT: I should mention we have Mysidia installed in a subdomain, and on x10hosting, on the offhand chance either of those are contributing factors

Last edited by KatFennec; 04-25-2017 at 07:52 PM.
Reply With Quote
  #17  
Old 04-25-2017, 08:30 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 151,163
Abronsyth is on a distinguished road
Default

I have the function in classes/class_siderbar as this;
PHP Code:
    public function getFavPetSB(){
        return 
$this->FavPetSB;
    }

    protected function 
setFavPetSB(){
        
$mysidia Registry::get("mysidia");
        
$profile $mysidia->user->getprofile();   
        
        
/* IF THE USER DOES *NOT* HAVE A FAVPET: */
        
if ($profile->getFavpetID() == "0"){
            
$this->FavPetSB = new Paragraph
            
$this->FavPetSB->add(new Comment("<a href='LINK TO CHOOSE PAGE'>Choose Companion</a>"));
        }

        
/* IF THE USER *DOES* HAVE A FAVPET: */
        
if ($profile->getFavpetID() != "0"){
            
$favpet = new OwnedAdoptable($profile->getFavpetID());
            
$this->FavPetSB = new Paragraph
            
$this->FavPetSB->add(new Comment("<center><b>Companion</b><br><a href='/myadopts/manage/{$profile->getFavpetID()}'><img src='{$favpet->getImage()}' style='max-width:80px;' rel='tooltip' title=\"{$favpet->name}\"></a><br></center>"));


        }        
        
$this->setDivision($this->FavPetSB);
    } 
That makes it so if a user doesn't have it set then they'll just get a link to set it. I don't know how much I changed it from Kyttias's version, but maybe it'll work for you?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #18  
Old 04-25-2017, 08:43 PM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 10,863
KatFennec is on a distinguished road
Default

OK, so I think I've narrowed down the problem - it looks like getFavpetID() is NOT returning a 0 when there is no favourite pet assigned. Which is particularly strange, seeing as I poked through the databases, and it most certainly SHOULD be returning a zero.
Reply With Quote
  #19  
Old 04-25-2017, 08:52 PM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 10,863
KatFennec is on a distinguished road
Default

In an attempt to confirm my findings, I attempted to create a module to return the FavPetID.
PHP Code:
$profile $mysidia->user->getprofile();
$owned = new OwnedAdoptable($profile->getFavpetID());
$profile->getFavpetID();
$uniqueidforpet $profile->getFavpetID();
$texta = new Paragraph;
$texta->add(new Comment("
<br>
ID: 
{$profile->getFavpetID()}
"
));
$moduleContainer->add($texta); 
Placed in a module, it correctly returned my favourite pet, but when I set it to none caused the site to return a 500 error
Reply With Quote
  #20  
Old 04-25-2017, 09:02 PM
aquapyrofan aquapyrofan is offline
Member
 
Join Date: Apr 2017
Posts: 48
Gender: Unknown/Other
Credits: 10,831
aquapyrofan is on a distinguished road
Default

I fixed it, by suggesting that the part defining the owned adoptable class be moved to where it definitively exists after the install in WAMP threw an error that told me what the problem was. Oops.
Reply With Quote
Reply


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 04:13 PM.

Currently Active Users: 2116 (0 members and 2116 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