Mys 1.3.4 Encyclopedia

Forum
Last Post
Threads / Messages

Dinocanid

Member
Member
Joined
Aug 30, 2016
Messages
520
Points
18
Age
23
Location
Maryland, USA
Mysidian Dollar
43,334
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:
5634076130410496.png

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:
<?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:
<?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:
<?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)

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:
cthUO0C.gif
 
Last edited:
Ooh, very nice! Thank you! :D

I'm gonna attempt a few modifications actually.. I only have a few species on my site but loads of recolours planned and don't want all the recolours having their own name and instead just using the species name, so I might see if I can add individual pages for all pets....... not sure if it will work, but I can try XD

EDIT: Also! You don't need to have your site url anywhere in it. If you put:

$document->add(new Comment("<a href='../encyclopedia/vija'>Vija</a>")); [[Put your own species in, etc. XD]]

with the dots instead, it links you to the correct url. This is preferred as then if you ever update your url (maybe get paid hosting/domain name) you don't need to edit every single file ^_^
 
Last edited:
I've finally got around to adding this to my site, and I have a quick question! I want the links to be [my site]/archive/[species name]/[id of the species colouration] (the id wouldn't actually be the id if you get my drift... it would just be the number of the entry, and one I manually put in when I write the colours profile and stuff) So like 1 for the first colour I add to the site. (As I don't like each and every colour to have its own special name...) But also this way I can have special designs that DO have a name there instead of the number if it's special enough. But anyways lol...

I have been doing research into public, protected and private functions but I still can't really grasp how I'd do it.. (or if you'd use one of them)

I thought it was a protected function but if it is I'm not sure how I'd actually go about making that come after the species name part of the link... >.>

Sorry for the trouble ^_^''
 
I think subpages are one of my weaknesses lol. I've been looking all over google on how to do it, but I can't find any information on it even though it's extremely common. I found nesting functions, but I can't get it to work with the mysidia script.
 
Yeah that's where I hit a snag too >.> I was trying to find perhaps examples within the script itself but can't, no matter which file I look in XD I might just be missing it, though... >.>
 
I put this on Beau's Aviary and it doesn't seem to be working when I click on a pet. It comes up with this.

  Spoiler: Error 
Class Beausaviary.mysidiahost.comController does not exist
 
Looks like you added something wrong. Near the top of encyclopedia.php, it should say "Class Encyclopedia" or something. (Same for the view file, but it would be Class EncyclopediaView) From the looks of it, you have a url there instead.
 
Looks like you added something wrong. Near the top of encyclopedia.php, it should say "Class Encyclopedia" or something. (Same for the view file, but it would be Class EncyclopediaView) From the looks of it, you have a url there instead.

Nope, it's fine. No url. For the birds ID's for the URL I put beausaviary.mysidiahost.com/encyclopedia/green_budgie (and the id of the bird changes for each bird). Did I do that part wrong?
 
I deleted the beausaviary.mysidiahost.com from the URL's and now the error doesn't appear but it just shows this:

  Spoiler: Invalid 
An error has occurred.
You specified an invalid action that cannot be completed.
 
Can you show what your view file looks like?


  Spoiler: encyclopediaview.php 
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='/encyclopedia/green_budgie'>Green Budgie February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/blue_budgie'>Blue Budgie February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/harry'>Harry February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/pied_budgie'>Pied Budgie February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/beau'>Beau February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/half_sider'>Half Sider Budgie February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/dark_grey_yellowface'>Dark Grey Yellowface Cockatiel February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/light_grey_yellowface'>Light Grey Yellowface Cockatiel February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/blue_grey_yellowface'>Blue Grey Yellowface Cockatiel February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/grey_with_white_wing'>Grey with White Wing Cockatiel February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/white_and_grey'>White and Grey Cockatiel February/March 2018</a>"));
        $document->add(new Comment("<a href='/encyclopedia/lutino'>Lutino Cockatiel February/March 2018</a>"));
    }
    
    public function green_budgie(){
    $mysidia = Registry::get("mysidia"); 
    $document = $this->document;
    $species = "Green Budgie";
    $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://ibb.co/js7YrH"));
    $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> 20cm<br></br><b>Group:</b> Budgie <br></br><b>Rarity:</b> Very Common<br></br><b>Disposition:</b> Good<br></br><b>Description:</b> A lovely, simple green budgie with extra fluff. <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 green budgie is based on it's natural colour, but the most important thing is that it is super fluffy.</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://beausaviary.mysidiahost.com/encyclopedia'>Return to Encyclopedia</a>"));
    }

 public function blue_budgie(){
    $mysidia = Registry::get("mysidia"); 
    $document = $this->document;
    $species = "Blue Budgie";
    $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://ibb.co/gvRhkc"));
    $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> 20cm<br></br><b>Group:</b> Budgie <br></br><b>Rarity:</b> Common<br></br><b>Disposition:</b> Good<br></br><b>Description:</b> Fred. Fred who? Fred who is Freda of course! <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 blue budgie is summed up in 2 words. Fred. Freda.</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://beausaviary.mysidiahost.com/encyclopedia'>Return to Encyclopedia</a>"));
    }
}
?>
 
Well the view file looks fine. Did you make sure to add functions to encyclopedia.php too?

Sorry what does that mean?! I am rubbish at all this coding stuff. This is what is inside the encyclopedia.php file:
  Spoiler: Code 
PHP:
<?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");   
        }
}
?>

Also, the font I chose isn't showing up on the theme :(
 
Last edited:
In the OP, it mentions that you need to add another public function to the encyclopedia.php too. Like this:
PHP:
  public function green_budgie(){ 
                $mysidia = Registry::get("mysidia");    
        }
"Species_name_here" is meant to be replaced with the ones you make.
The font isn't loading because I forget to send you the .ttf file. I'll go find it and edit it into this post as an attachment.
 
In the OP, it mentions that you need to add another public function to the encyclopedia.php too. Like this:
PHP:
  public function green_budgie(){ 
                $mysidia = Registry::get("mysidia");    
        }
The font isn't loading because I forget to send you the .ttf file. I'll go find it and edit it into this post as an attachment.

Thank you :)
 
In the OP, it mentions that you need to add another public function to the encyclopedia.php too. Like this:
PHP:
  public function green_budgie(){ 
                $mysidia = Registry::get("mysidia");    
        }
"Species_name_here" is meant to be replaced with the ones you make.
The font isn't loading because I forget to send you the .ttf file. I'll go find it and edit it into this post as an attachment.

I have it working now but for some reason it the statistics are wrong?
 
Last edited:
I got the file for you, just unzip it and upload it to the public_html folder. You may need to "ctrl+shift+r" to see the font.

For the statistics, that weird. Is "$species" exactly the same as the species name? I noticed that it's called "budgie" in the adopt shop, but you have it as blue/green/pied budgie in the encyclopedia.

(Also as a side note, it looks like you need to fix the links for your dropdown menus. For example, visiting the staff page and then clicking on the news will take you to an invalid page. To know how to fix it, there's a nice guide here: link)
 

Attachments

  • cutie-patootie-skinny.zip
    22.4 KB · Views: 4
I got the file for you, just unzip it and upload it to the public_html folder. You may need to "ctrl+shift+r" to see the font.

For the statistics, that weird. Is "$species" exactly the same as the species name? I noticed that it's called "budgie" in the adopt shop, but you have it as blue/green/pied budgie in the encyclopedia.

(Also as a side note, it looks like you need to fix the links for your dropdown menus. For example, visiting the staff page and then clicking on the news will take you to an invalid page. To know how to fix it, there's a nice guide here: link)

Oh yeah. It do alternative images though so thats why I do them seperatly.
 

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

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

Latest Threads

Latest Posts

Top