Home Community Mys-Script Creative Off-Topic |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Add Favorite Adopt to sidebar?
I'm wanting to add the user's favorite adopt to a sidebar module with the following structure:
(Image) Name the Species View | Change The view link would go to either their profile (if I can set that up) or to their "manage" page, while the "change" link would go to change the "active pet." Potentially with icons, most likely not. How would I go about this? |
#2
|
||||
|
||||
You'll want to check out this thread;
http://mysidiaadoptables.com/forum/s...favpet+sidebar
__________________
My Mods Site (1.3.4, 2020 Mods) |
#3
|
|||
|
|||
Quote:
|
#4
|
||||
|
||||
I know that thread is a lot to follow through, but I helped them with the basics before moving on. Here it is with just what you wanted:
To make a favpet display in the sidebar, first in the AdminCP you'll create a module (surprisingly not a widget): Then in classes/class_sidebar.php you'll need to add these functions: PHP Code:
$mysidia = Registry::get("mysidia"); // $mysidia is like god $profile = $mysidia->user->getprofile(); // $mysidia->user is an instance of the member class, so the function getprofile() is actually being called from class_member.php -- and what getprofile() does is create a new instance of the class_userprofile, which basically pulls information about (the current) user from the database $profile->getFavpetID() // so now our variable $profile is calling getFavpetID() from, you guessed it, class_userprofile.php, to get the id of the favorite pet (from here we check whether or not its set to anything past the default value of 0 and then move on) $favpet = new OwnedAdoptable($profile->getFavpetID()); // now we're creating $favpet as a new instance of the class "OwnedAdoptable" so we can call up functions from class_ownedadoptable.php and use them - but create a new instance of this class requires a parameter, and in this case, what it wants is the adoptable's ID number, so, that's exactly what we feed it $favpet->getImage() and $favpet->getName() and $favpet->getType() // these are all functions found in class_ownedadoptable.php -- so definitely check out that file to see what other kind of information you can dig up -- in addition, 'public' variables set at the top are also immediately accessible without a function call $mysidia->path->getAbsolute() // this one's really handy - $mysidia knows exactly what the root of your url is from when you installed, so you never have to worry if you change hosts or whatever - here we're using it to make sure our links definitely go to the right place every single time
__________________
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; 04-24-2017 at 09:45 PM. |
#5
|
|||
|
|||
Quote:
|
#6
|
||||
|
||||
Here, replace your entire classes/class_sidebar.php file with this one:
PHP Code:
__________________
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. |
#7
|
|||
|
|||
Quote:
|
#8
|
||||
|
||||
I tested this exact version of the file on my own site and it works just fine? Are you sure you created the module in the Admin CP exactly how the image shows?
__________________
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. |
#9
|
|||
|
|||
I just checked, it's exactly the same. I have no idea.
|
#10
|
||||
|
||||
Aquapyrofan and I are working together on this, so I've got a couple questions, since I'm having trouble getting this working as well. We've tried to set it exactly as you said, but it's still not working. As such, I was wondering whether the alchemy or item drop mods, or the fact that it was not installed at the domain's root, would be issues?
EDIT: tested on a clean install under WAMP, it still doesn't work Last edited by KatFennec; 04-25-2017 at 03:51 AM. |
|
|
What's New? |
What's Hot? |
What's Popular? |