Magento customer dashboard tracking number - php

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>

Related

Get Magento Order ID, Order Value and Coupon Code in success.phtml

We need to get Order ID, Order Value and Coupon Code from success.phtml.
We already have Google added to our success.phtml, and now we need to set up a new affiliate. We are not sure what $order_details and $adwords_saleamt do? Can we re-use them in any way?
Example
<?php
$order_details = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$adwords_saleamt = $order_details->subtotal;
?>
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = xxxxxxxxxx;
var google_conversion_language = "xy";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "xxxxxxxxxxxx";
var google_conversion_value = 0.00;
if (<?php echo $adwords_saleamt; ?>) {
google_conversion_value = <?php echo $adwords_saleamt; ?>;
}
var google_conversion_currency = "EUR";
var google_remarketing_only = false;
/* ]]> */
</script>
You can try following
$order_details = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$adwords_saleamt = $order_details->subtotal; //subtotal without tax and shipping
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); //Order Id
$couponCode = $order_details->coupon_code; //Coupon code
Then use the values in your affiliate code.
Code there please, copy and paste in your file and then check, if any issue let me know...
echo $this->getLayout()->createBlock('checkout/cart_totals')->setTemplate('onepagecheckout/onepage/review/totals.phtml')->toHtml();
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
// Get shipping method
$shipping_method = $order_details->_data["shipping_description"];
// Get ship-to address information
$shipping_address_data = $order_details->getShippingAddress();
$session = Mage::getSingleton('core/session', array('name'=>'frontend'));
$card = $session->getGiftcard();
$cvv = $session->getGiftcardCvd();
$amount = $session->getGiftcardDeduct();
?>
<div class="inner_content">
<div class="inner-header-categories clearfix">
<h1><?php echo $this->__('Order Confirmation') ?></h1>
</div>
<div class="order_confirmation_div">
<h3><?php echo $this->__('Thank you for your order!') ?></h3>
<p>
<?php echo $this->__('Dear') ?> <?php echo $shipping_address_data['firstname']; ?>,<br>
<?php echo $this->__('Thank you for your order!') ?><br>
<?php if ($this->getCanViewOrder()) :?>
<p><?php echo $this->__('Your order id is: %s.', sprintf('%s', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
<?php else :?>
<p><?php echo $this->__('Your order id is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
<?php endif;?>
</p>
<?php
$orderObj = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$orderItems = $orderObj->getAllItems();
?>
<h4><?php echo $this->__('Item Summary') ?></h4>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="order_ct_table">
<tr>
<th><?php echo $this->__('Product') ?></th>
<!--<th>Ship by</th>
<th>Delivers By</th>-->
<th><?php echo $this->__('Qty') ?></td>
<th class="no_border"><?php echo $this->__('UNIT PRICE') ?></th>
</tr>
<?php foreach($orderItems as $item)
{
?>
<tr>
<td class="porduct_dark_text"><div class="image_cart_in"><p><?php echo $item->getName();?></p></div></td>
<!--<td>18 August 2013</td>
<td>20 August 2013</td>-->
<td><?php echo round($item->getQtyOrdered(), 0);?></td>
<td class="no_border">$<?php echo number_format($item->getPrice(),2); ?></td>
</tr>
<?php }
?>
</table>
<h4><?php echo $this->__('Purchase Summary') ?>:</h4>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="order_ct_table_two">
<tr>
<td class="col_one_left"><?php echo $this->__('ITEM SUB TOTAL') ?> :</td>
<td class="no_border">$<?php echo number_format($orderValue = $orderObj->getSubtotal(),2);?></td>
</tr>
<?php if($orderObj->getDiscountAmount()!=0) { ?>
<tr>
<td class="col_one_left"><?php echo $this->__('Discount') ?> :</td>
<td class="no_border">$<?php echo number_format($orderValue = $orderObj->getDiscountAmount(),2);?></td>
</tr>
<?php } ?>
<tr>
<td class="col_one_left"><?php echo $orderObj->getShippingDescription(); ?>:</td>
<td class="no_border">$<?php echo number_format($orderSValue = $orderObj->getShippingAmount(),2); ?></td>
</tr>
<?php if(!empty($card)): ?>
<tr>
<td class="col_one_left"><?php echo $this->__('Giftcard ('.$card.') discount') ?>:</td>
<td class="no_border">$<?php echo number_format($amount,2); ?></td>
</tr>
<?php endif; ?>
<tr>
<td class="col_one_left"><?php echo $this->__('Tax') ?>:</td>
<?php
$GT = number_format($orderObj->getGrandTotal(),2);
$STA = number_format($orderSValue = $orderObj->getShippingAmount(),2);
$IST = number_format($orderValue = $orderObj->getSubtotal(),2);
$TAX = $IST+$STA;
$TTAX = $GT-$TAX;
?>
<td class="no_border">$<?php echo number_format($orderSValue = $orderObj->getTaxAmount(),2); ?></td>
</tr>
<tr>
<td class="col_one_left"><?php echo $this->__('Total') ?>:</td>
<td class="no_border">$<?php echo $GT;?></td>
</tr>
</table>
<ul class="billing_detail_confirm_ul_top"><li><h4><?php echo $this->__('Billing Address') ?></h4></li>
<li><h4><?php echo $this->__('Shipping Address') ?></h4></li></ul>
<ul class="billing_detail_confirm_ul">
<li>
<table border="0" cellspacing="0" cellpadding="0" style="border-right:none;">
<tr>
<td><?php echo $this->__('First Name') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['firstname']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('Last Name') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['lastname'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Company') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['company'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Phone') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['telephone'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Address') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['street'];?><br>
<?php echo $shipping_address_data['region']; ?>, <?php echo $shipping_address_data['postcode']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('City') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['city'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Country') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['country_id'];?></td>
</tr>
<tr>
<td><?php echo $this->__('State') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['region']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('Zip') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['postcode']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('Email') ?></td>
<td class="right_bold_text"><?php if($shipping_address_data['email']=='') { echo Mage::getSingleton('customer/session')->getCustomer()->getEmail(); } else { echo $shipping_address_data['email']; } ?></td>
</tr>
</table>
</li>
<li>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php echo $this->__('First Name') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['firstname']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('Last Name') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['lastname'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Company') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['company'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Phone') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['telephone'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Address') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['street'];?><br>
<?php echo $shipping_address_data['region']; ?>, <?php echo $shipping_address_data['postcode']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('City') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['city'];?></td>
</tr>
<tr>
<td><?php echo $this->__('Country') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['country_id'];?></td>
</tr>
<tr>
<td><?php echo $this->__('State') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['region']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('Zip') ?></td>
<td class="right_bold_text"><?php echo $shipping_address_data['postcode']; ?></td>
</tr>
<tr>
<td><?php echo $this->__('Email') ?></td>
<td class="right_bold_text"><?php if($shipping_address_data['email']=='') { echo Mage::getSingleton('customer/session')->getCustomer()->getEmail(); } else { echo $shipping_address_data['email']; } ?></td>
</tr>
</table>
</li>
</ul>
<h3><td><?php echo $this->__('Thank you for shopping with us!') ?></td></h3>
<button class="proceed" style="margin-bottom:40px;" onclick="window.location='<?php echo $this->getUrl() ?>'"><?php echo $this->__('Return to Homepage') ?></button>
</div>
</div>

Dynamic rowspan table in PHP

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.

Grouped Products with Individual “Add To Cart” Button (Magento)

I am trying to set up a grouped product in Magento.
What i am trying to accomplish is to add “add to cart” - button behind every grouped option that adds only this product to cart and not the hole grouped product.
I have managed to get "read more" buttom to work with
<?php echo $this->htmlEscape($_item->getProductUrl()) ?>
This will show product.
The problem is, when i add the "add to cart" buttom it shows error, because i havent selected amount yet. (Please select amount before adding to cart)
Is it possible to make default amount = 1 for grouped product and then add "add to cart" buttom to every product? Just as i did with "read more"?
UPDATE
This is how my grouped.phtml looks:
?>
<?php $this->setPreconfiguredValue(); ?>
<?php $_product = $this->getProduct(); ?>
<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<?php if ($_product->isAvailable() && $_hasAssociatedProducts): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<table class="data-table grouped-items-table" id="responsive-table">
<thead>
<tr>
<th><?php echo $this->__('Product Name') ?></th>
<th><?php echo $this->__('Metode (hvordan)') ?></th>
<th><?php echo $this->__('Sted (hvor)') ?></th>
<th><?php echo $this->__('Tilgængelighed') ?></th>
<th><?php echo $this->__('Fast Startdato') ?></th>
<?php if ($this->getCanShowProductPrice($_product)): ?>
<th><?php echo $this->__('Price') ?></th>
<?php endif; ?>
<?php if ($_product->isSaleable()): ?>
<th><?php echo $this->__('Qty') ?></th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php if ($_hasAssociatedProducts): ?>
<?php foreach ($_associatedProducts as $_item): ?>
<?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
<tr>
<td data-title="Produkt navn"><?php echo $this->htmlEscape($_item->getName()) ?></td>
<td data-title="Metode (hvordan)"><?php echo $_item->getAttributeText('prod_media'); ?></td>
<td data-title="Sted (hvor)"><?php echo $_item->getAttributeText('prod_place_region'); ?></td>
<td data-title="Tilgængelighed"><?php echo $_item->getAttributeText('prod_availability'); ?></td>
<td data-title="Fast Startdato"><?php echo $this->htmlEscape($_item->getprod_date_startday()); ?></td>
<td data-title="Pris">
<?php if ($this->getCanShowProductPrice($_item)): ?>
<?php echo $this->getPriceHtml($_item, true) ?>
<?php echo $this->getTierPriceHtml($_item) ?>
<?php endif; ?>
</td>
<?php echo $this->getTierPriceHtml($_item) ?></td>
<?php if ($_product->isSaleable()): ?>
<td>
<button type="button" title="Læs mere" class="button " onclick="setLocation('<?php echo $this->htmlEscape($_item->getProductUrl()) ?>'); return false; "><span><span>Læs mere</span></span></button>
<input type="button" title="<?php echo $this->__('Add to Cart') ?>" class="addtocart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$row['product_id'],'qty'=>1)) ?>')" />
<?php if ($_item->isSaleable()) : ?>
<input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('super-product-table')</script>
array('product'=>$_item->getId(),'qty'=>1)) ?>')"
EDIT:
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="addtocart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$_product->getProductId(),'qty'=>1)) ?>')"/>

Getting pager to show on magento list

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() ?>

Need Help with inserting code

I am not a programmer by no means. I am trying to figure out how to get this code inserted into profile.php
$author_id = get_query_var('author');
if($author_id){
echo do_shortcode("[photosmash gallery_type='contributor' author=" . $author_id . " no_form=true]");
}
Below is profile.php code:
<?php global $mngl_user, $mngl_friend, $mngl_options; ?>
<?php $display_profile = ( $user->privacy == 'public' or
MnglUser::is_logged_in_and_an_admin() or
MnglUser::is_logged_in_and_visible() ); ?>
<table class="mngl-profile-table">
<tr>
<td valign="top" class="mngl-profile-table-col-1 mngl-valign-top">
<table>
<tr>
<td>
<?php echo $avatar; ?>
<?php echo $mngl_friends_controller->display_add_friend_button($mngl_user->id, $user->id); ?>
<?php echo do_action('mngl-profile-display',$user->id); ?>
</td>
</tr>
<tr>
<td valign="top" class="mngl-valign-top">
<?php if($display_profile) { ?>
<?php if(isset($mngl_options->field_visibilities['profile_front']['bio']) and !empty($user->bio)) { ?>
<p class="mngl-profile-bio"><?php echo MnglBoardsHelper::format_message($user->bio); ?></p>
<?php } ?>
<div class="mngl-profile-information">
<?php if(isset($mngl_options->field_visibilities['profile_front']['name']) and !empty($user->first_name) and ($user->first_name != $user->screenname)) { ?>
<p class="mngl-profile-field"><strong><?php _e('Name', 'mingle'); ?>:</strong><br/><?php echo wptexturize(stripslashes($user->first_name)); ?>
<?php if(!empty($user->last_name)){ ?>
<?php echo " " . wptexturize(stripslashes($user->last_name)); ?>
<?php } ?>
</p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['profile_front']['sex']) and !empty($user->sex)) { ?>
<p class="mngl-profile-sex"><strong><?php _e('Gender', 'mingle'); ?>:</strong><br/><?php echo $user->sex_display; ?></p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['profile_front']['location']) and !empty($user->location)) { ?>
<p class="mngl-profile-location"><strong><?php _e('Location', 'mingle'); ?>:</strong><br/><?php echo wptexturize($user->location); ?></p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['profile_front']['birthday']) and !empty($user->birthday)) { ?>
<p class="mngl-profile-location"><strong><?php _e('Birthday', 'mingle'); ?>:</strong><br/><?php echo wptexturize($user->birthday); ?></p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['profile_front']['url']) and !empty($user->url)) { ?>
<p class="mngl-profile-url"><strong><?php _e('Website', 'mingle'); ?>:</strong><br/><?php echo make_clickable($user->url); ?></p>
<?php } ?>
</div>
<?php } ?>
<p><strong><?php _e('Friends', 'mingle'); ?>:</strong><div class="mngl-profile-friend-grid-wrap"><?php echo $mngl_friends_controller->display_friends_grid($user->id); ?></div></p>
</td>
</tr>
</table>
</td>
<td valign="top" class="mngl-profile-table-col-2">
<table class="mngl-profile-body">
<tr>
<td>
<div class="mngl-profile-name"><?php echo $user->screenname; ?></div>
<?php
if(!$display_profile)
require( MNGL_VIEWS_PATH . '/mngl-boards/private.php' );
?>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<?php if($display_profile) { ?>
<td valign="top" width="100%"><div class="mngl-board"><?php echo $mngl_boards_controller->display($user->id); ?></div></td>
<?php } ?>
</tr>
</table>
</td>
</table>
The new code needs to be enclosed in <?php and ?>. Then insert it into any free HTML area, for example between the empty <td> and </td> at the bottom. If it looks better elsewhere, move it. For non-programmers this is a trial end error method. Just take care not to insert it within any <?php if(... and <?php } ?> areas.

Categories