PDA

View Full Version : Remove name and description on adoption page


Abronsyth
08-05-2014, 02:37 PM
Hello!

I was wondering how I should properly remove the "type" and "description" from the adopt page?

I think I see where to edit it, but I don't want to risk breaking it ^_^

Thanks!
Abron

Hall of Famer
08-06-2014, 02:26 PM
In script file view/adoptview.php, you can find this for loop at around line 40:


for($i = 0; $i < $adopts->length(); $i++){
$row = new TRow;
$idCell = new TCell(new RadioButton("", "id", $adopts[$i]->getID()));
$imageCell = new TCell(new Image($adopts[$i]->getEggImage(), $adopts[$i]->getType()));
$imageCell->setAlign(new Align("center"));

$type = new Comment($adopts[$i]->getType());
$type->setBold();
$description = new Comment($adopts[$i]->getDescription(), FALSE);
$typeCell = new TCell;
$typeCell->add($type);
$typeCell->add($description);

$row->add($idCell);
$row->add($imageCell);
$row->add($typeCell);
$adoptTable->add($row);
}


You can change it to this:


for($i = 0; $i < $adopts->length(); $i++){
$row = new TRow;
$idCell = new TCell(new RadioButton("", "id", $adopts[$i]->getID()));
$imageCell = new TCell(new Image($adopts[$i]->getEggImage(), $adopts[$i]->getType()));
$imageCell->setAlign(new Align("center"));

$row->add($idCell);
$row->add($imageCell);
$adoptTable->add($row);


Thus the cell that contains type/description will be gone, but keep in mind your site may look a bit weird with some blank space that doesnt fit well. Lemme know if anything weird happens. ^^

Abronsyth
08-13-2014, 12:18 PM
I can't seem to find the directory "view?"

I am using version 1.3.3, if that changes anything.

Hall of Famer
08-13-2014, 01:46 PM
Oh I see, yeah version 1.3.3 does not separate controller from view so you dont have separate view files. I dont have version 1.3.3 source code with my new laptop now, can you post adopt.php here so I can help you sort out?

Abronsyth
08-13-2014, 03:05 PM
I have it right here. I can see where I need to change it, but I'm still uneasy about PHP, so I don't want to break it, haha.
<?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);
}
}
?>

Hall of Famer
08-13-2014, 03:17 PM
I have it right here. I can see where I need to change it, but I'm still uneasy about PHP, so I don't want to break it, haha.

Yup, you just have to remove anything related to the variable $typeCell. Here you goes, locate these lines:


$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);


Replace them by:


$row = new TRow;
$idCell = new TCell(new RadioButton("", "id", $id));
$imageCell = new TCell(new Image($adopt->getEggImage(), $adopt->getType()));
$imageCell->setAlign(new Align("center"));
$row->add($idCell);
$row->add($imageCell);
$adoptTable->add($row);

Abronsyth
08-13-2014, 03:25 PM
Awesome! Worked like a charm!

Many thanks to you, HoF!

Hall of Famer
08-13-2014, 03:28 PM
You are very welcome. ^^ I am glad to help like always.