#1
|
||||
|
||||
Pet biographies!
This tutorial allows you to add biographies to your adopts. Let me know if you get any errors since I worked on this on and off and I might have forgotten to include a line of code somewhere.
Setup This is the stuff you need to do in phpMyAdmin before you go edit anything else. I'm sure this tutorial won't work otherwise. Find adopts_owned_adoptables and add 1 column under the structure tab with this info: You can change the length to whatever you want the max number of characters allowed in an adoptable's bio to be. I put 500 since that seems reasonable. Foundation Now for the bulk of this tutorial: Editing. This part is for getting the under-the-hood stuff for the bio working so it actually saves after you type it. Let's work from the outside in. Step 1 Go to myadopts.php and add this to it: PHP Code:
Step 2 Go to classes>class_ownedadoptable.php and add this with all the other protected and public stuff (All that yellow stuff between "class OwnedAdoptable" and "public function_construct") PHP Code:
PHP Code:
Go to lang>lang_myadopts.php and add these lines: PHP Code:
We're halfway there, wow! This part is for adding the text areas, buttons, and links that will allow users to actually add bios to their adoptables; as well as displaying it on the adoptable's profile. Step 1 Go to view>myadoptsview. After we're done, you can use the following line to display the bio wherever you want on a pet's profile. You can go ahead and add it now if you want so you can see it right after we finish. PHP Code:
PHP Code:
Add this code with all the other functions. You can put it towards the bottom to keep things organized: PHP Code:
Step 3 Done? Good, now just scroll back up and add this with all the other links on your adoptable's profile. (Along with rename, trade status, freeze, etc.) PHP Code:
Aaand...you're done! To test this, go to your pet's profile and click on the new link we added. This should take you to a screen where you can type in whatever you want for the bio. Once you hit the "Change Bio" button, it takes you back to the profile with your pet's new and shiny biography. Last edited by Dinocanid; 12-23-2016 at 07:09 PM. |
#2
|
||||
|
||||
I'm receiving the following error: Database error 1054 - Unknown column 'petbio' in 'field list'
This is after I click on update for the pet's bio. How can I fix this? |
#3
|
||||
|
||||
That's usually caused by it not being in the database. Did you try the setup through step 2 again?
__________________
|
#5
|
||||
|
||||
If it still isn't working after you try again, I'll look at my code since it might be missing a part.
__________________
|
#6
|
||||
|
||||
I just tried it and it works for me. I noticed it has a "/" in words like "I've" and "pet's".
|
#7
|
||||
|
||||
Mysidia has a problem with apostrophes in text, so it will add backslashes wherever they're used. The only way to get rid of them is to go to the bio in phpMyAdmin and manually remove the \'s, or avoid using apostrophes. I wish there was a way to prevent it though, they pop up everywhere on my site since I use them a lot :/
__________________
|
#9
|
||||
|
||||
Dinocanid, you can use a stripslashes command to remove backslashes but I'm not too sure where you'd place them in yours XD I'm gonna have a go though, and will share if I get it..
EDIT: Done! This isn't too elegant.. and I have sooo many places to put it >.> But it works! Where you have your profile (bio, I suppose) placed you need to include this somewhere: $bio = stripslashes($adopt->getPetbio()); That's what I have on my 'manage adopt' page, and it works! (I am using Kyttias' profile page method of displaying stuff so that might make it work? I'm not sure.) Basically place that where you have biographies displayed :) Oh, and remember to put {$bio} (or just $bio) instead of the full string, to those who might be confused :) Last edited by parayna; 12-23-2016 at 06:46 PM. |
#10
|
||||
|
||||
Thanks for sharing! Those backslashes were so annoying lol.
__________________
|
|
|
What's New? |
What's Hot? |
What's Popular? |