![]() |
I updated the code above, give it a shot?
I can also try to make an addendum to the family tree code to prevent nonexistent pets from displaying. That'll definitely be easier in the long run, I think. (Actually no, it wasn't, I learned something from HoF in the process.) Basically, in the family tree code, we need to wrap the offspring in a try/catch statement, so find the foreach loop: PHP Code:
|
Thank you so much Kyttias! I'm going to test it out later when I get home (:
|
I'm now using code from both post #9 and post #11 just to be safe. While I was discussing this with HoF he expressed some of the same concerns I had, however, so it's worth bringing up:
We don't really know if other side effects will exist. I can't immediately fathom any, but that doesn't mean they don't exist. What if a pet is deleted half way through a trade? Will it corrupt the trade section for one person, both people, everyone? And, is it possible to to keep the pet's profile open, release it to the pound, and because you still have your pet's page open as if you own it - delete it? Would that break the pound? I haven't fully considered these things so please do some testing. It's hard to officially approve of deleting pets when we don't know what could happen. :catfish: |
Hmm, alright. I think I'll try getting a tester site up and do testing before releasing this on my site then. Those are some valid points made and could definitely turn into an issue if anyone were to abuse it.
EDIT: Alternatively, perhaps I can instead just make a page just like the pound and allow users to "release" their pets there, clearing any family data, and every few days the pets can be automatically (or manually) deleted thereafter. Pets on this page wouldn't be allowed for readoption. |
Alright so coming back to this. :P The code that ignores the error when an offspring doesn't exist is working great. Is there a way to have this also work if mothers and fathers were deleted as well? Whenever a mother or father is deleted, the babies get an error on their pages saying so. I tried to look in the code and figure it out myself but not getting anywhere. ><
|
I'll work on this when I get back from... work. *sigh*
edit: See later post for solution. |
Ahh Kyttias thank you! <3 It's no rush. I just happened to fiddle with it more and noticed that problem unfortunately.
I'm not using grandparents on my site at the moment so it wouldn't be a problem for me luckily, though others following this might find that useful. Not sure if I ever will display grandparents, so I'm mainly just focused on ignoring the error for parents as well. I also still need to do some testing to make sure there aren't any major errors with adding the deleting part. Plan on getting to that soon! |
The best thing to do will be just to make a try/catch as we did before, actually, with the children. Telling you where to make edits is a little harder, so, from the thread where the family tree was made, post number four, the first bit of code. That. Where-ever you put that, no matter how you designed it within, it'll be easiest just to put this above it, so we have both:
PHP Code:
So why do we need this code first? Basically, the code from the post I referred to is checking whether or not the current adoptable has a parent held in its database column (it's checking for NULL, so, so long as something there, it should try to render something). Well, we're backing up a step. First we're checking if the field is not NULL - okay, something is there? Okay, but does that pet actually exist? We check that. And if doesn't exist? We inform the code it is NULL, therefore stopping the original code. If something about this goes strangely, go ahead and send me the file via PM. :meow: |
You really are the best! <3 It works, at least for mothers and fathers. Someone else would need to test grandparents. :P Thank yoouuu!
|
Still haven't tested if deleting adopts causes any errors, but did wanna say I instead just basically duplicated the pound and made it into the "Wild". Players can't adopt these pets but they can view them and their profiles. So far it seems to be working okay and I may just stick to this. I need to trim and clean up a lot of the code though.
Also working on getting pets to display randomly and limited to only maybe 50 or so at a time. Would be horrible to visit a page with 500+ pets there. :P I'm also not sure if I wanna delete pets manually every so often (for tidyness), or just keep them there. Probably just gonna get my users to vote on this. http://i.imgur.com/UWtIdwF.png |
All times are GMT -5. The time now is 10:28 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.