Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 10-21-2016, 05:37 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 63,595
Dinocanid is on a distinguished road
Default 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:
  Spoiler: What to add 
Name: petbio
Type: VARCHAR
Length/Values: 500
Default: NULL
Collation: latin1_swedish_ci
Check the box that says null

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:
public function changepetbio(){
        
$mysidia Registry::get("mysidia");        
        if(
$mysidia->input->post("submit")){
            
$poundsettings getpoundsettings();
            
$poundpet $mysidia->db->select("pounds", array(), "aid='{$this->adopt->getAdoptID()}'")->fetchObject();
            if(
$poundpet and $poundsettings->rename->active == "yes"){
                if(!empty(
$poundpet->firstowner) and $mysidia->user->username != $poundpet->firstowner){
                    
$this->setFlags("rename_error""rename_owner");
                    return;    
                }                
            }            
            
$this->adopt->setPetbio($mysidia->input->post("petbio"), "update");
        }
        
$this->setField("adopt"$this->adopt);        
    
$this->setField("image"$this->image);            
    } 
As you can probably see, I basically duplicated the rename function. Some of it can probably be cleaned up if you know how, but I don't.

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:
public $petbio
Once you do that, add these lines with all the other functions. It can be towards the bottom or something.
PHP Code:
public function getPetbio(){
        return 
$this->petbio;
    }
    public function 
setPetbio($petbio$assignMode ""){
        if(
$assignMode == Model::UPDATE$this->save("petbio"$petbio);
        
$this->petbio $petbio;
    } 
Step 3
Go to lang>lang_myadopts.php and add these lines:
PHP Code:
$lang['changebio'] = "Change the bio of ";
$lang['changebio_default'] = "This page allows you to change the bio of ";
$lang['changebio_details'] = ". To change this adoptable's bio, simply type it in the box below.";
$lang['changebio_error'] = "Cannot change";
$lang['changebio_owner'] = "The site admin has specified that only original owners can change their adoptables' bios.";  
$lang['changebio_success_title'] = "Bio Change Successful";
$lang['changebio_success'] = "You have successfully changed the bio of "
Displaying and Using
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:
$bio stripslashes($adopt->getPetbio()); 
Bio: {$bio
You can also use this if your profile code is structured differently from mine:
PHP Code:
$bio stripslashes($adopt->getPetbio()); 
$document->add(new Comment(Bio: {$bio})); 
Step 2
Add this code with all the other functions. You can put it towards the bottom to keep things organized:
PHP Code:
public function changepetbio(){
        
$mysidia Registry::get("mysidia");
        
$adopt $this->getField("adopt");        
        
$image $this->getField("image");        
        
$document $this->document;
        
        if(
$mysidia->input->post("submit")){
            
$document->setTitle($this->lang->changebio_success_title);
            
$document->add($image);
            
$message "<br>{$this->lang->changebio_success}{$adopt->getName()}
                        You can now manage 
{$mysidia->input->post("adoptname")} on the";
            
$document->addLangvar($message);
            
$document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}""My Adopts Page"));
            return;
        }
        
        
$document->setTitle($this->lang->changebio.$adopt->getName());
        
$document->add($image);
        
$document->addLangvar("<br />{$this->lang->changebio_default}{$adopt->getName()}{$this->lang->changebio_details}<br />");
        
        
$petbioForm = new FormBuilder("petbioform""""post");
        
$petbioForm->buildTextArea("petbio")->buildButton("Change Bio""submit""submit");
        
$document->add($petbioForm);           
    } 
Another rename replica . This huge chunk basically works like the rename function and takes the user to a page that lets them edit the bio.

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:
$document->add(new Link("myadopts/changepetbio/{$aid}"" Change {$name}'s Bio"TRUE)); 
The End
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 06:09 PM.
Reply With Quote
  #2  
Old 11-25-2016, 01:24 AM
Bexasaurus's Avatar
Bexasaurus Bexasaurus is offline
〈 ᴘʀᴀᴄᴛɪᴄɪɴɢ ᴀʀᴛɪsᴛ 〉
 
Join Date: Aug 2015
Posts: 101
Gender: Female
Credits: 7,444
Bexasaurus is on a distinguished road
Default

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?
__________________
TUMBLR * NOPE
I post art and stuff, feel free to follow/watch!
Reply With Quote
  #3  
Old 11-25-2016, 06:33 AM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 63,595
Dinocanid is on a distinguished road
Default

That's usually caused by it not being in the database. Did you try the setup through step 2 again?
__________________
Reply With Quote
  #4  
Old 11-25-2016, 11:17 AM
Bexasaurus's Avatar
Bexasaurus Bexasaurus is offline
〈 ᴘʀᴀᴄᴛɪᴄɪɴɢ ᴀʀᴛɪsᴛ 〉
 
Join Date: Aug 2015
Posts: 101
Gender: Female
Credits: 7,444
Bexasaurus is on a distinguished road
Default

I'll try to redo all of the steps. Maybe I just missed something and don't know it.
__________________
TUMBLR * NOPE
I post art and stuff, feel free to follow/watch!
Reply With Quote
  #5  
Old 11-25-2016, 01:51 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 63,595
Dinocanid is on a distinguished road
Default

If it still isn't working after you try again, I'll look at my code since it might be missing a part.
__________________
Reply With Quote
  #6  
Old 11-25-2016, 02:35 PM
Corsair's Avatar
Corsair Corsair is offline
Member
 
Join Date: Jan 2012
Posts: 128
Gender: Female
Credits: 11,222
Corsair is on a distinguished road
Default

I just tried it and it works for me. I noticed it has a "/" in words like "I've" and "pet's".
Reply With Quote
  #7  
Old 11-25-2016, 02:40 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 63,595
Dinocanid is on a distinguished road
Default

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 :/
__________________
Reply With Quote
  #8  
Old 11-25-2016, 02:55 PM
Bexasaurus's Avatar
Bexasaurus Bexasaurus is offline
〈 ᴘʀᴀᴄᴛɪᴄɪɴɢ ᴀʀᴛɪsᴛ 〉
 
Join Date: Aug 2015
Posts: 101
Gender: Female
Credits: 7,444
Bexasaurus is on a distinguished road
Default

Ah, so it's just me then. I'll redo the steps as soon as I fix the inventory issue I have going on.
__________________
TUMBLR * NOPE
I post art and stuff, feel free to follow/watch!
Reply With Quote
  #9  
Old 12-23-2016, 05:38 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 16,084
parayna is on a distinguished road
Default

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 05:46 PM.
Reply With Quote
  #10  
Old 12-23-2016, 06:06 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 63,595
Dinocanid is on a distinguished road
Default

Thanks for sharing! Those backslashes were so annoying lol.
__________________
Reply With Quote
Reply

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 04:36 AM.

Currently Active Users: 451 (0 members and 451 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


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