The following is a mod that extends the functionality of levelup.php to create a profile for each pet, viewable by other users.
This mod is heavily based on code provided by Kyttias
To get started, open levelup.php and change
to
, t
at the bottom paste the following:
Next, open levelupview.php, found in your views folder.
again, scroll down to the bottom and paste:
This essentially creates a new page under levelup, yoursite.com/levelup/publicprofile/(adoptable ID number), but there isn't anything that links to it yet! We'll fix that next. Open myadoptsview.php and under the line reading
,
add
.
Now you can view your pets' profiles. But what about other people? If you want them to see the pet's info, go back to levelup.php and replace
with
Finally, open class_adoptablehelper.php, in your classes folder, and replace
with
And you're done~!
This mod is heavily based on code provided by Kyttias
To get started, open levelup.php and change
PHP:
if($mysidia->input->action() == "click" or $mysidia->input->action() == "siggy" $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
PHP:
if($mysidia->input->action() == "click" or $mysidia->input->action() == "siggy" or $mysidia->input->action() == "publicprofile") $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
at the bottom paste the following:
PHP:
public function publicprofile(){
#begin profile code
$mysidia = Registry::get("mysidia");
$date = new DateTime;
$this->setField("adopt", $this->adopt);
$ip = secure($_SERVER['REMOTE_ADDR']);
Next, open levelupview.php, found in your views folder.
again, scroll down to the bottom and paste:
PHP:
public function publicprofile(){
$mysidia = Registry::get("mysidia");
$adopt = $this->getField("adopt");
$adoptcurrentlevel = $adopt->currentlevel;
$document = $this->document;
$document->setTitle("Viewing {$adopt->getName()}'s profile");
if($adopt->hasNextLevel()){
$nextLevel = $adopt->getNextLevel();
#$requiredClicks = $nextLevel->getRequiredClicks();
$thisisauniqueid = new OwnedAdoptable($adopt->getAdoptID());
$gender_lookup = $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
if ($gender_lookup == "m") { $gender = "Male"; $pronoun = "him"; } else { $gender = "Female"; $pronoun = "her"; }
$alternates_lookup = $mysidia->db->select("owned_adoptables", array("usealternates"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
if ($mysidia->user->username == $adopt->getOwner()){ $manage_btn = "<a class='btn btn-sm btn-info' href='../../myadopts/manage/{$adopt->getAdoptID()}'><i class='fa fa-gear'></i> Manage</a>"; } else { $manage_btn = ""; }
if($adopt->hasNextLevel()){
$level = $adopt->getNextLevel();
$levelupClicks = $adopt->getLevelupClicks();
$document->add(new Comment("(LVL ".$level->getLevel()." in ".$levelupClicks." more EXP)"));
}
else { $document->add(new Comment("(MAX)")); }
if($adopt->getTradeStatus() == "fortrade") { $tradestatus = "<b>For Trade</b>"; }
else { $tradestatus = "<b>Not For Trade</b>"; }
// If you've already seen the pet today:
if ($adopt->hasVoter($mysidia->user, $date)){
$document->add(new Comment("<a class='btn btn-sm btn-info disabled' href='../../levelup/click/{$adopt->getAdoptID()}'><i class='fa fa-paw'></i> Already Fed</a>"));
}
// If you haven't seen the pet today:
else {
$document->add(new Comment("<a class='btn btn-sm btn-info' href='../../levelup/click/{$adopt->getAdoptID()}'><i class='fa fa-paw'></i> Feed</a>"));
};
}
$document->add(new Comment("{$manage_btn}
<br> <br>
<img src='{$thisisauniqueid->getImage()}'><br>"));
$adoptabletype = $mysidia->db->select("adoptables", array(), "type='{$adopt->getType()}'")->fetchObject();
$diet = $adoptabletype->Diet;
$level = $adopt->getCurrentLevel();
$document->add(new Comment("<ul>
<li>Lives With: <a href='/profile/view/{$adopt->getOwner()}'>{$adopt->getOwner()}</a></li>
<li>Species: {$adopt->getType()}</li>
<li>Gender: {$gender}</li>
<li>LVL: {$adopt->getCurrentLevel()} {$toNext}</li>
<li>Total EXP: {$adopt->getTotalClicks()}</li>
<li>Trade Status: {$tradestatus}</li>
"));
}
This essentially creates a new page under levelup, yoursite.com/levelup/publicprofile/(adoptable ID number), but there isn't anything that links to it yet! We'll fix that next. Open myadoptsview.php and under the line reading
PHP:
$document->add(new Link("levelup/click/{$aid}", " LevelUp {$name}", TRUE));
add
PHP:
$document->add(new Link("levelup/publicprofile/{$aid}", " View {$name}'s Profile", TRUE));
Now you can view your pets' profiles. But what about other people? If you want them to see the pet's info, go back to levelup.php and replace
PHP:
$message = ($mysidia->user instanceof Member)?"already_leveled_member":"already_leveled_guest";
PHP:
$message .= "You already clicked this adoptable today. Try again tomorrow. <br>
<a class='btn btn-sm btn-info' href='../../levelup/publicprofile/{$this->adopt->getAdoptID()}'><i class='fa fa-chevron-left'></i> Back to Profile</a>";
Finally, open class_adoptablehelper.php, in your classes folder, and replace
PHP:
public function getLevelupLink(OwnedAdoptable $adopt){
return new Link("levelup/click/{$adopt->getAdoptID()}", $adopt->getImage("gui"));
PHP:
public function getLevelupLink(OwnedAdoptable $adopt){
return new Link("levelup/publicprofile/{$adopt->getAdoptID()}", $adopt->getImage("gui"));
Last edited: