@NobodysHero
So you own MystFell? Beautiful art! I think I submitted the form put up on VPL, but I'm not sure haha
---------
Alright. This is a very manual version. I didn't do the "active" column version because I'm not sure what you will use this for and that way would be restricting it too much. This way, you can put a linked image in whatever page to make people obtain an adoptable - fun for treasure hunts?
Checking your database for the IDs
Since you will need to get the IDs you want for the adoptable, you will need to go check your database (I haven't checked the admincp to see if they are shown there because mine is currently under changes, sorry).
1) Use phpMyAdmin or similar from your control panel to access your database.
2) Once you are there, choose the database you use for your site (from the left side or by going to "Databases" at the top).
3) Then, choose the table something_adoptables (default is adopts_adoptables)
4) Look at the column id, these will be the numbers you will use. Check the names and images to see if it's the species you want
Image: http://i.imgur.com/ePST02Y.png
Putting the linked image up
Choose which page you want this to appear and link an image to /get/id/ID_NUMBER. This ID_NUMBER should be the same as one of your existing species in the database (see above).
To add it to pages like yoursite.com/
adopt, go to inside the view folder and edit the file
adoptview.php. Search the index() function and:
PHP Code:
public function index(){
//you will find something like this in this function:
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("News");//I chose a page I have called News
//put this anywhere after the title. Edit the ID to your liking, change the image link, add more images, etc.
$document->add(new Comment("<a href='/get/id/1'><img src='http://i.imgur.com/Bjzw7CM.gif'></a>"));
....
}
You can add more $document->add(new Comment(""));
You can also write HTML code inside the quotation marks " ", so feel free to do things like this:
PHP Code:
$document->add(new Comment("
<b>ADOPT ME:</b>
<br><br>
<a href='/get/id/1'><img src='http://i.imgur.com/Bjzw7CM.gif'></a><br>
<a href='/get/id/7'><img src='another_image.png'></a>
"));
Be careful to use ' ' instead of " " for the links and image links!
Do this: <img src=
'link.png
'>
Not this: <img src=
"link.png
">
The double quotation for the links might interfere with the previous marks and make your page throw errors! Always use the single quotation ones inside Comments("") to avoid mistakes!
Building the GET page!
Alright, clicking the image will take you to your index probably. We have to create the page that will take care of adopting.
Note:
If your link is yoursite.com/
get/
id/ID_NUMBER then your files need to be
get.php and
getview.php and both need an index() function and an
id() function.
If your link is yoursite.com/
capture/
get/ID_NUMBER then your files need to be
capture.php and
captureview.php and both need an index() function and a
get() function.
Etc... Just substitute the "get" word and the "id" word used for this explanation
For this example, my link is yoursite.com/get/id/ID_NUMBER
Create a file named get.php with these contents:
PHP Code:
<?php
use Resource\Native\Integer;
use Resource\Native\String;
class GetController extends AppController{
private $id;
public function __construct(){
parent::__construct("member");
$mysidia = Registry::get("mysidia");
if($mysidia->usergroup->getpermission("canadopt") != "yes"){
throw new NoPermissionException("permission");
}
}
public function index(){
//don't let people access yoursite.com/get
throw new InvalidActionException("global_action");
}
//yoursite.com/get/id
public function id(){
$mysidia = Registry::get("mysidia");
//get ID_NUMBER
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$parts = Explode('/', $pageURL);
$id = $parts[count($parts) - 1];
if(!$id) throw new InvalidIDException("global_id");
//---------- Edit here
/* In this part, we check if the ID is actually part of the IDs available to adopt!
* If you want adoptable 1 and 7 to be available through get/id/number, you gotta add
* 1 and 7 to the array
*/
$id_array = [1,7];//add your OK numbers here
$count = count($id_array);
$found = false;
for($i = 0; $i < $count; $i++)
{
//if ID is inside the array, then it's OK
if($id == $id_array[$i]){
$found = true;
break;
}
}
//the ID wasnt found inside the array, throw error
if(!$found)
throw new NoPermissionException("This adoptable is not available through this method.");
//----------
//after checking:
$this->access = "member";
$this->handleAccess();
//get adoptable information
$adopt = new Adoptable($id);
$conditions = $adopt->getConditions();
if(!$conditions->checkConditions()) throw new NoPermissionException("condition");
$name = $adopt->getType();
$alts = $adopt->getAltStatus();
$code = $adopt->getCode();
$gender = $adopt->getGender();
//insert into database
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $name, "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $gender, "offsprings" => 0, "lastbred" => 0));
//get its info
$aid = $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
$this->setField("aid", new Integer($aid));
$this->setField("name", new String($name));
$this->setField("eggImage", new String($adopt->getEggImage()));
}
}
?>
Search where it says "Edit here" in the file above, read the instructions and edit the array how you want it.
Create a file named getview.php inside the view folder with these contents:
PHP Code:
<?php
class GetView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("Adopt a pet");
}
public function id(){
$document = $this->document;
$document->setTitle("Adopt a pet");
$aid = $this->getField("aid")->getValue();
$name = $this->getField("name")->getValue();
$eggImage = $this->getField("eggImage")->getValue();
//display information
$image = new Image($eggImage);
$image->setLineBreak(TRUE);
$document->setTitle("Catching {$id} ");
$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!");
}
}
?>
So now visiting yoursite.com/get/id/1 should add an adoptable to your account (if the number 1 is in your id_array)
I might have forgotten something. If you notice an error, please tell me