View Single Post
  #2  
Old 12-14-2014, 02:13 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,370
Kyttias is on a distinguished road
Default

Hmm... Well... I modified my default shop pages. Specifically, classes/class_itemshop.php. Outside of that, I really can't help. Shops are tied to three or four other files and having to clone all of them would just be tedious. Save backups of the original classes/class_itemshop.php, and bear with me. (And I assume the class for adoptshop would be similar, but I actually haven't modified mine yet.) Because you add items to shops through the AdminCP, these additional files I'm talking about all work together to display the items that belong in a particular shop, pull up item information, and construct the functionality needed for the buttons. To recreate it all, you'd need exactly the same files already in place -- so you really have no choice but to work with them, else work entirely from scratch with little help from the community.

Inside public function display is where all the important magic is happening for this. So examine everything going on in this function in its default state and try to wrap your head around it.

If you could draw or create a visual mockup/representation of what you want the finished product to look like, I can try to help from there? I will also need to know the name of at least two item shops to start my example, but the more the merrier. I designed my shops to use tooltips, but any arrangement of information is possible.

You want two things - to render an NPC image based on the shop, and, I assume to change the entire way items are listed.

As a start, in public function display:
PHP Code:
# Choose the NPC image based on the name of the shop
    
switch ($this->shopname) {
        case 
"Crossed Roads":                     
            
$npc_img "http://fc00.deviantart.net/fs71/f/2014/262/a/2/base_npc_60_by_kyttias-d7zqrnf.png";
            break;
        case 
"Spectrum"
            
$npc_img "http://fc00.deviantart.net/fs70/f/2014/313/a/c/base_npc_2_60_by_kyttias-d85ww5k.png";    
            break;
        default; 
            
$npc_img "http://placekitten.com/g/200/500";
            break;
    }
            
# Now let's render the NPC, use css to position the div with the class name of .shop_npc
    
$document->add(new Comment("<div class='shop_npc'><img src='{$npc_img}'/></div>"FALSE)); 
I have two shops, Crossed Roads and Spectrum. If I make a shop and forget to list it here, it will use the default.

The switch statement I've constructed above is using $this->shopname. The word "this" means, literally, defined inside this class. This page. Up at the top you'll find public $shopname;. If you were some other page, you'd need to pull up that information with a function yourself. Why create a page for each shop if each shop is going to need to pull all the same data from the database to construct itself? This is the entire basis of object oriented PHP - to avoid repeating yourself.

So this is why I encourage you to modify the default shop rendering.

If you'll show me how you want items to display, if you don't want the default table that is, I can get to the next step. ^^

-

But, then again, upon reading closer, I think you may also be wanting an entirely new kind of shop? One that uses items, rather than currency? (Possibly multiple items? And currency in addition? How complex.)

If you like the default shops as they are, you can ignore everything I've said. But an entirely new kind of shop that uses items as a currency would need work beyond what I can do in a single night.

I mean, I like the concept, so I can try to tinker over winter break. How many shops of this kind were you wanting? Just one, or many?
__________________
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; 12-14-2014 at 02:26 PM.
Reply With Quote