My Adopts Page

Forum
Last Post
Threads / Messages

KittHaven

Member
Member
Joined
May 21, 2013
Messages
478
Points
28
Age
25
Location
Devon, UK
Mysidian Dollar
8,292
Does anyone know how to edit the TCells in the myadoptsview.php file? I am attempting to make it so that your adoptables show up side by side (maybe more than 2 in a row if I can find out a way to auto size them smaller). But I have been trying to edit them for 4 hours now and I am officially lost... I have managed to get it down to where it just shows their image but I don't want that... I want it to also show their gender, their total clicks and their name. So this is what it looks like so far:

  Spoiler: Image 
screenshot_zpsd06547c0.png


Basically, I want the table GONE. I don't like it. And for some reason it won't get rid of the black even when I go into the CSS file and try and manually make the border white... unless it has a shadow and I haven't spotted it? All it seems to have done is make it appear smaller/thinner...


Anyway, what I want now is for it to appear in this format:

IMAGE
NAME
GENDER
TOTAL CLICKS

And for that to continue along the whole page and then go down and start a new row once it reaches the end of the wrapper. Basically, I want it to look like the daycare. I have been looking at the daycare file and attempting to copy across similar commands but it isn't working as I don't think it is compatible if I just change stuff >.< So... it's irritating me now. And I didn't want to ask for help as I want to learn how to do stuff myself now, but without a teacher here to tell me what to do and show me at the same time, learning is going to be VERY hard.. but I will have to just try and find some books or something when I can and see if they help me.

But for now, can anyone help me? ^_^ Thank you..
 
Well, when you are new to something, you will need people's help in some way or another (directly asking questions or reading guides made by others) to go through the initial learning process. So don't feel bad for asking questions

Alright, when we want to do something, we should write down the process. It will make it easier to translate into coding.

1) We take all the adoptables owned by the person
2) We set a limit of how many adoptables will be displayed per row
3) With the number of adoptables (for example, 30) and the limit (for example, 5), we can get the number of rows our table will have (30/5 = 6)
5) To go through all rows, we need a for() cycle.
6) We need to display 5 adoptables per row, so we make an internal for() cycle

PHP:
use Resource\Collection\ArrayList;//add this to use ArrayLists
//rest of code here

	public function index(){
	    $mysidia = Registry::get("mysidia");
		$document = $this->document;
	    $document->setTitle($this->lang->title);
 
        $pagination = $this->getField("pagination");
		$stmt = $this->getField("stmt")->get();
		if($stmt->rowCount() == 0){
		    $document->addLangvar($this->lang->empty);
		    return;
		}

//new code starts here:

	        $adoptTable = new Table("adopttable", "", false);	
	
		$numAdoptsPerRow = 5;
		$total = $stmt->rowCount();
		$numTotalRows = ceil($total / $numAdoptsPerRow);

		$index = 0;

//this is a copy from the table in the Daycare:
		for($row = 0; $row < $numTotalRows; $row++){//for cycle to write the rows
			$aRow = new TRow("row{$row}");
			for($column = 0; $column < $numAdoptsPerRow; $column++){//internal for cycle for the columns
			        $adopt = new OwnedAdoptable($stmt->fetchColumn());
				$cell = new ArrayList;
				$cell->add(new Comment("<a href='/levelup/click/{$adopt->getAdoptID()}'><img src='{$adopt->getImage()}'></a>"));
				$cell->add(new Comment("<b>Name:</b>{$adopt->getName()}"));
				$cell->add(new Comment("<b>Gender:</b>{$adopt->getGender()}"));
				$cell->add(new Comment("<b>Clicks:</b>{$adopt->getTotalClicks()}"));
				$aCell = new TCell($cell, "cell{$index}");
				$aCell->setAlign(new Align("center", "center"));
				$aRow->add($aCell);
				$index++;
				if($index == $total) break;
			}
			$adoptTable->add($aRow);			
		}
		
		$document->add($adoptTable);
		$document->addLangvar($pagination->showPage());
	}
 
Thank you. I guess it just get's frustrating not having anyone physically being here to teach me and so I get a bit frustrated when I don't get something XD Do you know how to change the line:

PHP:
$cell->add(new Comment("<a href='/levelup/click/{$adopt->getAdoptID()}'><img src='{$adopt->getImage()}'></a>"));

to something like:

PHP:
$cell->add(new Comment("<a href='/myadopts/manage/{$aid}'><img src='{$adopt->getImage()}'></a>"));

because that up there ^ doesn't work XD I kind of want it to still link to the stats page as then people can still access the codes and trading options and stuff...
 
Ah, I forgot about that! Sorry!

PHP:
$aid = $stmt->fetchColumn();
$adopt = new OwnedAdoptable($aid);
                $cell = new ArrayList;
                $cell->add(new Comment("<a href='/myadopts/manage/{$aid}'><img src='{$adopt->getImage()}'></a>"));
                $cell->add(new Comment("<b>Name:</b>{$adopt->getName()}"));
                $cell->add(new Comment("<b>Gender:</b>{$adopt->getGender()}"));
                $cell->add(new Comment("<b>Clicks:</b>{$adopt->getTotalClicks()}"));
 
Do you know how to make it so that the genders appear as 'Female' and 'Male' not 'f' and 'm'? I tried editing the array in the deep down core and that works, but stops everything recognising them as male and female (basically breeding doesn't work XD) because I would need to edit everything and anything that specifies their genders. When I put them back to 'm' and 'f' in the table, the adoptables showed back up as available.. and then promptly banned me for modifying the genders XD So I put the files back to normal, but would like to know how to make the gender appear as words?

Could you do a command where it gets the gender, senses whether it is 'f' or 'm' and then inputs Female or Male instead of the letter? (Just for the word on the adopt page, really)

Thanks~
 
If this is doing what I think it's doing, then it's something I had plans for over break, yay~ headstart!

As for gender, try this:
PHP:
if ($adopt->getGender() == "m") { $gender = "Male"; }
if ($adopt->getGender() == "f") { $gender = "Female"; }
Or possibly this, if the above isn't going to work:
PHP:
 $gender_lookup = $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
if ($gender_lookup == "m") { $gender = "Male"; }
if ($gender_lookup == "f") { $gender = "Female"; }

Place either below
PHP:
$adopt = new OwnedAdoptable($aid);
And replace {$adopt->getGender()} with just {$gender}.
 
No, it doesn't quite work. It get's rid of the m and f but's replaces it with nothing. It just shows 'Gender:'

This is what I have:

PHP:
				$aid = $stmt->fetchColumn();
				$adopt = new OwnedAdoptable($aid);
				$gender_lookup = $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
				if ($gender_lookup == "m") { $gender = "Male"; }
				if ($gender_lookup == "f") { $gender = "Female"; }  
                $cell = new ArrayList; 
                $cell->add(new Comment("<a href='/myadopts/manage/{$aid}'><img src='{$adopt->getImage()}'></a>"));
                $cell->add(new Comment("<b>Name: </b>{$adopt->getName()}"));
                $cell->add(new Comment("<b>Gender: </b>{$Gender}"));
                $cell->add(new Comment("<b>Clicks: </b>{$adopt->getTotalClicks()}"));

Thanks ~
 
@IntoRain - I really enjoyed doing this, but is it possible to change the number of adopts shown before a page break to either 9 or 12 instead of 10? I set the adopts to display per row to 3, but now the 10th sits all by herself.

edit// Nvm. Over on myadopts.php (not the view) there's this:
PHP:
$pagination = new Pagination($total, 10, "myadopts");

And that was easy to change.
 
Last edited:
At the top of myadoptsview.php add
PHP:
use Resource\Native\Arrays;
use Resource\Collection\ArrayList;
to the list already there. (He only had us adding one of these, I think we need both?)

Then all you have to do replace the index function with the one IntoRain provided.
 
Yes. This is what this is? IntoRain provided a replacement index code in his post that will do exactly that.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,132
Members
1,603
Latest member
Monako
BETA

Latest Threads

Top