Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Reply
 
Thread Tools Display Modes
  #1  
Old 12-28-2017, 11:03 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 992
Gender: Male
Credits: 37,526
Abronsyth is on a distinguished road
Default Item Pages

I wanted to make my inventory pages nice and clean, plus make greater use of the item system (as my site requires users to assign items to pets). So I came up with this and, after a lot of screeching in frustration, I have it working. It still needs some work in spifying it up and streamlining the process, but I have seen folks bring it up before so figured I'd share it as-is.

First! I cannot recall if it is dependent on Kyttias's mod, but it may very well be so note you'll want to install this mod first: http://mysidiaadoptables.com/forum/s...ead.php?t=4741

Okay, so let's get started. The good news is you do not have to touch your database at all (whew!).

Assuming you have Kyttias' mod installed, the first part we're going to edit is how we display items in the inventory. Open up inventoryview.php and scroll to where you see the notation; # Rendering items now
Now I replaced everything between that note, and the closing bracket ( } ) for this line; for($i = 0; $i < $iids->length(); $i++){.
PHP Code:
$document->add(new Comment("<div class=\"s_panel sc_item\">
            <img rel=\"tooltip\" title=\"
{$usage}\" src=\"{$item->imageurl}\"/><br>
              <b>
{$item->itemname}</b><br> Own &times;{$item->quantity}<br>"FALSE));
           
                
$useForm = new FormBuilder("useform""inventory/uses""post");
                
$useForm->setLineBreak(FALSE);
                
$useForm->buildPasswordField("hidden""action""use")
                        ->
buildPasswordField("hidden""itemname"$item->itemname)
                        ->
buildButton("Manage""use""use");
                
$document->add($useForm);
                
                
$document->add(new Comment("</div>"FALSE)); 
What this does is makes it so we see the item's image, name, how many you own, and a "Manage" button. The manage button is clickable but totally useless right now.

Now we're going to replace EVERYTHING between the END of the INDEX function and the START of the TOSS function with this messy chunk of code;
PHP Code:
    public function uses(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
$itemname $mysidia->input->post("itemname");    
        
$image $mysidia->db->select("items", array("imageurl"), "itemname='{$mysidia->input->post("itemname")}'")->fetchColumn();
        
$consumable $mysidia->db->select("items", array("consumable"), "consumable='yes'")->fetchColumn();
        
$quantity $mysidia->db->select("inventory", array("quantity"), "itemname='{$itemname}'" AND "owner='{$mysidia->user->username}'")->fetchColumn();
        
        if(
$mysidia->input->post("aid")){
            
$message = (string)$this->getField("message");
            
$document->setTitle($mysidia->lang->global_action_complete);
            
$document->addLangvar($message);
            return;        
        }
        
        
$petMap $this->getField("petMap");
        
$document->setTitle("Manage Item");
        
$document->add(new Comment("<center><b>{$itemname}</b><br>
<img src='
{$image}'/><br>
<b>Owned:</b> 
{$quantity}</center>"));
if(
$consumable) {
    
$document->add(new Comment("<h2>Use</h2>"));
        
$document->addLangvar($mysidia->lang->select);        
        
$chooseFrom = new Form("chooseform""uses""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""itemname"$mysidia->input->post("itemname")));
        
$chooseFrom->add(new PasswordField("hidden""validation""valid"));
        
$chooseFrom->add(new Button("Choose this pet""submit""submit"));
        
$document->add($chooseFrom);}
else{
             
$document->add(new Comment("<button style='cursor:not-allowed;' type='button'>Unusable</button><br><br>"FALSE));
            }
        
        
//SELL FORM//
        
$price $mysidia->db->select("items", array("price"), "itemname='{$mysidia->input->post("itemname")}'")->fetchColumn();
        
$sellback $price 2;
            if(
$item->function == "Key") {
            
$document->add(new Comment("
            <button style='cursor:not-allowed;' type='button'>Unsellable</button> "
FALSE));
            }    
            else {
                
$sellForm = new FormBuilder("sellform""sell""post");
                
$sellForm->setLineBreak(FALSE);
                
$sellForm->buildPasswordField("hidden""action""sell")
                         ->
buildPasswordField("hidden""itemname"$mysidia->input->post("itemname"));
                
$quantity = new TextField("quantity");
                
$quantity->setSize(3);
                
$quantity->setMaxLength(3);
                
$quantity->setLineBreak(FALSE);

                
$sell = new Button("Sell""sell""sell");
                
$sell->setLineBreak(FALSE);

                
$sellForm->add($quantity);
                
$sellForm->add($sell);
        
$document->add(new Comment("<h2>Sell for {$sellback} {$mysidia->settings->cost} Each</h2>"));
                            
$document->add($sellForm);
    }}
    
    public function 
sell(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
$document->setTitle($this->lang->global_transaction_complete);
        
$document->addLangvar("{$this->lang->sell}{$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} {$this->lang->sell2}");
    } 
What this does is create a page to manage that item. It shows the item's name, image, and quantity owned. It also shows two forms, a Use form, and a Sell form. The use form only works if the item is consumable, otherwise it states "unusable," and the sell form does NOT work for "Key" items. To use it, it shows a drop-down of the user's pets. To sell it the page shows the price it's worth, and lets the user put the quantity to sell in the box. (Don't worry, they cannot sell more than they own).

That's all there is to it! I know the code itself is messy and the manage page could use some beautifying, but I'll leave that to you.

If you have questions/comments/etc just post and I'll get to it when I am able

Happy new year, y'all!
__________________
Reply With Quote
  #2  
Old 12-29-2017, 09:44 AM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 422
Gender: Unknown/Other
Credits: 15,697
Dinocanid is on a distinguished road
Default

It looks great, thanks! It looks like you forgot to include the styling for the items, since every items appears underneath each other instead of next to each other. I fixed it by adding style tags though:
PHP Code:
$document->add(new Comment("
            <style>
                .sc_item {
                  display: inline-table;
                  padding: 5px;
                  text-align: center;
                  font-family: 'Trebuchet MS', Helvetica, sans-serif;
                  font-size: 14px;
                  margin-bottom: 3px;
                }
                .s_panel {
                  border-radius: 2px;
                  border: 1px solid #CCC;
                  background-color: #FBFDF2;  
                  height: 200px;
                }
            </style>     
            <div class='s_panel sc_item'> 
            <img rel='tooltip' title='
{$usage}' src='{$item->imageurl}' style='height:100px; width:auto;'><br> 
              <b>
{$item->itemname}</b><br> Own &times;{$item->quantity}<br>"FALSE)); 
I think it only works without adding style tags if you added Kyttias's styling in your theme's css file.
__________________
Reply With Quote
  #3  
Old 12-29-2017, 09:39 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 992
Gender: Male
Credits: 37,526
Abronsyth is on a distinguished road
Default

Oops, thank you for that! I don't notate my modifications well in the moment lol
__________________
Reply With Quote
  #4  
Old 12-30-2017, 01:34 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 838
Gender: Female
Credits: 33,397
Kyttias is on a distinguished road
Send a message via AIM to Kyttias
Default

I'm tickled people are making mods from my mods and sharing 'em.
Reply With Quote
  #5  
Old 12-30-2017, 08:44 AM
Silver_Brick Silver_Brick is offline
Designer || Coder
 
Join Date: Oct 2016
Location: In Earth
Posts: 202
Gender: Male
Credits: 6,547
Silver_Brick is on a distinguished road
Default

Great work abro i really appreciate it and i don't think so this is really based on kyttias mod .
__________________
Reply With Quote
  #6  
Old 12-30-2017, 11:31 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 992
Gender: Male
Credits: 37,526
Abronsyth is on a distinguished road
Default

@Kyttias, I have learned a lot from your mods on what's possible/how to do things, and a lot of them have the perfect set-up to expand on, they're great

@Silver_Brick, thank you, you're welcome, and it's definitely heavily "inspired"/derrived from it, but I am sure that you can modify it to use w/out Kyttias' mod.
__________________
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 06:17 PM.

Currently Active Users: 214 (1 members and 213 guests)
Threads: 3,912, Posts: 31,103, Members: 15,462
Welcome to our newest members, Giggi.
BER





What's New?

What's Hot?

What's Popular?


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