Modify Shop Display

Forum
Last Post
Threads / Messages

Abronsyth

A Headache Embodied
Member
Joined
Aug 25, 2011
Messages
1,012
Points
36
Location
NY
Mysidian Dollar
73,285
I am trying to modify the shop listing display so that shops are next to one another (I am only showing the images), instead of over one another. So, say I have 5 shops, it show 5 shops all next to one another horizontally.

Say I have 10 shops, it has 2 rows of 5.

I am not very clever with PHP generated tables, so I am a wee bit lost.

Does anyone know how I might accomplish this?
 
You need to create a table without border, and then you need to calculate the number of rows from total shops and the columns(5 in your case). You will use PHP for loops to add table cells to a table row until it needs to switch to a new row. Finally you add all rows to the table, and add table to the document.

If it sounds too complex, you can take a look at levelupview.php file and method daycare(), it will give you an example of how to create Icon View. It is not very difficult once you get a hang of it.

Code:
        $daycareTable = new Table("daycare", "", FALSE);
        $total = $daycare->getTotalAdopts();
        $index = 0;

        for($row = 0; $row < $daycare->getTotalRows(); $row++){
            $daycareRow = new TRow("row{$row}");
            for($column = 0; $column < $daycare->getTotalColumns(); $column++){
                $adopt = new OwnedAdoptable($adopts[$index]);
                $cell = new ArrayList;
                $cell->add(new Link("levelup/click/{$adopt->getAdoptID()}", $adopt->getImage("gui"), TRUE));
                $cell->add(new Comment($daycare->getStats($adopt)));
                $daycareCell = new TCell($cell, "cell{$index}");
                $daycareCell->setAlign(new Align("center", "center"));
                $daycareRow->add($daycareCell);
                $index++;
                if($index == $total) break;
            }
            $daycareTable->add($daycareRow);            
        }
        
        $document->add($daycareTable);
 
Here's my code for /view/shopview.php:
PHP:
<?php

use Resource\Collection\LinkedList;

class ShopView extends View{
	
	public function index(){
		$document = $this->document;
	    $document->setTitle($this->lang->access);
		
		$typeForm = new Form("shoptypes", "shop", "post");
		$typeSelection = new DropdownList("shoptype");
		$typeSelection->add(new Option("Itemshop", "itemshop"));
		$typeSelection->add(new Option("Adoptshop", "adoptshop"));
		$typeForm->add($typeSelection);
		$typeForm->add(new Button("Go", "submit", "submit"));
		$document->add($typeForm);
		
		$shopList = $this->getField("shopList");
        
		$iterator = $shopList->iterator();
		while($iterator->hasNext()){
            $entry = $iterator->next();
		    $shop = $shopList->createshop($entry->getKey());
		    
                    # Display Shop...
			$document->add(new Comment("<div style='display: inline-table;'>
			<a href='/shop/browse/{$shop->shopname}'>
			    <img src='{$shop->imageurl}' rel='tooltip' title=\"{$shop->shopname}<br>
			   <strong>Location:</strong> {$shop->category}<br>
			   {$shop->description}\">
		       </a></div>", FALSE));
		}
	}
	
	public function browse(){
		$document = $this->document;			        
		$document->setTitle($this->lang->welcome);
        $shop = $this->getField("shop");
        $shop->display();
	}
	
	public function purchase(){
        $mysidia = Registry::get("mysidia");
		$cost = $this->getField("cost");
		$document = $this->document;		
		
	    if($mysidia->input->post("shoptype") == "itemshop"){
		    $document->setTitle($this->lang->global_transaction_complete);
	        $document->addLangvar("{$this->lang->purchase_item}{$cost->getValue()} {$mysidia->settings->cost}");
		}
		elseif($mysidia->input->post("shoptype") == "adoptshop"){
   			$document->setTitle($this->lang->global_transaction_complete);
	        $document->addLangvar("{$this->lang->purchase_adopt}{$cost->getValue()} {$mysidia->settings->cost}");	  
		}
		else return;
	}
}
?>

I've taken the tables away entirely and replaced them with only linked pictures. Try setting the div width to 20% so it only takes up 1/5 of the page.
 
Last edited:
Thank you both!

I've decided to use Lotus's modifications, now I can set it up to actually look like a market!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

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

Latest Threads

Latest Posts

Top