We currently have a quote page which lists all existing quotes that we would like to show the pager.
We have the following code in the List page which we've added the call to the pager but it doesn't appear to be showing frontend at all.
I've also added the history page which displays a list with a pager as an example of a working page we are trying to emulate.
Can anyone point us in the right direction as we appear to be missing something
List
<?php $_quotation = $this->getQuotations();?>
<?php if($_quotation->getSize()): ?>
<?php echo $this->getPagerHtml(); ?>
<table cellspacing="0" class="data-table" id="my-quotations-table">
<thead>
<tr>
<th class="quote-quote"><?php echo $this->__('Quote #') ?></th>
<th class="quote-date"><?php echo $this->__('Creation Date') ?></th>
<th class="quote-valid"><?php echo $this->__('Valid until') ?></th>
<th class="quote-status"><?php echo $this->__('Status') ?></th>
<th class="quote-view-link"> </th>
</tr>
</thead>
<tbody>
<?php $_odd = ''; ?>
<?php foreach ($this->getQuotations() as $_quotation): ?>
<?php $_quotation->checkExpirationDateAndApply(); ?>
<tr>
<td><?php echo $_quotation->getincrement_id() ?></td>
<td><?php echo $this->formatDate($_quotation->getcreated_time()) ?></td>
<td><?php echo $this->formatDate($_quotation->getValidEndTime()); ?>
<td><?php echo $this->__($_quotation->getstatus()); ?></td>
<td class="a-center"><?php if ($_quotation->isViewableByCustomer()): ?>
<?php echo $this->__('View Quotation') ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('my-quotations-table')</script>
<?php echo $this->getPagerHtml(); ?>
<?php else: ?>
<p><?php echo $this->__('You have no quotes available.') ?></p>
<?php endif ?>
History
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php $_orders = $this->getOrders(); ?>
<div class="pager"><?php echo $this->getPagerHtml(); ?></div>
<?php if($_orders->getSize()): ?>
<table class="data-table" id="my-orders-table">
<col width="1" />
<col width="1" />
<col />
<col width="1" />
<col width="1" />
<col width="1" />
<thead>
<tr>
<th><?php echo $this->__('Order #') ?></th>
<th><?php echo $this->__('Date') ?></th>
<th><?php echo $this->__('Delivery To') ?></th>
<th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
<th><span class="nobr"><?php echo $this->__('Order Status') ?></span></th>
<th> </th>
</tr>
</thead>
<tbody>
<?php $_odd = ''; ?>
<?php foreach ($_orders as $_order): ?>
<tr>
<td><?php echo $_order->getRealOrderId() ?></td>
<td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
<td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : ' ' ?></td>
<td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td><em><?php echo $_order->getStatusLabel() ?></em></td>
<td class="a-center">
<span class="nobr"><?php echo $this->__('View Order') ?>
<?php /*<span class="separator">|</span><?php echo $this->__('Track Order') ?> */ ?>
<?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
<span class="separator">|</span> <?php echo $this->__('Reorder') ?>
<?php endif ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('my-orders-table');</script>
<?php echo $this->getPagerHtml(); ?>
<?php else: ?>
<p><?php echo $this->__('You have placed no orders.'); ?></p>
<?php endif ?>
Layout block for List
<quotation_quote_list>
<reference name="root">
<action method="setTemplate"><template>page/3columns-account.phtml</template></action>
</reference>
<update handle="customer_account"/>
<reference name="content">
<block type="Quotation/Frontend_Grid" name="quotationslist" as="quotationslist" template="Quotation/List.phtml"/>
</reference>
</quotation_quote_list>
We can implement custom model collection with magento pagination by extending Mage_Catalog_Block_Product_List class in our block class. Suppose I want to display users blog posts with pagination. Here is the steps to implement it easily:
Create a block class (posts.php) and add the below code in it.
class Blog_User_Block_Posts extends Mage_Catalog_Block_Product_List
{
protected function _beforeToHtml()
{
$toolbar = $this->getToolbarBlock();
$collection = $this->_getPostsCollection();
$toolbar->setCollection($collection); /*(Add toolbar to collection)*/
return parent::_beforeToHtml();
}
}
In the view.phptml file add the below code in it
<?php echo $this->getToolbarHtml() ?>
Related
I want to output statement you are approve if the row status = 1, the data can be output now i just want the statement saying approve.
here's my code
<div class="row">
<div class="col-md-12">
<table class="table table-striped">
<tr>
<th>Nominee Name</th>
<th>Year</th>
<th>Department</th>
<th>StudentID</th>
<th>Position</th>
<th>View File</th>
<th>Nominee Photo</th>
<th>Nominated by</th>
<th>status</th>
</tr>
<?php
foreach ($nominees as $noms) {
?>
<tr>
<td><?php echo $noms['name']; ?></td>
<td><?php echo $noms['year']; ?></td>
<td><?php echo $noms['department']; ?></td>
<td><?php echo $noms['studentid']; ?></td>
<td><?php echo $noms['position']; ?></td>
<td></td>
<td><img src="<?php echo base_url(); ?>uploads/<?php echo $noms['photo']; ?>" style='width:50px;height:50px;'></td>
<td><?php echo $noms['nomname']; ?></td>
<?php if ($noms['approve'] == 1) { ?>
<td>Approve</td>
<?php } else { ?>
<td>pending</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</div>
</div>
If the $nominees array returns the stays, then you can do like this
<?php if ( $nom['status'] == 1) { ?>
<td>Approve</td>
<?php }else{ ?>
<td>pending</td>
<?php }?>
What am I missing here? It always produces new tables instead of one table where all datasets are in.
foreach($results as $print) { ?>
<table class='wp-list-table widefat striped'>
<thead>
<tr> <!-- display table header -->
<th style='text-align:center;' width=<?php echo $width[0]; ?>><?php echo $character[0]; ?></th>
<th style='text-align:center;' width=<?php echo $width[1]; ?>><?php echo $character[1]; ?></th>
</tr>
</thead>
<tbody>
<form action='' method='post'>
<tr> <!-- display data -->
<td width=<?php echo $width[0]; ?>><?php echo $print->postleitzahl; ?></td>
<td width=<?php echo $width[1]; ?>><?php echo $print->ort; ?></td>
</tr>
</form>
<?php } ?>
</tbody>
</table>
Can you find my mistake? Sorry but I can't see it.
I would do it this way:
<table class='wp-list-table widefat striped'>
<thead>
<tr> <!-- display table header -->
<th style='text-align:center;' width=<?php echo $width[0]; ?>><?php echo $character[0]; ?></th>
<th style='text-align:center;' width=<?php echo $width[1]; ?>><?php echo $character[1]; ?></th>
</tr>
</thead>
<tbody>
foreach($results as $print) { ?>
<form action='' method='post'>
<tr> <!-- display data -->
<td width=<?php echo $width[0]; ?>><?php echo $print->postleitzahl; ?></td>
<td width=<?php echo $width[1]; ?>><?php echo $print->ort; ?></td>
</tr>
</form>
<?php } ?>
</tbody>
</table>
I have a following code which I have written to convert the download monitor output to html table.
<div class="table-1">
<table width="100%">
<thead>
<tr>
<th>Lab Title</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php $dlm_download->the_title(); ?></td>
<td><a href="<?php $dlm_download->get_the_download_link(); ?>">
<?php $dlm_download->the_title(); ?> (<?php echo $dlm_download->get_the_download_count(); ?>)</a></td>
</tr>
</tbody>
</table>
</div>
however this gives me the output as shown below
how can I modify code so the table headers aren't repeated for every download.
Update: here's the php code
<?php global $dlm_page_addon; ?>
<div class="download_category download_group">
<!-- <h3><?php //echo $category->name; ?> <?php //if ( $category->count ) : ?>(<?php //echo $category->count; ?>)<?php //endif; ?></h3> -->
<?php while ( $downloads->have_posts() ) : $downloads->the_post(); ?>
<?php $dlm_download = new DLM_Download( get_the_ID() ); ?>
<?php $template_handler = new DLM_Template_Handler(); $template_handler->get_template_part( 'content-download', $format, $dlm_page_addon->plugin_path() . 'templates/', array( 'dlm_download' => $dlm_download ) ); ?>
<?php endwhile; ?>
</div>
As far as I understand, this code passes the array $dlm_download to the template. The template code is the one with the table and has repeating table headers. I want to have a three column table with download title, category and download link.
Replace <th></th> tags with <td></td> and use <strong>Content</strong>
<div class="table-1">
<table width="100%">
<thead>
<tr>
<td><strong>Lab Title</strong></td>
<td>Download</td>
</tr>
</thead>
<tbody>
<tr>
<td><?php $dlm_download->the_title(); ?></td>
<td><a href="<?php $dlm_download->get_the_download_link(); ?>">
<?php $dlm_download->the_title(); ?> (<?php echo $dlm_download->get_the_download_count(); ?>)</a></td>
</tr>
</tbody>
</table>
</div>
I have a problem getting a table to work.
I want to adjust a printable form for order list (opencart),
but I want address box on left and products ordered on right.
The problem is the number of products varies per order, so using rowspan on the address box does not work (I left the rowspan in the code).
<thead>
<tr>
<td><b><?php echo $text_to; ?></b></td>
<td><b><?php echo $column_product; ?></b></td>
<td class="text-center"><b><?php echo $column_quantity; ?></b></td>
</tr>
</thead>
<tbody><tr>
<td rowspan="10"><?php echo $order['shipping_address']; ?><br/><br/>
<?php echo $order['telephone']; ?>
<br />
<?php if ($order['shipping_method']) { ?>
<b><?php echo $text_shipping_method; ?></b> <?php echo $order['shipping_method']; ?><br />
<?php } ?></td></tr>
<?php foreach ($order['product'] as $product) { ?>
<td><?php echo $product['name']; ?>
<?php foreach ($product['option'] as $option) { ?>
<br />
<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
<?php } ?></td>
<td class="text-center"><?php echo $product['quantity']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
You have all the information available it seems so you just need to change:
<td rowspan="10">
to:
<td rowspan="<?php echo count($order['product']); ?>">
However, you do need to check the generated html as it looks like you are not generating valid rows so you might need to change the logic a bit.
I'm editing the template file for the customer dashboard at sales/order/recent.phtml. I want the tracking number along with a tracking link to show up under the recent order. I have tried the following but getAllTracks is not grabbing anything. Thoughts?
<?php foreach ($_orders as $_order): ?>
<tr>
<td><?php echo $_order->getRealOrderId() ?></td>
<td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
<td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : ' ' ?></td>
<td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td><em><?php echo $_order->getStatusLabel() ?></em></td>
<td class="a-center">
<span class="nobr">
<?php echo $this->__('View Order') ?>
<?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
<span class="separator">|</span> <?php echo $this->__('Reorder') ?>
<?php endif ?>
</span>
</td>
</tr>
<tr>
<?php $collection = Mage::getResourceModel('sales/order_shipment_collection');
$collection->addAttributeToFilter('order_id', $_order->getRealOrderId()); ?>
<?php foreach($collection as $_ship): ?>
<?php var_dump($_ship->getAllTracks())?>
<?php $i=0; foreach ($_ship->getAllTracks() as $_item): $i++ ?>
<?php $url = $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>
<?php echo "URL is". $url ?>
<?php if ($url): ?>
<td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getNumber() ?></td>
<?php else: ?>
<td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getNumber() ?></td>
<?php endif; ?>
<?php endforeach ?>
<!---Track --->
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
Ended up being a really short line of code to put the link in there. I didn't bother to keep working at getting the tracking number. I put the link in the second to last column.
<div class="box-account box-recent">
<?php $_orders = $this->getOrders(); ?>
<div class="box-head">
<h2><?php echo $this->__('Recent Orders') ?></h2>
<?php if( sizeof($_orders->getItems()) > 0 ): ?><?php echo $this->__('View All') ?><?php endif; ?>
</div>
<?php if( sizeof($_orders->getItems()) > 0 ): ?>
<table class="data-table" id="my-orders-table">
<col width="1" />
<col width="1" />
<col />
<col width="1" />
<col width="1" />
<col width="1" />
<thead>
<tr>
<th><?php echo $this->__('Order #') ?></th>
<th><?php echo $this->__('Date') ?></th>
<th><?php echo $this->__('Ship To') ?></th>
<th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
<th><?php echo $this->__('Status') ?></th>
<th><?php echo $this->__('Track') ?></th>
<th> </th>
</tr>
</thead>
<tbody>
<?php foreach ($_orders as $_order): ?>
<tr>
<td><?php echo $_order->getRealOrderId() ?></td>
<td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
<td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : ' ' ?></td>
<td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td><em><?php echo $_order->getStatusLabel() ?></em></td>
<td>
<?php if ($_order->getTracksCollection()->count()) : ?>
<?php echo $this->__('Track Order Shipment') ?>
<br/>
<?php endif; ?>
</td>
<td class="a-center">
<span class="nobr">
<?php echo $this->__('View Order') ?>
<?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
<span class="separator">|</span> <?php echo $this->__('Reorder') ?>
<?php endif ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('my-orders-table')</script>
<?php else: ?>
<p><?php echo $this->__('You have placed no orders.'); ?></p>
<?php endif; ?>
</div>