View Single Post
  #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,961
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