Dinocanid
12-29-2016, 12:09 PM
I quickly made this last night as a way to add more depth to pets. Currently it's only for adopts, but it could be used for items as well.
-What this does-
This script adds a "bestiary" sort of page where users can find information on your adoptables, like so:
http://www.clipular.com/c/5634076130410496.png?k=tBs7A8hLJkCKzrst0VN1hOdylI4
It makes the use of public functions, so no need for a separate php file for every entry!
-Step 1-
Make a new file called encyclopedia.php and paste this inside:
<?php
class EncyclopediaController extends AppController{
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
}
public function species_name_here(){
$mysidia = Registry::get("mysidia");
}
}
?>
-Step 2-
Now go to your view folder and make a new file called encyclopediaview.php and paste this inside:
<?php
class EncyclopediaView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Encyclopedia");
$document->add(new Comment("<h2>Choose a species below</h2>"));
$document->add(new Comment("<a href='SITEURL/encyclopedia/species_name_here'>Species name</a>"));
}
public function species_name_here(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$species = "Species name here";
$topclicks = $mysidia->db->select("owned_adoptables", array("totalclicks"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadopt = $mysidia->db->select("owned_adoptables", array("name"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadoptowner = $mysidia->db->select("owned_adoptables", array("owner"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$count = $mysidia->db->select("owned_adoptables", array(), "Type='{$species}'")->rowCount();
$document->setTitle("<center>{$species}</center>");
$document->add(new Image("PetDirectImageLink"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Basic info</th>
</tr>
<tr>
<td><b>Species:</b> {$species} <br></br><b>Height:</b> height<br></br><b>Group:</b> group <br></br><b>Rarity:</b> rarity<br></br><b>Description:</b> pet description <br></br><b>Obtainable:</b> where users can find it<br></br</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Background</th>
</tr>
<tr>
<td>In depth description goes here. It can include origins, date created, etc.</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Statistics</th>
</tr>
<tr>
<td><b>Amount In-Game:</b> {$count}<br></br><b>Top {$species}:</b> {$topadopt} with {$topclicks} clicks. (Owned by {$topadoptowner})</td>
</tr>
</table>"));
$document->add(new Comment("<a href='SITEURL/encyclopedia'>Return to Encyclopedia</a>"));
}
-In Depth Explanation/ How This Works-
1. For SITEURL you post your full site url. For example, mine is located at http://adopttest.mysidiahost.com/encyclopedia
2. For PetDirectImageLink you get the image of your adoptable. This can easily be done by right clicking on an adoptable on your site and selecting "open image in new tab". Then copy the full url and paste it in.
3. This script is created to be used with custom tables! You can use the default tables as if you wish though.
4. For public function species_name_here, the name must be the same in both the base php file and view php file or else it won't work!
5. If you wish to add more entries, just copy and paste the same lines of code for each adoptable you want to add!
-Example Code-
If you require a reference to help you understand the script, here is a part of mine. (It includes my table css)
<?php
class EncyclopediaController extends AppController{
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
}
public function spaniel_flan(){
$mysidia = Registry::get("mysidia");
}
public function egg_cat(){
$mysidia = Registry::get("mysidia");
}
}
?>
(encyclopedia.php)
<style>
.myTable { width:600px; border-collapse:collapse; }
.myTable th { background-color:#543210;width:600px; padding:5px;border:5px solid #543210;color:#000;}
.myTable td { padding:5px;border:5px solid #543210;height:100px; }
</style>
<?php
class EncyclopediaView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Encyclopedia");
$document->add(new Comment("<h2>Choose a species below</h2>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/spaniel_flan'>Spaniel Flan</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/egg_cat'>Eggsotic Shorthair</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/hotdach'>Hotdach</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/ragamuffin'>Ragamuffin</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/black_forest_dog'>Black Forest Dog</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/chowchowder'>Chowchowder</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/apple_pom'>Apple pom</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/cranberry_tufted_deer'>Cranberry Tufted Deer</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/blue_raspberry_dragon'>Blue Raspberry Dragon</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/black_licorice_dragon'>Black Licorice Dragon</a>"));
}
public function spaniel_flan(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$species = "Spaniel Flan";
$topclicks = $mysidia->db->select("owned_adoptables", array("totalclicks"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadopt = $mysidia->db->select("owned_adoptables", array("name"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadoptowner = $mysidia->db->select("owned_adoptables", array("owner"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$count = $mysidia->db->select("owned_adoptables", array(), "Type='{$species}'")->rowCount();
$document->setTitle("<center>{$species}</center>");
$document->add(new Image("http://adopttest.mysidiahost.com/picuploads/png/SF.png"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Basic info</th>
</tr>
<tr>
<td><b>Species:</b> {$species} <br></br><b>Height:</b> 7cm<br></br><b>Group:</b> Canine <br></br><b>Rarity:</b> Common<br></br><b>Disposition:</b> Good<br></br><b>Description:</b> Cool to the touch and feels like jelly. <br></br><b>Obtainable:</b> Adoption Center<br></br</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Background</th>
</tr>
<tr>
<td>The very first bab created. A popular choice among new breeders for their playful personality and friendly smile. They're rather high maintenance pets, since their sticky coat attracts all sorts of dirt, dust, and residue.</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Statistics</th>
</tr>
<tr>
<td><b>Amount In-Game:</b> {$count}<br></br><b>Top {$species}:</b> {$topadopt} with {$topclicks} clicks. (Owned by {$topadoptowner})</td>
</tr>
</table>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia'>Return to Encyclopedia</a>"));
}
public function egg_cat(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$species = "Eggsotic Shorthair";
$topclicks = $mysidia->db->select("owned_adoptables", array("totalclicks"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadopt = $mysidia->db->select("owned_adoptables", array("name"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadoptowner = $mysidia->db->select("owned_adoptables", array("owner"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$count = $mysidia->db->select("owned_adoptables", array(), "Type='{$species}'")->rowCount();
$document->setTitle("<center>{$species}</center>");
$document->add(new Image("http://adopttest.mysidiahost.com/picuploads/png/1bb920fa3db230cc12df5725d64410e5.png"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Basic info</th>
</tr>
<tr>
<td><b>Species:</b> {$species} <br></br><b>Height:</b> 4cm<br></br><b>Group:</b> Feline <br></br><b>Rarity:</b> Common<br></br><b>Disposition:</b> Good<br></br><b>Description:</b> Likes to sizzle. <br></br><b>Obtainable:</b> Adoption Center<br></br</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Background</th>
</tr>
<tr>
<td>One of the first babs created. They only have front paws, which limits mobility, but that doesn't stop them from crawling around when unsupervised, so expect to find them in odd places if left alone for a while. This little critter enjoys the company of their owner, and is easy to care for.</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Statistics</th>
</tr>
<tr>
<td><b>Amount In-Game:</b> {$count}<br></br><b>Top {$species}:</b> {$topadopt} with {$topclicks} clicks. (Owned by {$topadoptowner})</td>
</tr>
</table>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia'>Return to Encyclopedia</a>"));
}
}
?>
(encyclopediaview.php)
And this is an example of how it works:
http://i.imgur.com/cthUO0C.gif
-What this does-
This script adds a "bestiary" sort of page where users can find information on your adoptables, like so:
http://www.clipular.com/c/5634076130410496.png?k=tBs7A8hLJkCKzrst0VN1hOdylI4
It makes the use of public functions, so no need for a separate php file for every entry!
-Step 1-
Make a new file called encyclopedia.php and paste this inside:
<?php
class EncyclopediaController extends AppController{
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
}
public function species_name_here(){
$mysidia = Registry::get("mysidia");
}
}
?>
-Step 2-
Now go to your view folder and make a new file called encyclopediaview.php and paste this inside:
<?php
class EncyclopediaView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Encyclopedia");
$document->add(new Comment("<h2>Choose a species below</h2>"));
$document->add(new Comment("<a href='SITEURL/encyclopedia/species_name_here'>Species name</a>"));
}
public function species_name_here(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$species = "Species name here";
$topclicks = $mysidia->db->select("owned_adoptables", array("totalclicks"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadopt = $mysidia->db->select("owned_adoptables", array("name"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadoptowner = $mysidia->db->select("owned_adoptables", array("owner"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$count = $mysidia->db->select("owned_adoptables", array(), "Type='{$species}'")->rowCount();
$document->setTitle("<center>{$species}</center>");
$document->add(new Image("PetDirectImageLink"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Basic info</th>
</tr>
<tr>
<td><b>Species:</b> {$species} <br></br><b>Height:</b> height<br></br><b>Group:</b> group <br></br><b>Rarity:</b> rarity<br></br><b>Description:</b> pet description <br></br><b>Obtainable:</b> where users can find it<br></br</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Background</th>
</tr>
<tr>
<td>In depth description goes here. It can include origins, date created, etc.</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Statistics</th>
</tr>
<tr>
<td><b>Amount In-Game:</b> {$count}<br></br><b>Top {$species}:</b> {$topadopt} with {$topclicks} clicks. (Owned by {$topadoptowner})</td>
</tr>
</table>"));
$document->add(new Comment("<a href='SITEURL/encyclopedia'>Return to Encyclopedia</a>"));
}
-In Depth Explanation/ How This Works-
1. For SITEURL you post your full site url. For example, mine is located at http://adopttest.mysidiahost.com/encyclopedia
2. For PetDirectImageLink you get the image of your adoptable. This can easily be done by right clicking on an adoptable on your site and selecting "open image in new tab". Then copy the full url and paste it in.
3. This script is created to be used with custom tables! You can use the default tables as if you wish though.
4. For public function species_name_here, the name must be the same in both the base php file and view php file or else it won't work!
5. If you wish to add more entries, just copy and paste the same lines of code for each adoptable you want to add!
-Example Code-
If you require a reference to help you understand the script, here is a part of mine. (It includes my table css)
<?php
class EncyclopediaController extends AppController{
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
}
public function spaniel_flan(){
$mysidia = Registry::get("mysidia");
}
public function egg_cat(){
$mysidia = Registry::get("mysidia");
}
}
?>
(encyclopedia.php)
<style>
.myTable { width:600px; border-collapse:collapse; }
.myTable th { background-color:#543210;width:600px; padding:5px;border:5px solid #543210;color:#000;}
.myTable td { padding:5px;border:5px solid #543210;height:100px; }
</style>
<?php
class EncyclopediaView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Encyclopedia");
$document->add(new Comment("<h2>Choose a species below</h2>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/spaniel_flan'>Spaniel Flan</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/egg_cat'>Eggsotic Shorthair</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/hotdach'>Hotdach</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/ragamuffin'>Ragamuffin</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/black_forest_dog'>Black Forest Dog</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/chowchowder'>Chowchowder</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/apple_pom'>Apple pom</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/cranberry_tufted_deer'>Cranberry Tufted Deer</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/blue_raspberry_dragon'>Blue Raspberry Dragon</a>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia/black_licorice_dragon'>Black Licorice Dragon</a>"));
}
public function spaniel_flan(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$species = "Spaniel Flan";
$topclicks = $mysidia->db->select("owned_adoptables", array("totalclicks"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadopt = $mysidia->db->select("owned_adoptables", array("name"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadoptowner = $mysidia->db->select("owned_adoptables", array("owner"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$count = $mysidia->db->select("owned_adoptables", array(), "Type='{$species}'")->rowCount();
$document->setTitle("<center>{$species}</center>");
$document->add(new Image("http://adopttest.mysidiahost.com/picuploads/png/SF.png"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Basic info</th>
</tr>
<tr>
<td><b>Species:</b> {$species} <br></br><b>Height:</b> 7cm<br></br><b>Group:</b> Canine <br></br><b>Rarity:</b> Common<br></br><b>Disposition:</b> Good<br></br><b>Description:</b> Cool to the touch and feels like jelly. <br></br><b>Obtainable:</b> Adoption Center<br></br</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Background</th>
</tr>
<tr>
<td>The very first bab created. A popular choice among new breeders for their playful personality and friendly smile. They're rather high maintenance pets, since their sticky coat attracts all sorts of dirt, dust, and residue.</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Statistics</th>
</tr>
<tr>
<td><b>Amount In-Game:</b> {$count}<br></br><b>Top {$species}:</b> {$topadopt} with {$topclicks} clicks. (Owned by {$topadoptowner})</td>
</tr>
</table>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia'>Return to Encyclopedia</a>"));
}
public function egg_cat(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$species = "Eggsotic Shorthair";
$topclicks = $mysidia->db->select("owned_adoptables", array("totalclicks"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadopt = $mysidia->db->select("owned_adoptables", array("name"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$topadoptowner = $mysidia->db->select("owned_adoptables", array("owner"), "Type='{$species}'", "1 ORDER BY totalclicks DESC LIMIT 1")->fetchColumn();
$count = $mysidia->db->select("owned_adoptables", array(), "Type='{$species}'")->rowCount();
$document->setTitle("<center>{$species}</center>");
$document->add(new Image("http://adopttest.mysidiahost.com/picuploads/png/1bb920fa3db230cc12df5725d64410e5.png"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Basic info</th>
</tr>
<tr>
<td><b>Species:</b> {$species} <br></br><b>Height:</b> 4cm<br></br><b>Group:</b> Feline <br></br><b>Rarity:</b> Common<br></br><b>Disposition:</b> Good<br></br><b>Description:</b> Likes to sizzle. <br></br><b>Obtainable:</b> Adoption Center<br></br</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Background</th>
</tr>
<tr>
<td>One of the first babs created. They only have front paws, which limits mobility, but that doesn't stop them from crawling around when unsupervised, so expect to find them in odd places if left alone for a while. This little critter enjoys the company of their owner, and is easy to care for.</td>
</tr>
</table>"));
$document->add(new Comment("<center><table class='myTable'>
<tr>
<th>Statistics</th>
</tr>
<tr>
<td><b>Amount In-Game:</b> {$count}<br></br><b>Top {$species}:</b> {$topadopt} with {$topclicks} clicks. (Owned by {$topadoptowner})</td>
</tr>
</table>"));
$document->add(new Comment("<a href='http://adopttest.mysidiahost.com/encyclopedia'>Return to Encyclopedia</a>"));
}
}
?>
(encyclopediaview.php)
And this is an example of how it works:
http://i.imgur.com/cthUO0C.gif