I am making an adoptable website similar to Dragon cave or silvadopts. My website can be viewed at simpleadopts.x10.mx
If anyone has seen on both Dragon cave and silvadopts, they have a special adoption system. It displays a set image, and when you click it, it leads to a link which gives the user an adoptable. For a while I’ve been trying to figure this out. While looking online however, I found this code [php]<?php
// Random Image With Link
// Blog Tycoon
// http://getbutterfly.com/
//
// Usage:
//
// Save this file as ads.php and use the include function to call it inside your web site
function display_random_img($array) {
$key = rand(0 , count($array) -1);
$link_url = $array[$key][‘url’];
$alt_tag = $array[$key][‘alt’];
$random_img_url = $array[$key][‘img_url’];
list($img_width, $img_height) = getimagesize($random_img_url);
return “<a href=”$link_url"><img src="$random_img_url" width="$img_width" height="$img_height" alt="$alt_tag" title="$title" />";
}
// Edit the following values accordingly
$ads_array = array(
array(
‘url’ => ‘http://www.google.com/’,
‘alt’ => ‘Beach wolf’,
‘img_url’ => ‘http://i297.photobucket.com/albums/mm215/superdude44/sampleegg_zps42455e42.png’
),
array(
‘url’ => ‘http://www.yahoo.com/’,
‘alt’ => ‘Summer wolf’,
‘img_url’ => ‘http://i297.photobucket.com/albums/mm215/superdude44/sampleegg_zps42455e42.png’
),
array(
‘url’ => ‘http://www.msn.com/’,
‘alt’ => ‘Snow Leopard’,
‘img_url’ => ‘http://i297.photobucket.com/albums/mm215/superdude44/sampleegg_zps42455e42.png’
)
);
echo display_random_img($ads_array);
echo display_random_img($ads_array_1); // add or remove accordingly
?>[/php]
when I put this directly to the website I come up with this http://simpleadopts.x10.mx/adoptnew Notice the egg is there, in the top left. But I’d like it to be inside the white area, where it says “Fatal Error: Class AdoptnewController either does not exist, or has its include path misconfigured!” I’d also like for it to be in a row of four, with each one a different link, as well as a description under the image. However I do not know how to accomplish this.
I’d also like to link it to my adoption system so that it will link the user to the adoptable instead of google, yahoo, and msn like it does now. [php]<?php
class AdoptController extends AppController{
private $view;
private $subController;
public function __construct(){
parent::__construct("member");
$mysidia = Registry::get("mysidia");
if($mysidia->usergroup->getpermission("canadopt") != "yes"){
throw new NoPermissionException("It appears that you are either not logged in, or do not have permission to adopt.");
}
}
public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
if($mysidia->input->post("submit")){
$this->flag = "member";
$this->handleAccess();
if($mysidia->session->fetch("adopt") != 1 or !is_numeric($mysidia->input->post("id"))) throw new InvalidIDException($mysidia->lang->global_id);
$adopt = new Adoptable($mysidia->input->post("id"));
$conditions = $adopt->getConditions();
if(!$conditions->checkConditions()) throw new NoPermissionException("It appears that you do not meet the condition to acquire this adoptable.");
$name = (!$mysidia->input->post("name"))?$adopt->getType():$mysidia->input->post("name");
$alts = $adopt->getAltStatus();
$code = $adopt->getCode();
$gender = $adopt->getGender();
$mysidia->db->insert("owned_adoptables", array("aid" => NULL, "type" => $adopt->getType(), "name" => $name, "owner" => $mysidia->user->username, "currentlevel" => 0, "totalclicks" => 0, "code" => $code,
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $gender, "lastbred" => 0));
$aid = $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
$document->setTitle("{$name} adopted successfully");
$image = new Image($adopt->getEggImage());
$image->setLineBreak(TRUE);
$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!");
return;
}
$mysidia->session->assign("adopt", 1, TRUE);
$default = (!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member;
$document->setTitle($mysidia->lang->title);
$document->addLangvar($default);
$ids = $mysidia->db->select("adoptables", array("id"), "shop='none'")->fetchAll(PDO::FETCH_COLUMN);
$adoptForm = new Form("form", "adopt", "post");
$adoptTitle = new Comment("Available Adoptables");
$adoptTitle->setHeading(3);
$adoptForm->add($adoptTitle);
$adoptTable = new Table("table", "", FALSE);
foreach($ids as $id){
$adopt = new Adoptable($id);
$conditions = $adopt->getConditions();
if($conditions->checkConditions()){
$row = new TRow;
$idCell = new TCell(new RadioButton("", "id", $id));
$imageCell = new TCell(new Image($adopt->getEggImage(), $adopt->getType()));
$imageCell->setAlign(new Align("center"));
$type = new Comment($adopt->getType());
$type->setBold();
$description = new Comment($adopt->getDescription(), FALSE);
$typeCell = new TCell;
$typeCell->add($type);
$typeCell->add($description);
$row->add($idCell);
$row->add($imageCell);
$row->add($typeCell);
$adoptTable->add($row);
}
}
if(!$ids) $adoptForm->add(new Comment("There is not an adoptable available at this point, please come back later."));
else $adoptForm->add($adoptTable);
$adoptSubtitle = new Comment("Adopt");
$adoptSubtitle->setHeading(3);
$adoptForm->add($adoptSubtitle);
$adoptForm->add(new Comment("Adoptable Name: ", FALSE));
$adoptForm->add(new TextField("name"));
$adoptForm->add(new Comment(""));
$adoptForm->add(new Button("Adopt Me", "submit", "submit"));
$document->add($adoptForm);
}
}
?>[/php]
-thank you