Mys 1.3.6 Give Treasures/Held Items to Pets Script

Forum
Last Post
Threads / Messages

clay

Member
Member
Joined
May 2, 2023
Messages
8
Points
3
Age
27
Mysidian Dollar
158
I'm aware there's an existing script like this, but I wanted to create my own with its own purpose: any item can be held by a pet, no matter what the item function is (e.g. whether it's a key item or a consumable food item), and it can be taken away or switched with a different item at any time, and shown off; essentially as a pet "treasure."

Essentially, this script installs a "give" button to the inventory that lets users give any owned item to a pet (different from using or tossing). You can give a new treasure item to a pet and it'll retrieve the old item in its place, or you can go to a pet's My Adopt manage page and click "Remove Treasure."



First, navigate to service/helper/itemtablehelper.php and add this underneath the getUseForm() function, above the getSellForm() function.
PHP:
    public function getGiveForm(OwnedItem $item){
        $giveForm = new FormBuilder("giveform", "inventory/give", "post");
        $giveForm->setLineBreak(FALSE);
        $giveForm->buildComment("")
                ->buildPasswordField("hidden", "action", "give")
                ->buildPasswordField("hidden", "item", $item->getItemID())
                ->buildButton("Give", "give", "give");
        return $giveForm;               
    }

Now go to controller/main/inventorycontroller.php and add this function underneath the uses() function, above the sell() function.
PHP:
    public function give() {
        $mysidia = Registry::get("mysidia");
        $item = new OwnedItem($mysidia->input->post("item"), $mysidia->user->getID());   
        if(!$item->inInventory()) throw new ItemException("use_none");
        
        if($mysidia->input->post("aid")) {
            // if input wasn't valid
            if ($mysidia->input->post("validation") != "valid") {
                throw new ItemException("use_fail");
            } else {
                // give treasure to adoptable
                $mysidia->db->update("owned_adoptables", array("treasure" => $item->getItem()), "aid = '{$mysidia->input->post('aid')}'");
            }
        }

        $stmt = $mysidia->db->select("owned_adoptables", ["aid", "name"], "owner = '{$mysidia->user->getID()}'");
        $map = $mysidia->db->fetchMap($stmt);
        $this->setField("item", $item);
        $this->setField("petMap", $map);
    }

Go to view/main/inventoryview.php and put this after uses(), above sell().
PHP:
    public function give(){
        $mysidia = Registry::get("mysidia");
        $document = $this->document;   
        if($mysidia->input->post("aid")){
            $message = (string)$this->getField("message");
            $document->setTitle($this->lang->global_action_complete);
            $document->addLangvar($message);
            return;
        }
        
        $petMap = $this->getField("petMap");
        $document->setTitle($this->lang->select_title);
        $document->addLangvar($this->lang->select);       
        $chooseFrom = new Form("chooseform", "give", "post");
        
        $adoptable = new DropdownList("aid");
        $adoptable->add(new Option("None Selected", "none"));
        if($petMap->size() > 0){
            $iterator = $petMap->iterator();
            while($iterator->hasNext()){
                $adopt = $iterator->nextEntry();
                $adoptable->add(new Option($adopt->getValue(), $adopt->getKey()));
            }
        }       
        $chooseFrom->add($adoptable);
        
        $chooseFrom->add(new PasswordField("hidden", "item", $mysidia->input->post("item")));
        $chooseFrom->add(new PasswordField("hidden", "validation", "valid"));
        $chooseFrom->add(new Button("Choose this Adopt", "submit", "submit"));
        $document->add($chooseFrom);
    }

Add "Give" after "Use" and before "Sell" in $inventoryTable->buildHeaders(...) in the topmost index() function in that same inventoryview.php file like so:
eafd.png
...and add this line as well, after $cells->add(new TCell($inventoryTable->getHelper()->getUseForm($item)));
PHP:
            $cells->add(new TCell($inventoryTable->getHelper()->getGiveForm($item)));

Now navigate to model\domainmodel\ownedadoptable.php.
Add protected $treasure; under the other protected variables at the way top.

Above protected function save($field, $value) etc., copy paste this.
PHP:
    public function getTreasure() {
        return $this->treasure;
    }
    
    public function giveTreasure($treasure, $assignMode = "") {
        $mysidia = Registry::get("mysidia");
        $item = new OwnedItem($treasure, $mysidia->user->getID());
        $item->remove(1, $mysidia->user->getID());
        if ($this->treasure != "noitem") {
            $olditem = new OwnedItem($this->treasure, $mysidia->user->getID());
            $olditem->add(1, $mysidia->user->getID());
        }
        if ($assignMode == Model::UPDATE) $this->save("treasure", $treasure);
        $this->treasure = $treasure;
    }
    
    public function takeTreasure($assignMode = "") {
        $mysidia = Registry::get("mysidia");
        $item = new OwnedItem($this->treasure, $mysidia->user->getID());
        $item->add(1, $mysidia->user->getID());
        if ($assignMode == Model::UPDATE) $this->save("treasure", "noitem");
        $this->treasure = "noitem";
    }


Open view\main\myadoptsview.php. Paste this in the manage() function, before $document->add(new Image("templates/icons/add.gif"));
PHP:
        if ($ownedAdopt->getTreasure() != "noitem") {
            $treasure = new OwnedItem(($ownedAdopt->getTreasure()), $mysidia->user->getID());
            $document->add(new Comment("<div style='display:flex;align-items:center;'>
                <p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
                <p><b>Treasure:</b> {$treasure->getItemname()}</p>
            </div>"));
        } else {
            $document->add(new Comment("<div><p><b>Treasure:</b> None</p></div>"));
        }
Now add this after $document->add(new Link("levelup/click/{$ownedAdopt->getID()}", " Click Level Up Profile", TRUE));
PHP:
        if ($ownedAdopt->getTreasure() != "noitem") {
            $document->add(new Image("templates/icons/package-delete.png"));
            $document->add(new Link("myadopts/treasure/{$ownedAdopt->getID()}", " Remove Treasure", TRUE));
        }

"templates/icons/package-delete.png" references an image you haven't uploaded yet, so it's time to upload it! Save this image (or, replace it as you'd like) as "package-delete.png" and upload it to the templates\icons subdirectory.
package-delete.png

Now, go back to view\main\myadoptsview.php. Paste this inside class Myadoptsview, right before the final closing bracket.
PHP:
    public function treasure() {
        $mysidia = Registry::get("mysidia");
        $adopt = $this->getField("adopt");
        $image = $this->getField("image");
        $document = $this->document;
        
        $document->setTitle("Remove " . $adopt->getName() . "'s Treasure");
        $document->add($image);
        
        $document->addLangvar("<p>Successfully removed {$adopt->getName()}'s treasure and returned it to the inventory.</p>");
        if ($adopt->getGender() == "m") {$pronoun = "his";} else {$pronoun = "her";}
        $message = "<p>You can continue to manage {$adopt->getName()}'s settings from {$pronoun} <a href='myadopts/manage/{$adopt->getAdoptID()}'>My Adopts manage page</a>.</p>";
    }

Now to update your tables!
Navigate to (prefix)_owned_adoptables, edit the structure of the table, and add 1 new column named "treasure" with type "varchar(60)", null set to No, and default set to "noitem". It should look like this when done.
treasure table.png



By default, this script only displays your pet's treasure on the Manage Your Adoptable page. It's up to you to add more functionality and display pet treasures on other pages, like a pet's Level Up page, a user profile's adopts tab, the My Adopts page, or wherever else you might think of.
Try using this script:
PHP:
$treasure = new OwnedItem($mysidia->db->select("owned_adoptables", ["treasure"], "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn(), $mysidia->user->getID());
$treasuretxt = "{$treasure->getItemname()} <img class='treasure-img' src='{$treasure->getImageURL($fetchMode = 'Model::GUI')}' alt='{$treasure->getItemname()}'>";

Add $treasuretxt to a new Comment, and you should have text and an image with your pet's treasure!
 
Has anyone been able to get this to work?

I followed everything to the letter ( I think ) and everything seems good, no errors or anything anywhere --

but once you 'Give' the item and it goes in the database -- that pets my adopts page errors out and won't load. All the other things still work, just not that.

Then if you don't go in and manually insert 'noitem' again, it won't stop erroring, even if you remove the item number.

This looked like such a great mod but either I am missing something or there is an error. I was meticulous about adding everything, and again, got no code errors at all -- all was well, till I actually did the 'give' -- which also seems to work and insert the item number.
 
What exactly does the error say? Error messages give information why it's not working.

I personally don't like the inline html and CSS and this could be messing the views as I'm not sure which version of Mysidia this was written for. It could also mess with the Bootstrap mod. If I saw the error message, I might be able to tell if the inline styling might be part of the problem.

$document->add(new Comment("<div style='display:flex;align-items:center;'>
<p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
<p><b>Treasure:</b> {$treasure->getItemname()}</p>
</div>"));

divs should be styled on the CSS page and called with its name from the CSS with the new division function, and images should be called with the new image function.
 
Last edited:
What exactly does the error say? Error messages give information why it's not working.

I personally don't like the inline html and CSS and this could be messing the views as I'm not sure which version of Mysidia this was written for. It could also mess with the Bootstrap mod. If I saw the error message, I might be able to tell if the inline styling might be part of the problem.

$document->add(new Comment("<div style='display:flex;align-items:center;'>
<p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
<p><b>Treasure:</b> {$treasure->getItemname()}</p>
</div>"));

divs should be styled on the CSS page and called with its name from the CSS with the new division function, and images should be called with the new image function.


Just basically, it cant handle it lol.

It was in the 1.3.6 section, so presumed it was for that ...


error.png
 
As soon as I replace the item ID with 'noitem' again in SQL, we're good again.

Happens as soon as you go to the manage section ...
 
I'm going to add this to my site to see if I can figure this out. I think it might have to do with that if else block in the views with the inline styling, so I'll try to rewrite it to use the functions.
 
I put everything as is and got this error

Fatal error: Uncaught Error: Call to undefined method Model\ViewModel\OwnedAdoptableViewModel::getTreasure() in C:\wamp64\www\mysidia1.3.6\view\main\myadoptsview.php:68Stack trace:#0 C:\wamp64\www\mysidia1.3.6\resource\core\frontcontroller.php(120): View\Main\MyadoptsView->manage()#1 C:\wamp64\www\mysidia1.3.6\index.php(78): Resource\Core\FrontController->render()#2 C:\wamp64\www\mysidia1.3.6\index.php(84): IndexController->run()#3 C:\wamp64\www\mysidia1.3.6\index.php(88): IndexController::main()#4 {main} thrown in C:\wamp64\www\mysidia1.3.6\view\main\myadoptsview.php on line 68
Are you using a dev server like WAMP to test changes? Errors should be turned on so you can see them on a dev server.

This error shows that the code is looking in the ownedadoptableviewmodel and not ownedadoptable

I added this to ownedadoptableview model which fixed that error

public function getTreasure(){
return $this->model->getTreasure();
}

My next error was this:

Fatal error: Uncaught Exception: Fatal Error: Class View\Main\OwnedItem either does not exist, or has its include path misconfigured! in C:\wamp64\www\mysidia1.3.6\resource\core\loader.php:80Stack trace:#0 C:\wamp64\www\mysidia1.3.6\view\main\myadoptsview.php(69): Resource\Core\Loader->load('View\\Main\\Owned...')#1 C:\wamp64\www\mysidia1.3.6\resource\core\frontcontroller.php(120): View\Main\MyadoptsView->manage()#2 C:\wamp64\www\mysidia1.3.6\index.php(78): Resource\Core\FrontController->render()#3 C:\wamp64\www\mysidia1.3.6\index.php(84): IndexController->run()#4 C:\wamp64\www\mysidia1.3.6\index.php(88): IndexController::main()#5 {main} thrown in C:\wamp64\www\mysidia1.3.6\resource\core\loader.php on line 80

and I fixed it to at least load the page by changing the DB field treasure to this

Screenshot 2024-02-03 at 20-56-03 localhost _ MySQL _ mysidia _ adopts_owned_adoptables phpMyA...png

and then changing this line in ownedadoptsview to use 0 instead of noitem

if ($ownedAdopt->getTreasure() != "0") {
$treasure = new OwnedItem(($ownedAdopt->getTreasure()), $mysidia->user->getID());
$links->add(new Comment("<div style='display:flex;align-items:center;'>
<p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
<p><b>Treasure:</b> {$treasure->getItemname()}</p>
</div>"));
} else {
$links->add(new Comment("<div><p><b>Treasure:</b> None</p></div>"));
}

The page now loads though there is now a broken image link for the item if there is no item on the pet. This does not fix the fact that a class is being called in the wrong place and I will work on that next (new owneditem should be called in the controller and sent to views through a field). Having a bit of a carpal tunnel flare so this might take a few days but I'll post updates as I fix stuff.

also change any of the $document->add to $links->add in the links block or it will break your formatting

Here's the part of my code where I added the treasure stuff. I'll be fixing this more to get rid of inline styling, but for now it works without breaking the rest of the styling.

Code:
        $links->add(new Comment("<br>{$ownedAdopt->getName()}'s Links:<br>"));
        if ($ownedAdopt->getTreasure() != "0") {
            $treasure = new OwnedItem(($ownedAdopt->getTreasure()), $mysidia->user->getID());
            $links->add(new Comment("<div style='display:flex;align-items:center;'>
                <p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
                <p><b>Treasure:</b> {$treasure->getItemname()}</p>
            </div>"));
        } else {
            $links->add(new Comment("<div><p><b>Treasure:</b> None</p></div>"));
        }
        $links->add(new Image("templates/icons/add.gif"));
        $links->add(new Link("levelup/click/{$ownedAdopt->getID()}", " Level Up {$ownedAdopt->getName()}", TRUE));
        if ($ownedAdopt->getTreasure() != "0") {
            $links->add(new Image("templates/icons/package-delete.png"));
            $links->add(new Link("myadopts/treasure/{$ownedAdopt->getID()}", " Remove Treasure", TRUE));
        }
        $links->add(new Image("templates/icons/stats.gif"));
...........
 
Last edited:
Make sure this is at the top in the namespaces on the myadoptscontroller page:

use Model\DomainModel\OwnedItem;

I changed the myadoptscontroller for manage to this:

Code:
    public function manage($aid){
        $mysidia = Registry::get("mysidia");
        $this->initOwnedAdopt($aid);
        if ($this->adopt->getTreasure() != "0") {
            $this->treasure = new OwnedItem(($this->adopt->getTreasure()), $mysidia->user->getID());
        }else {
            $this->treasure = $this->adopt->getTreasure();
        }
        $this->setField("ownedAdopt", $this->adopt);
        $this->setField("image", $this->adopt->getImage(Model::GUI));
        $this->setField("ownedAdopt", new OwnedAdoptableViewModel($this->adopt));
        $this->setField("treasure", $this->treasure ? $this->treasure : NULL);
    }

Here's my updated code in ownedadoptview

Code:
        $links->add(new Comment("<br>{$ownedAdopt->getName()}'s Links:<br>"));
        $treasure = $this->getField("treasure");
        if ($ownedAdopt->getTreasure() != "0") {
            $links->add(new Comment("<div style='display:flex;align-items:center;'>
                <p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
                <p><b>Treasure:</b> {$treasure->getItemname()}</p>
            </div>"));
        } else {
            $links->add(new Comment("<div><p><b>Treasure:</b> None</p></div>"));
        }

So far page loads fine when treasure field is 0 and the broken image link is gone. I haven't tested giving an item and seeing if that works yet.

Screenshot 2024-02-03 at 22-05-05 Mysidia1.3.6.png
 
Last edited:
Thank you for all your hard work on this!

it turned out to be quite perplexing ... made the changes and alterations, and used the Give function - on my site that part is working ok -- it inserted the number and then got this error for manage:


Code:
An error has occurred...

Fatal Error: Class Controller\Main\OwnedItem either does not exist, or has its include path misconfigured!


You had mentioned there was a Controller being called somewhere incorrectly, I am guessing this is it!


So went in and manually removed the item number again from that pet's treasure in phpmyadmin, made it a 0 again -- (which had been working ) and now went back to the page of 'Can't handle the request' -- now none of the pets Manage page will come up, just the same black page with "Cant handle etc"-

So went back in, and added the item number once more manually to the treasure section in SQL.

Now that ONE pet's manage will come up with this error again, none of the others will load at all.

Very strange!

Rest the carpal tunnel, I know how that is!

( since this was making all the My Adopts manage not work at all, I saved all the modded versions of pages with a rename and just uploaded my trusty backups for now )



error2.png
 
Last edited:
Make sure this is at the top in the namespaces on the myadoptscontroller page, I forgot to include it (I'll add it to my post above so anyone following will not want to throw their computer out the window at this point):

use Model\DomainModel\OwnedItem;


Also, it's very important to have a developer site to test things before uploading to your main site. Having things randomly break on a live site gives a bad experience to anyone online in the moment and while some users might be tolerant and helpful about it, others might simply leave out of frustration. You can use WAMP server on your personal computer (this is what I use), or have a testing site using a free webhost, just make sure to make it stated on that site that it is a testing site and provide a link to your live site. I would do this through editing the index page in the ACP on the testing site, and not through anything hard coded in the html or php as you might accidentally upload that to your live site.
 
Last edited:
Thank you for the addition, and yes, very good advice there!

I am testing all this out on a not- live site, that is, not open yet to anyone but myself and my second test account.

I can only imagine how frustrating it would be for a player!
 
Okay having gone through and methodically removed anything new, and uploaded new files for all this adopts stuff, I found I think where a possibly new error is happening.

Slowly adding it all back, I was fine until I got to myadoptscontroller - adding the new manage code in got the black page and 'Cant handle' error, and replacing the new manage code to the original ( un modded simple version) makes it load again.

Hope that helps, process of elimination I guess. I immediately errored when I made this change to the new modded manage there.

** Also .. maybe due to not being able to mod the myadoptscontroller successfully, any pet with an item number for treasure errors out still, with the 'Cant handle' black page.

if its a 0 in that field, it comes up for manage page okay.
 
Last edited:
Also I tested giving items, that works, but I got an error for taking items and found out there's nothing in the controller for removing them. I added this function in myadoptscontroller

Code:
    public function treasure($aid, $confirm = NULL){
        $mysidia = Registry::get("mysidia");
        $this->initOwnedAdopt($aid);
        if($confirm){
            if(!$aid) $this->index();
            $this->adopt->takeTreasure(Model::UPDATE);
        }
        $this->setField("adopt", $this->adopt);
        $this->setField("image", $this->adopt->getImage(Model::GUI));
        $this->setField("confirm", $confirm ? new MysString($confirm) : NULL);
    }

I also had to change the treasure functions in ownedadoptable model:

Code:
    public function giveTreasure($treasure, $assignMode = "") {
        $mysidia = Registry::get("mysidia");
        $item = new OwnedItem($treasure, $mysidia->user->getID());
        $item->remove(1, $mysidia->user->getID());
        if ($this->treasure != "0") {
            $olditem = new OwnedItem($this->treasure, $mysidia->user->getID());
            $olditem->add(1, $mysidia->user->getID());
        }
        if ($assignMode == Model::UPDATE) $this->save("treasure", $treasure);
        $this->treasure = $treasure;
    }
   
    public function takeTreasure($assignMode = "") {
        $mysidia = Registry::get("mysidia");
        $item = new OwnedItem($this->treasure, $mysidia->user->getID());
        $item->add(1, $mysidia->user->getID());
        if ($assignMode == Model::UPDATE) $this->save("treasure", "0");
        $this->treasure = "0";
    }

And finally I fixed some things in myadoptsview


Code:
        $links->add(new Comment("<br>{$ownedAdopt->getName()}'s Links:<br>"));
        $treasure = $this->getField("treasure");
        if ($ownedAdopt->getTreasure() != "0") {
            $links->add(new Comment("<div style='display:flex;align-items:center;'>
                <p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
                <p><b>Treasure:</b> {$treasure->getItemname()}</p>
            </div>"));
            $links->add(new Image("templates/icons/package-delete.png"));
            $links->add(new Link("myadopts/treasure/{$ownedAdopt->getID()}/confirm", " Remove Treasure", TRUE));
        } else {
            $links->add(new Comment("<div><p><b>Treasure:</b> None</p></div>"));
        }
        $links->add(new Image("templates/icons/add.gif"));
        $links->add(new Link("levelup/click/{$ownedAdopt->getID()}", " Level Up {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/stats.gif"));
        $links->add(new Link("myadopts/stats/{$ownedAdopt->getID()}", " Get Stats for {$ownedAdopt->getName()}", TRUE));


Code:
    public function treasure() {
        $mysidia = Registry::get("mysidia");
        $adopt = $this->getField("adopt");
        $image = $this->getField("image");
        $confirm = $this->getField("confirm");
        $document = $this->document;
       
        $document->setTitle("Remove " . $adopt->getName() . "'s Treasure");
        $document->add($image);
       
        if($confirm){
            $document->addLangvar("<p>Successfully removed {$adopt->getName()}'s treasure and returned it to the inventory.</p>");
            if ($adopt->getGender() == "m") {$pronoun = "his";} else {$pronoun = "her";}
                $message = "<p>You can continue to manage {$adopt->getName()}'s settings from {$pronoun} <a href='myadopts/manage/{$adopt->getAdoptID()}'>My Adopts manage page</a>.</p>";
        }
    }
 
Last edited:
We're really having to work for this one!

Thank you for all your work on this!! Don't over do the carpal tunnel, been there and done that, and it can get excruciating ...

Going to try these new things now after breakfast :) Thank you again!
 
No matter what I modify ( and I made all the additions and alterations ) -- if its anything other than '0' in the field, it does the same old error, black page and can't load.

everything seems fine till it sees anything other than 0 there. Which is what it was doing before, with 'noitem'.

Frustrating .. can't figure it out. It will even let you 'remove' a non existent item - that part of the code works too. But showing the item and not erroring out if there is actually something in that field, nope. There is really something it doesn't like about figuring out that item ID number and associating it with an actual object to be shown I guess ..
 
It feels like it still can't pull the item info from the id provided in the treasure field

Did you add this at the top in the namespaces on the myadoptscontroller page?

Code:
use Model\DomainModel\OwnedItem;

My full namespaces on myadoptscontroller looks like this (showing you where I placed mine)

Code:
namespace Controller\Main;
use Model\DomainModel\AdoptNotfoundException;
use Model\DomainModel\OwnedAdoptable;
use Model\DomainModel\PoundAdoptable;
use Model\DomainModel\OwnedItem;
use Model\DomainModel\Vote;
use Model\Settings\PoundSettings;
use Model\ViewModel\OwnedAdoptableViewModel;
use Resource\Collection\ArrayList;
use Resource\Core\AppController;
use Resource\Core\Model;
use Resource\Core\Pagination;
use Resource\Core\Registry;
use Resource\Exception\NoPermissionException;
use Resource\Exception\InvalidActionException;
use Resource\Native\MysString;

This is my entire manage function in myadoptscontroller

Code:
    public function manage($aid){
        $mysidia = Registry::get("mysidia");
        $this->initOwnedAdopt($aid);
        if ($this->adopt->getTreasure() != "0") {
            $this->treasure = new OwnedItem(($this->adopt->getTreasure()), $mysidia->user->getID());
        }else {
            $this->treasure = $this->adopt->getTreasure();
        }
        $this->setField("ownedAdopt", $this->adopt);
        $this->setField("image", $this->adopt->getImage(Model::GUI));
        $this->setField("ownedAdopt", new OwnedAdoptableViewModel($this->adopt));
        $this->setField("treasure", $this->treasure ? $this->treasure : NULL);
    }

I'm including my entire manage function in myadoptsview so you can see where I placed my changes. There's extra stuff in there not in vanilla including commented out code so don't copy paste this, just use it as reference. I still need to fix that inline styling too

Code:
    public function manage(){   
        $document = $this->document;   
        $ownedAdopt = $this->getField("ownedAdopt");
        $adoptbackground = "{$ownedAdopt->getAdoptBackground()}";
        $background = new Image($adoptbackground);
        $background->setType("background");
        $image = $this->getField("image");
        $document->setTitle("Managing {$ownedAdopt->getName()}");

        $petImage = new Division(NULL,"petimage");
        $petImage->setAlign(new Align("center", "center"));
        $petImage->setBackground($background);
        $petImage->add($image);
        $document->add($petImage);

        $adoptStats = new Division(NULL, "left");
        $adoptStats->add($ownedAdopt->getStats());
        $document->add($adoptStats);

        $links = new Division(NULL, "right");
        $links->add(new Comment("<br>{$ownedAdopt->getName()}'s Links:<br>"));
        $treasure = $this->getField("treasure");
        if ($ownedAdopt->getTreasure() != "0") {
            $links->add(new Comment("<div style='display:flex;align-items:center;'>
                <p><img src='{$treasure->getImageURL()}' alt='{$treasure->getItemname()}'></p>
                <p><b>Treasure:</b> {$treasure->getItemname()}</p>
            </div>"));
            $links->add(new Image("templates/icons/package-delete.png"));
            $links->add(new Link("myadopts/treasure/{$ownedAdopt->getID()}/confirm", " Remove Treasure", TRUE));
        } else {
            $links->add(new Comment("<div><p><b>Treasure:</b> None</p></div>"));
        }
        $links->add(new Image("templates/icons/add.gif"));
        $links->add(new Link("levelup/click/{$ownedAdopt->getID()}", " Level Up {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/stats.gif"));
        $links->add(new Link("myadopts/stats/{$ownedAdopt->getID()}", " Get Stats for {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/bbcodes.gif"));
        $links->add(new Link("myadopts/bbcode/{$ownedAdopt->getID()}", " BBCodes/HTML Codes for {$ownedAdopt->getName()}", TRUE));
           //$document->add(new Image("templates/icons/title.gif"));
        //$document->add(new Link("inventory/backgrounditems/}", " Change Background Image for {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/title.gif"));
        $links->add(new Link("myadopts/rename/{$ownedAdopt->getID()}", " Rename {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/trade.gif"));
        $links->add(new Link("myadopts/trade/{$ownedAdopt->getID()}", " Change Trade status for {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/freeze.gif"));
        $links->add(new Link("myadopts/freeze/{$ownedAdopt->getID()}", " Freeze or Unfreeze {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/delete.gif"));
        $links->add(new Link("pound/pound/{$ownedAdopt->getID()}", " Pound {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/delete.gif"));
        $links->add(new Link("myadopts/free/{$ownedAdopt->getID()}", " Set Free {$ownedAdopt->getName()}", TRUE));
        $links->add(new Image("templates/icons/next.gif"));
        $links->add(new Link("myadopts/index/}", "Return to Manage Adoptables page"));
        $document->add($links);
    }
 
Last edited:
I did add everything in, but it still isn't recognizing that treasure field as something to fetch and display.

It just black page error's out, every time ....

Is it working for you?

I mean is it displaying anything for the 'held' item, for the treasure?

I am at a loss at this point ... I am sure I have added everything in right, but it either errors totally or just won't work correctly if anything other than '0' is in the field.

Starting to wonder if maybe I shouldnt just work on getting layers to work ...

Thanks for sharing all your work on this!
 
I'm sorry, maybe if you want to send me your files for those specific pages I can see if I can spot anything. It is working for me, even got rid of the inline styling (I'll probably move it out of the links side and into the stats side but my site is modded to add in the stats on the manage page).




Screenshot 2024-02-04 at 21-38-50 Mysidia1.3.6.png
 
Last edited:
I'm sorry, maybe if you want to send me your files for those specific pages I can see if I can spot anything. It is working for me, even got rid of the inline styling (I'll probably move it out of the links side and into the stats side but my site is modded to add in the stats on the manage page).




View attachment 755


I really appreciate that.

I hate to ask you to do more .. you have done a lot of work as it is ...

I may have just gotten so tired from doing and re doing it all I have missed or undone something important by this point. At this point I am a little lost, honestly.

Thank you again for all your help. :)
 

Attachments

  • myadoptsview.php
    13.1 KB · Views: 2
  • myadoptscontroller.php
    6.4 KB · Views: 2
  • ownedadoptable.php
    11.2 KB · Views: 2
I took a break on my hands past couple days, sorry about that.

Could you also send me ownedadoptableviewmodel?

I'll look at these next couple of days and get back to you on the weekend as I work during the week and it's hard for me to think after a long day, but I will get back to you :)
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

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

Latest Threads

Top