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

Thread Tools Display Modes
Old 06-13-2017, 10:28 AM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Join Date: Aug 2016
Location: Maryland, USA
Posts: 515
Gender: Unknown/Other
Credits: 23,923
Dinocanid is on a distinguished road
Default Pet Sorting

Pet Sorting mod (Mys 1.3.4)
Description: A non-invasive and minimal mod that allows users to sort their pets according to total clicks, gender, level, and name; without the use of javascript or ajax. This can easily be extended on to allow more sorting options as well (like species).
  Spoiler: Screenshot 

-Step 1-
Go into phpMyAdmin and add a new column in users_options:

-Step 2-
Open up myadopts.php and replace the entire public function index with this:
PHP Code:
    public function index(){
$mysidia Registry::get("mysidia");
$total $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}'")->rowCount();
$pagination = new Pagination($total10"myadopts");
//Attempting to sort!
$sort $mysidia->db->select("users_options", array("petsort"), "username = '{$mysidia->user->username}'")->fetchColumn();
            switch (
$stmt $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY totalclicks LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
$stmt $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY gender LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}"); 
$stmt $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY currentlevel LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
$stmt $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY name LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
//Sorting ends here!
$this->setField("stmt", new DatabaseStatement($stmt));
-Step 3-
Finally, open myadoptsview.php and place this wherever you want the dropdown to be (I placed it above the table for adopts)
PHP Code:
//This is for sorting!
$choice $mysidia->input->post("sortlist");
$mysidia->db->update("users_options", array("petsort" => $choice), "username = '{$mysidia->user->username}'");
$document->add(new Comment("<meta http-equiv='refresh' content='0;url=/myadopts' />")); 
$sortForm = new Form("sortform""""post");
$sort_list = new DropdownList("sortlist");
$sort_list->add(new Option("Clicks""clicks"));
$sort_list->add(new Option("Gender""gender"));
$sort_list->add(new Option("Level""level"));
$sort_list->add(new Option("Name""name"));
$sortForm->add(new Comment("<b>Sort by:</b>"FALSE));
$sortForm->add(new Button("Sort Pets""sortpets""submit"));
//Sorting ends here!!! 
  Spoiler: Different codes for refreshing 

It is also possible to refresh the page with:
PHP Code:
header("Location: $root/myadopts");
PHP Code:
header("Location: /myadopts");
But this might not work for everyone

(Also if anyone knows how to safely place the button next to the dropdown box that would be great!)

Last edited by Dinocanid; 06-13-2017 at 10:31 AM.
Reply With Quote
Old 06-13-2017, 10:55 AM
parayna's Avatar
parayna parayna is offline
Join Date: May 2013
Location: Devon, UK
Posts: 312
Gender: Female
Credits: 9,649
parayna is on a distinguished road

Yay mod XD I also added a new option to mine at the top that says 'Select an option...' and instead of making it throw an error I made it set the users sort to the default (clicks). That way it's like a reset button and is basically a blank option XD Purely for aesthetic reasons lol If it resets what they had before then they were probably trying to change it anyway, so.. XD

Examples from my in-progress adoptable site's 7 available starters
My personal favourite designs, in fact!
Reply With Quote
Old 06-13-2017, 11:44 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
Join Date: Aug 2011
Location: NY
Posts: 996
Gender: Male
Credits: 44,525
Abronsyth is on a distinguished road

This is splendid, easy to edit, and simple to set up!!

Thank you very much for sharing, it is definitely a feature users appreciate!
Reply With Quote
Old 08-09-2018, 05:15 AM
draugluin's Avatar
draugluin draugluin is offline
Join Date: Oct 2011
Location: germany
Posts: 118
Gender: Unknown/Other
Credits: 5,085
draugluin is on a distinguished road

Ah.. this is GREAT !! thank you Dinocanid !
Reply With Quote

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 05:43 PM.

Currently Active Users: 222 (2 members and 220 guests)
Threads: 3,970, Posts: 31,513, Members: 15,581
Welcome to our newest members, kendricksmith.

What's New?

What's Hot?

What's Popular?

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