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 05-04-2017, 01:22 PM
kristhasirah's Avatar
kristhasirah kristhasirah is offline
Member
 
Join Date: Jan 2010
Location: In middle of the nothingness
Posts: 196
Gender: Female
Credits: 28,035
kristhasirah
Default Unique names =)

this is just a copy/paste edit code of the create a shop code but it works for that ^^
at the very end of your myadopts.php page before the } ?> paste this:
PHP Code:
             private function dataValidate(){
        
$mysidia Registry::get("mysidia");
        if(!
$mysidia->input->post("adoptname")) throw new BlankFieldException("You did not enter in a name for this creature. Please <a href='/myadopts/rename/{$this->adopt->getAdoptID()}'>go back</a> and try again.");        
        
$name $mysidia->db->select("owned_adoptables", array(), "name = '{$mysidia->input->post("adoptname")}'")->fetchObject();
        if(
$this->action == "rename" and is_object($name)) throw new DuplicateIDException("A creature with the same name already exists, please <a href='/myadopts/rename/{$this->adopt->getAdoptID()}'>go back</a> and change its name.");
        return 
TRUE;
    } 
then look for public function rename and add:
PHP Code:
            $this->dataValidate(); 
after the
PHP Code:
        if($mysidia->input->post("submit")){ 
this don't affect the named adopts in the main adopt page, unless you add it there... i haven't tested this code in there... im using kittyas code to name the adopt after the creature is adopted so when the user gives the adopt a name is redirected to the rename page in the myadopts. so i don't need to add it to the main page..
This also throws an error, when the user tries to remove the name of the adopt and leave it blank, so no more blank names ^^
If you only want the blank name error then just remove or comment out the $name and the second if($this->action lines.
again if i dint make sense this is how the code should look:
PHP Code:
             private function dataValidate(){
        
$mysidia Registry::get("mysidia");
        if(!
$mysidia->input->post("adoptname")) throw new BlankFieldException("You did not enter in a name for this creature. Please <a href='/myadopts/rename/{$this->adopt->getAdoptID()}'>go back</a> and try again.");        
        return 
TRUE;
    } 
hope someone finds this useful ^^

edit:
ok here is the code for the adopt.php page:
PHP Code:
                 private function dataValidate(){
        
$mysidia Registry::get("mysidia");
        if(!
$mysidia->input->post("name")) throw new BlankFieldException("You did not enter in a name for this creature. Please go back and try again.");        
        
$name $mysidia->db->select("owned_adoptables", array(), "name = '{$mysidia->input->post("name")}'")->fetchObject();
        if(
$this->action == "index" and is_object($name)) throw new DuplicateIDException("A creature with the same name already exists, please go back and change its name.");
        return 
TRUE;
    } 
then in public function index and add:
PHP Code:
            $this->dataValidate(); 
after the
PHP Code:
        if($mysidia->input->post("submit")){ 
WARNING! this code is for an unedited adopt page! if you are using the random code i posted it will be kind of annoying to the users to have to return to the main page and see that the eggs have changed and they have lost the rare/ultrarare egg ^^ unless you know how to code something similar to dragon cave name box that tells you if the name is in use.
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 03:22 AM.

Currently Active Users: 434 (0 members and 434 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