Mys 1.3.4 Know Gender of New Pets Before Naming

Forum
Last Post
Threads / Messages

Kyttias

Super Moderator
Super Mod
Joined
Jan 26, 2014
Messages
849
Points
18
Mysidian Dollar
58,199
This is what we'll be doing (more or less):
help_by_kyttias-d892m9i.gif


Basically we remove the option to name the pet on the first page, so now we'll name it from the confirmation screen - since the adoptable exists now, we can know its gender!

We'll be modifying two sections in adoptview.php -
First we'll replace the contents inside if($mysidia->input->post("submit")){ ... }.
It WAS this:
PHP:
if($mysidia->input->post("submit")){
		    $aid = $this->getField("aid")->getValue();
			$name = $this->getField("name")->getValue();
			$eggImage = $this->getField("eggImage")->getValue();
			$image = new Image($eggImage);
			$image->setLineBreak(TRUE);	
			
            $document->setTitle("{$name} adopted successfully");			
			$document->add($image);
			$document->addLangvar("Congratulations!  You just adopted {$name}.  You can now manage {$name} on the ");
			$document->add(new Link("myadopts", "Myadopts Page."));
			$document->add(new Comment(""));
			$document->add(new Link("myadopts/manage/{$aid}", "Click Here to Manage {$name}"));
			$document->add(new Comment(""));
			$document->add(new Link("myadopts/bbcode/{$aid}", "Click Here to get BBCodes/HTML Codes for {$name}"));
			$document->add(new Comment(""));
			$document->addLangvar("Be sure and");
			$document->add(new Link("levelup/{$aid}", "feed "));
			$document->addLangvar("{$name} with clicks so that they grow!");
		    return;
		}
We'll be changing the entire statement to:

PHP:
if($mysidia->input->post("submit")){
		    $aid = $this->getField("aid")->getValue();
			$name = $this->getField("name")->getValue();
			$gender_lookup = $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$aid}'")->fetchColumn();
			if ($gender_lookup == "m") { $gender = "boy"; $pronoun = "him"; }
			if ($gender_lookup == "f") { $gender = "girl"; $pronoun = "her"; } 
			$eggImage = $this->getField("eggImage")->getValue();
			$image = new Image($eggImage);
			$image->setLineBreak(TRUE);	

            $document->setTitle("{$name} adopted successfully!");			
			$document->add($image);
			$document->addLangvar("Congratulations! The {$name} you just recruited is a ");
			$document->add(new Comment("<b>{$gender}</b>. Would you like to name {$pronoun}? <br> (Valid names may only contain letters, numbers and spaces.)", FALSE));
		
			$nameForm = new FormBuilder("renameform", "/myadopts/rename/{$aid}", "post");
			$nameForm->buildTextField("adoptname")->buildButton("Name", "submit", "submit");
			$document->add($nameForm);	


			$document->add(new Comment("Or if you'd rather wait until later, you can ", FALSE));
			$document->add(new Link("myadopts/manage/{$aid}", "click here to manage your new {$name}!", TRUE));

			$document->addLangvar("Be sure to");
			$document->add(new Link("levelup/{$aid}", "visit "));
			$document->addLangvar("{$name} every day so that they grow!");
		    return;
		}

The last block of lines at the bottom looks like this:

PHP:
$adoptForm->add($adoptTable);		
		$adoptSubtitle = new Comment("Adopt");
		$adoptSubtitle->setHeading(3);
		$adoptForm->add($adoptSubtitle);
		$adoptForm->add(new Comment("Adoptable Name: ", FALSE));
		$adoptForm->add(new TextField("name"));
		$adoptForm->add(new Comment(""));
        $adoptForm->add(new Button("Adopt Me", "submit", "submit"));
        $document->add($adoptForm);

We're going to reduce it to just this:

PHP:
$adoptForm->add($adoptTable);			
        $adoptForm->add(new Button("Recruit", "submit", "submit"));
        $document->add($adoptForm);



Let me know if there are any issues/questions.

(* Yes, it is getting rid of the BBCode link, but since that can be found from the adopt's page, anyway, I didn't see it as a big deal? Naming is important. )
 
Last edited:
I like this a lot Kyttias, I think I may apply it to version 1.4.0 when I am ready to release it. After all, it will make no sense if you give your pet a female name only to realize it is male later on, and vice-versa. Good idea.
 
Just added this mod!

It's splendid ^_^ Thank you for sharing <3
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top