shipping restriction based on the selected currency - magento

I need to implement shipping restriction based on the selected currency.
For example:
If people select / use US dollars to check out, their delivery address can only be in USA, and if people select GBP in currency drop down, their delivery address can only be in UK.
Anyone know how can I achieve that? I am a junior developer and this is my first Maganto project.
Here is my available.phtml file:
<?php $_shippingRateGroups = $this->getShippingRates(); ?>
<?php if (!$_shippingRateGroups): ?>
<p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else: ?>
<dl class="sp-methods">
<?php $shippingCodePrice = array(); ?>
<?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
<dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
<dd>
<ul>
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
<?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $this->escapeHtml($_rate->getErrorMessage()) ?></li></ul></li></ul>
<?php else: ?>
<?php if ($_sole) : ?>
<span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
<?php else: ?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
<?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
<script type="text/javascript">
//<![CDATA[
lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
//]]>
</script>
<?php endif; ?>
<?php endif; ?>
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
<?php endif ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
//<![CDATA[
<?php if (!empty($shippingCodePrice)): ?>
var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
<?php endif; ?>
$$('input[type="radio"][name="shipping_method"]').each(function(el){
Event.observe(el, 'click', function(){
if (el.checked == true) {
var getShippingCode = el.getValue();
<?php if (!empty($shippingCodePrice)): ?>
var newPrice = shippingCodePrice[getShippingCode];
if (!lastPrice) {
lastPrice = newPrice;
quoteBaseGrandTotal += newPrice;
}
if (newPrice != lastPrice) {
quoteBaseGrandTotal += (newPrice-lastPrice);
lastPrice = newPrice;
}
<?php endif; ?>
checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
return false;
}
});
});
//]]>
</script>
<?php endif; ?>

You can restrict the shipping methods according to the currency type. just go to the
app\design\frontend\base\default\template\checkout\onepage\shipping_method\available.phtml and get the currency by getting cart over here. And now by simple If/Else conditions according to the currency you can restrict the shipping methods.

Related

Magento product page resize

http://dev.factorydirectmedical.com/wheelchairs?mode=grid this is my product page and I want to resize the images. I used Magento developer option to hint the template path. Here a screenshot, (http://www.awesomescreenshot.com/image/1645297/4998c8379ebab36e77cab59c1a9c3bd5), I found the HTML file but I'm unable to fix this image box.
List.phtml
<?php
/**
* #package be
* #copyright Copyright (c) 2010-2015 MeigeeTeam. (http://www.meigeeteam.com)
*/
?>
<?php
/**
* Product list template
*
* #see Mage_Catalog_Block_Product_List
*/
?>
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$meigeeOptions = $this->getLayout();
$gridColumns = $meigeeOptions->getMConfigResultByAlias('listing_columns');
$productType = $meigeeOptions->getMConfigResultByAlias('listing_product_type');
$listType = $meigeeOptions->getMConfigResultByAlias('listing_list_type');
$grid_indents = $meigeeOptions->getMConfigResultByAlias('listing_indents');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<?php echo $this->getLayout()->createBlock('page/html')->setProductInfo($_product)->setProductList($this)->setIterator($this)->setTemplate($listType)->toHtml(); ?>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php else: ?>
<?php // Grid Mode ?>
<ul class="products-grid row <?php echo $gridColumns.''.($grid_indents != 1 ? ' no-indents' : ''); ?>">
<?php foreach ($_productCollection as $_product): ?>
<?php echo $this->getLayout()->createBlock('page/html')->setProductInfo($_product)->setProductList($this)->setTemplate($productType)->toHtml(); ?>
<?php endforeach ?>
</ul>
<script type="text/javascript">
decorateGeneric($$('ul.products-grid'), ['odd','even','first','last']);
</script>
<?php endif; ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
<script type="text/javascript">
jQuery(window).load(function(){
function buttonsSize(){
if(jQuery('.category-products li.item').length){
jQuery('.category-products li.item').each(function(){
itemsCount = jQuery(this).find('.image-box .actions').children().length;
switch(itemsCount) {
case 1:
itemsCountClass = 'one-item';
break;
case 2:
itemsCountClass = 'two-items';
break;
case 3:
itemsCountClass = 'three-items';
break;
case 4:
itemsCountClass = 'four-items';
break;
default:
itemsCountClass = 'four-items';
break;
}
jQuery(this).find('.image-box .actions').addClass(itemsCountClass);
});
}
}
buttonsSize();
jQuery(window).resize(function(){
buttonsSize();
});
if('undefined' != typeof GeneralToolbar) {
buttonsSize();
}
GeneralToolbar.onInit = function(){
buttonsSize();
}
});
</script>
<?php if(Mage::app()->getLayout()->getBlock('ajaxkit')->issetSubmodulesConfig('general_toolbar')) { ?>
<div class="infinite-scroll-elements">
<div class="infinite-scroll-loader"><div></div></div>
<div class="infinite-scroll-button" id="StaticScrollBtn"><?php echo $this->__('Show More Products'); ?></div>
</div>
<?php } ?>
</div>
<?php endif; ?>
<?php
// Provides a block where additional page components may be attached, primarily good for in-page JavaScript
if ($this->getChild('after')){
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach ($_afterChildren as $_afterChildName){
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
//set product collection on after blocks
$_afterChild->setProductCollection($_productCollection);
echo $_afterChild->toHtml();
}
}
?>
new.phtml
<?php
/**
* #package be
* #copyright Copyright (c) 2010-2015 MeigeeTeam. (http://www.meigeeteam.com)
*/
$meigeeOptions = $this->getLayout();
$lightBox = $meigeeOptions->getMConfigResultByAlias('lightbox_listing');
$timerStatus = $meigeeOptions->getMConfigResultByAlias('timer_status');
$timerListingStatus = $meigeeOptions->getMConfigResultByAlias('timer_listing_status');
$catalogModeWrapper = $meigeeOptions->getMConfigResultByAlias('catalog_mode');
$catalogMode = $catalogModeWrapper['value']['sv2']['value'];
?>
<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<div class="row">
<div class="widget widget-new-products clearfix">
<div class="col-xs-12">
<header class="widget-title">
<h2><?php echo $this->__('New Products') ?></h2>
</header>
</div>
<div class="widget-products col-xs-12">
<?php echo $this->getPagerHtml() ?>
<div class="row">
<ul class="products-grid clearfix">
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
<li class="item col-xs-6 col-sm-3">
<div class="image-box">
<?php if($lightBox){ ?>
<a href="<?php echo $_product->getProductMediaResized(930, 'small_image')->getImageSrc(); ?>" data-toggle="lightbox" class="lightbox-button" data-footer="<?php echo $this->stripTags($_product->getName(), null, true) ?>" title="<?php echo $this->__('Lightbox'); ?>">
<i class="icon-search"></i>
</a>
<?php } ?>
<?php echo $this->getLayout()->createBlock('page/html')->setProductInfo($_product)->setTemplate('catalog/product/product_labels.phtml')->toHtml(); ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
<span class="mask"></span>
<?php
echo $_product->productHoverImage($this, 800);
$escaped_label = $this->stripTags($_product->getName(), null, true);
echo '<img '. $_product->getProductMediaResized(800, 'small_image')
->addImageHtmlAttributte('alt', $escaped_label)
->addImageHtmlAttributte('title', $escaped_label)
->getImageHtmlAttributte().' />';
?>
</a>
<div class="actions clearfix">
<?php if ($_product->isSaleable()): ?>
<?php if($catalogMode == 0) { ?>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')); ?>" class="btn btn-default pull-left" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><i class="icon-basket"></i></span></span></button>
<?php } ?>
<?php else: ?>
<a class="btn btn-default" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Read More')); ?>"><i class="icon-link"></i></a>
<?php endif; ?>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<span class="link-wishlist-wrapper"><i class="icon-heart-fa"></i></span>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<span class="link-compare-wrapper"><i class="icon-shuffle"></i></span>
<?php endif; ?>
</div>
</div>
<h3 class="product-name"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></h3>
<?php if($_product->isSaleable()): ?>
<p class="availability in-stock"><i class="icon-record"></i><?php echo $this->__('Product') ?> <span><?php echo $this->__('In stock') ?></span></p>
<?php else: ?>
<p class="availability out-of-stock"><i class="icon-record"></i><?php echo $this->__('Product') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php echo $this->getPriceHtml($_product, true, '-new') ?>
<?php if($timerStatus && $timerListingStatus) {
echo $this->getLayout()->createBlock('page/html')->setProduct($_product)->setTemplate('catalog/product/listing_timer.phtml')->toHtml();
} ?>
<hr class="indent-18 white-space"/>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
<?php endif; ?>
Images come from list.phtml
There may use other method to get this image. if you unable to find image then please provide me list.phtml file code

I want to display an option list for configurable attributes on product list page in magento

I want to display an option list for configurable attributes on product list page in magento, just like it appears on product view page for configurable products.I tried everything but nothing is working, looked for some similar topics but they are useless.Please help me resolve this issue.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$sidebar=Mage::getStoreConfig('buyshoplayout/product_listing/sidebar');
$i=0;
$count=0;
$span=3;
$p_in_row=4;
$type=Mage::getStoreConfig('buyshoplayout/product_listing/product_listing_image_size');
if($type=='small')
{
$span=2;
$p_in_row=6;
}
?>
<?php if(!$_productCollection->count()): ?>
<div class="category-products aligncenter">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('buyshop_no_products')->toHtml() ?>
</div>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php foreach ($_productCollection as $_product): ?>
<?php
$widthBig=258;
$heightBig=245;
$widthSmall=71;
$heightSmall=65;
$count++;
?>
<!--PRODUCT-->
<div class="row product-listing">
<?php echo Mage::helper('buyshopconfig')->getProductHtml($_product,$this,$widthBig,$heightBig,$span,false,true,true,false,$this->getPriceHtml($_product, true))?>
<div class="span6 product-detailes">
<h3 class="product-name bottom-line"><?php echo $this->stripTags($_product->getName(), null, true)?></h3>
<div class="bottom-line">
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="product-review">
<?php echo Mage::helper('buyshopconfig')->getStars($_product)?>
</div>
</div>
<div class="bottom-line"><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></div>
<div class="product-buttons">
<?php echo Mage::helper('buyshopconfig')->addToCartLink($_product,$this,true)?>
<div class="add-to-links">
<ul>
<?php echo Mage::helper('buyshopconfig')->addWishCompLink($_product,$this,true)?>
</ul>
</div>
</div>
</div>
</div>
<!--PRODUCT EOF-->
<?php endforeach; ?>
<?php else: ?>
<?php // Grid Mode ?>
<?php if(!empty(Mage::registry('current_category')->name)):?>
<h2><?php echo Mage::registry('current_category')->name ?></h2>
<?php endif; ?>
<?php if($sidebar):?><div class="row big_with_description"><?php endif; ?>
<?php foreach ($_productCollection as $_product): ?>
<?php if(!$_product->isSaleable() && !Mage::getStoreConfig('cataloginventory/options/show_out_of_stock'))continue; ?>
<?php
$widthBig=258;
$heightBig=245;
$widthSmall=71;
$heightSmall=65;
$count++;
?>
<?php
if(!$sidebar)
{
$i++;
if($i==1)echo '<div class="row big_with_description">';
}
$price=$this->getPriceHtml($_product, true);
?>
<!--PRODUCT-->
<?php echo Mage::helper('buyshopconfig')->getProductHtml($_product,$this,$widthBig,$heightBig,$span,false,true,false,true,$price)?>
<?php echo Mage::helper('buyshopconfig')->getProductHover($_product,$this,$widthBig,$heightBig,$widthSmall,$heightSmall,$type,true,true,$price)?>
<!--PRODUCT EOF-->
<?php
if(!$sidebar)
{
if($i==$p_in_row || $count==count($_productCollection))
{
echo '</div>';
$i=0;
}
}
?>
<?php endforeach; ?>
<?php if($sidebar):?></div><?php endif; ?>
<?php endif; ?>
<?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>

Implementing Lightbox in Magento

I already have an existing page which I'm trying to turn into a Magento website. One the pages I'm working on makes use of Lightbox. I tried including the lightbox file through Design in the CMS Page. Same for content but it didn't work there. Is there any way I can include the lightbox javascript from the previous website without having to touch the xml, html and php files? How do I make the lightbox work on the website?
You can always add a javascript file to the page's head by adding the following to the design tab of your CMS page (note that the path is relative to the root js directory). However, if you plan on using lightbox on multiple pages, this would not be the preferred method because you'd have to copy this into the design tab of every page you needed it on.
<reference name="head">
<action method="addJs"><js>custom/lightboxjs</js></action>
</reference>
View.PHTML
<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<?php $config = Mage::getStoreConfig('mdloption/product-type-option'); ?>
<?php if($config['product-view-option'] !=2 && $config['product-view-option'] !=3): ?>
<?php $classnNum ='span9'?>
<?php else:?>
<?php $classnNum ='f-fix'?>
<?php endif; ?>
<?php if($config['product-view-option']==3):?>
<?php $classnNum2 = 'left-carousel'?>
<?php endif; ?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="product-view <?php echo $classnNum; ?>">
<!--<a class="prePage" href="<?php //echo $_SESSION['core']['last_url'];?>"><?php //echo $this->__('Return to Previous Page')?></a>-->
<!--Prev/Next Code Start-->
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$prev_url = $next_url = $url = $_product->getProductUrl();
if ($this->helper('catalog/data')->getCategory()) {
$category = $this->helper('catalog/data')->getCategory();
} else {
$_ccats = $this->helper('catalog/data')->getProduct()->getCategoryIds();
$category = Mage::getModel('catalog/category')->load($_ccats[0]);
}
$children = $category->getProductCollection();
$_count = is_array($children) ? count($children) : $children->count();
if ($_count) {
foreach ($children as $product) {
$plist[] = $product->getId();
}
$current_pid = $this->helper('catalog/data')->getProduct()->getId();
$curpos = array_search($current_pid, $plist);
$previd = isset($plist[$curpos+1])? $plist[$curpos+1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($previd);
$prevpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$prevpos += 1;
$nextid = isset($plist[$prevpos])? $plist[$prevpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$prev_url = $product->getProductUrl();
$nextid = isset($plist[$curpos-1])? $plist[$curpos-1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
$nextpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$nextpos -= 1;
$nextid = isset($plist[$nextpos])? $plist[$nextpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$next_url = $product->getProductUrl();
}
?>
<!--Prev/Next Code End-->
<div class="product-essential">
<div class="product-img-box span6 <?php echo $classnNum2;?>"> <?php echo $this->getChildHtml('media') ?> </div>
<div class="productDetailBox span6">
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div class="no-display">
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
<input type="hidden" name="related_product" id="related-products-field_1" value="" />
</div>
<div class="product-shop">
<div class="product_left f-fix">
<div class="nextPre">
<!-- <a rel="tooltip" data-placement="left" title="<?php echo $this->__('No Products')?>" class="prod-prev disable" href="JavaScript:void(0);">Prev</a>
<a rel="tooltip" data-placement="right" title="<?php echo $this->__('No Products')?>" class="prod-next disable" href="JavaScript:void(0);">NEXT</a>-->
<?php if ($url <> $prev_url):?>
<a class="prod-next" rel="tooltip" data-placement="right" title="<?php echo $this->__('Volgende product')?>" href="<?php echo $prev_url; ?>"><i class="fa fa-angle-right"></i></a>
<?php endif; ?>
<?php if ($url <> $next_url):?>
<a rel="tooltip" data-placement="left" title="<?php echo $this->__('Vorige product')?>" class="prod-prev" href="<?php echo $next_url; ?>"><i class="fa fa-angle-left"></i></a>
<?php endif; ?>
</div>
<div class="product-name">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
</div>
<div class="review"> <?php echo $this->getReviewsSummaryHtml($_product, false, true)?> </div>
<div class="stock_box">
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('<i class="fa fa-check-circle"></i> Beschikbaar') ?></span></p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('<i class="fa fa-times-circle"></i> Verkocht') ?></span></p>
<?php endif; ?>
</div>
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
</div>
<?php endif;?>
<div class="pro-left">
<div class="add_to_cart">
<?php if (!$this->hasOptions()):?>
<div class="add-to-box">
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php endif; ?>
<div class="price_box">
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml()?>
</div>
</div>
<?php endif; ?>
<?php echo $this->getChildHtml('other');?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<div class="price_box">
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml()?>
</div>
<?php endif;?>
<div class="clear"></div>
</div>
<div class="f-fix">
<?php echo $this->getChildHtml('extrahint') ?>
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
<?php endif; ?>
<?php echo $this->getChildHtml('addto') ?>
<?php if ($this->canEmailToFriend()): ?>
<p class="email-friend"><a rel="tooltip" data-placement="top" title="<?php echo $this->__('Email to a Friend') ?>" href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><i class="fa fa-envelope"></i> <?php echo $this->__('Email to a Friend') ?></a></p>
<?php endif; ?>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f74bbe87b978120"></script>
<!-- AddThis Button END -->
</div>
</div>
</div>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('static_links')->toHtml() ?>
</div>
</form>
</div>
<div class="product-collateral" id="tabs">
<?php echo $this->getChildHtml('info_tabs') ?>
</div>
</div>
</div>
<?php if($config['product-view-option'] !=2 && $config['product-view-option'] !=3): ?>
<div class="product_right span3">
<?php $config = Mage::getStoreConfig('mdloption/upsellsetting'); ?>
<?php if($config['upsellblocks']==1):?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php elseif($config['upsellblocks']==2):?>
<?php if($_product->getUpsellProducts()): ?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php else: ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('productBanner')->toHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product_custom_block')->toHtml() ?>
<?php endif ?>
<?php elseif($config['upsellblocks']==3):?>
<?php echo $this->getChildHtml('upsell_products'); ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('productBanner')->toHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product_custom_block')->toHtml() ?>
<?php endif;?>
<div class="staticSidebar">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product-static-box')->toHtml() ?>
</div>
</div>
<?php endif; ?>
<?php //echo $this->getChildHtml('upsell_products'); ?>
<?php //echo $this->getChildHtml('related'); ?>
<script type="text/javascript">
//<![CDATA[
var productAddToCartForm = new VarienForm('product_addtocart_form');
productAddToCartForm.submit = function(button, url) {
if (this.validator.validate()) {
var form = this.form;
var oldUrl = form.action;
if (url) {
form.action = url;
}
var e = null;
try {
this.form.submit();
} catch (e) {
}
this.form.action = oldUrl;
if (e) {
throw e;
}
if (button && button != 'undefined') {
button.disabled = true;
}
}
}.bind(productAddToCartForm);
productAddToCartForm.submitLight = function(button, url){
if(this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
// Remove custom datetime validators
for (var methodName in Validation.methods) {
if (methodName.match(/^validate-datetime-.*/i)) {
delete Validation.methods[methodName];
}
}
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
//]]>
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("a[rel=example_group]").fancybox({
hideOnContentClick : true,
showNavArrows : false,
arrows : false,
showTitle : false,
scrolling : 'no',
'transitionIn' : 'none',
'transitionOut' : 'none',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' ' + title : '') + '</span>';
}
});
});
</script>

Warning: get_class() expects parameter 1 to be object, boolean given

I'm having a problem that's been in some way posted here before but never for this case. Usually this error occurs in App.php but for me it's occurring in /httpdocs/app/design/frontend/default/theme/template/catalog/category/view.phtml on line 42 which I've indicated below.
Does anyone have any idea on the fix for this? I'm a bit at a loss.
<?php
/**
* Category view template
*
* #see Mage_Catalog_Block_Category_View
*/
?>
<?php
$_helper = $this->helper('catalog/output');
$_category = $this->getCurrentCategory();
$_imgHtml = '';
$_category->setCanShowBlock(false);
$_category->setHasHeaderImage(false);
//////Line 42/////// if (get_class($this->getLayout()->getBlock('catalog.leftnav')) != 'Mage_Catalog_Block_Navigation') {
$_category->setCanShowBlock($this->getLayout()->getBlock('mana.catalog.leftnav')->canShowBlock());
}
if ($_imgUrl = $_category->getImageUrl()) {
$_imgHtml = '<img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" />';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
$_category->setHasHeaderImage(true);
}
?>
<?php /*
<!-- <div class="page-title category-title">
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
<?php echo $this->__('Subscribe to RSS Feed') ?>
<?php endif; ?>
<h1><img src="<?php echo $this->getSkinUrl('images/' . $_helper->categoryAttribute($_category, $_category->getName(), 'name') . '.jpg') ?>" alt="<?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?>" /></h1>
</div> -->
*/
Mage::getModel('core/session')->setHasAdditionalDescription(false);
?>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div id="category_top_image"<?php if ($_category->getCanShowBlock()): ?> style="margin-left: -280px;"<?php endif ?>>
<?php if($_imgUrl): ?>
<?php echo $_imgHtml ?>
<?php endif; ?>
<?php if(strtolower($_category->getHideTitle()) != 'yes'): ?>
<h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
<?php endif ?>
<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
<div class="category-description std">
<?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
</div>
<?php endif; ?>
</div>
<?php if($this->isContentMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php elseif($this->isMixedMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
<?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
<?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
<?php endif; ?>
<?php echo $this->getProductListHtml() ?>
<?php else: ?>
<?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
<?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
<?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
<?php endif; ?>
<?php echo $this->getProductListHtml() ?>
<?php endif; ?>
Well, that error means that there is no block named catalog.leftnav on the page, so you should check your layouts. And actually this way of checking class is bad since it leads to such errors. Also there will be a problem, if some extension will rewrite Mage_Catalog_Block_Navigation class.
So I'm not sure why do you want to check the class of that block, but if you really need it, I would suggest something less risky and rewrite-friendly:
if ($block = $this->getLayout()->getBlock('catalog.leftnav') && $block instanceof Mage_Catalog_Block_Navigation) {
...
}

Alternative layout is applied to an article but not the other

I'm using Joomla 3.x and create an article override. It works fine for some articles. But when I apply to another article, inside a single article menu item, it not work.
UPDATE
Here is my entire override file:
<?php
/**
* #package Joomla.Site
* #subpackage com_content
*
* #copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
// Create shortcuts to some parameters.
$params = $this->item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $params->get('access-edit');
$user = JFactory::getUser();
$info = $params->get('info_block_position', 0);
JHtml::_('behavior.caption');
?>
<div class="item-page<?php echo $this->pageclass_sfx?>">
<?php if ($this->params->get('show_page_heading') && $params->get('show_title')) : ?>
<div class="page-header">
<h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
</div>
<?php endif;
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && $this->item->paginationrelative)
{
echo $this->item->pagination;
}
?>
<?php if ($params->get('show_title') || $params->get('show_author')) : ?>
<div class="page-header">
<h2>
<?php if ($this->item->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php if ($params->get('show_title')) : ?>
<?php if ($params->get('link_titles') && !empty($this->item->readmore_link)) : ?>
<?php echo $this->escape($this->item->title); ?>
<?php else : ?>
<?php echo $this->escape($this->item->title); ?>
<?php endif; ?>
<?php endif; ?>
</h2>
<p class="date-created"><?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC3'))); ?></p>
</div>
<?php endif; ?>
<?php if (!$this->print) : ?>
<?php if ($canEdit || $params->get('show_print_icon') || $params->get('show_email_icon')) : ?>
<div class="btn-group pull-right">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <span class="icon-cog"></span> <span class="caret"></span> </a>
<?php // Note the actions class is deprecated. Use dropdown-menu instead. ?>
<ul class="dropdown-menu actions">
<?php if ($params->get('show_print_icon')) : ?>
<li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $this->item, $params); ?> </li>
<?php endif; ?>
<?php if ($params->get('show_email_icon')) : ?>
<li class="email-icon"> <?php echo JHtml::_('icon.email', $this->item, $params); ?> </li>
<?php endif; ?>
<?php if ($canEdit) : ?>
<li class="edit-icon"> <?php echo JHtml::_('icon.edit', $this->item, $params); ?> </li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
<?php else : ?>
<div class="pull-right">
<?php echo JHtml::_('icon.print_screen', $this->item, $params); ?>
</div>
<?php endif; ?>
<?php $useDefList = ($params->get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date')
|| $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author')); ?>
<?php if ($useDefList && ($info == 0 || $info == 2)) : ?>
<div class="article-info muted">
<dl class="article-info">
<!--<dt class="article-info-term"><?php echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?></dt>-->
<?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
<dd class="createdby">
<?php $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; ?>
<?php if (!empty($this->item->contactid) && $params->get('link_author') == true) : ?>
<?php
$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getItems('link', $needle, true);
$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author)); ?>
<?php else: ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_parent_category') && !empty($this->item->parent_slug)) : ?>
<dd class="parent-category-name">
<?php $title = $this->escape($this->item->parent_title);
$url = ''.$title.'';?>
<?php if ($params->get('link_parent_category') && !empty($this->item->parent_slug)) : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_category')) : ?>
<dd class="category-name">
<?php $title = $this->escape($this->item->category_title);
$url = '' . $title . '';?>
<?php if ($params->get('link_category') && $this->item->catslug) : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_publish_date')) : ?>
<dd class="published">
<!--<span class="icon-calendar"></span>--> <?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON', JHtml::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($info == 0) : ?>
<?php if ($params->get('show_modify_date')) : ?>
<dd class="modified">
<!--<span class="icon-calendar"></span>--> <?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_create_date')) : ?>
<dd class="create">
<!--<span class="icon-calendar"></span>--> <?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_hits')) : ?>
<dd class="hits">
<span class="icon-eye-open"></span> <?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->item->hits); ?>
</dd>
<?php endif; ?>
<?php endif; ?>
</dl>
</div>
<?php endif; ?>
<?php if (!$params->get('show_intro')) : echo $this->item->event->afterDisplayTitle; endif; ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '0')) || ($params->get('urls_position') == '0' && empty($urls->urls_position)))
|| (empty($urls->urls_position) && (!$params->get('urls_position')))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php if ($params->get('access-view')):?>
<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
<?php $imgfloat = (empty($images->float_fulltext)) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_fulltext_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_fulltext_caption) . '"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>"/> </div>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
endif;
?>
<?php if (isset ($this->item->toc)) :
echo $this->item->toc;
endif; ?>
<div class="article-text"><?php echo $this->item->text; ?></div>
<?php if ($useDefList && ($info == 1 || $info == 2)) : ?>
<div class="article-info muted">
<dl class="article-info">
<!--<dt class="article-info-term"><?php echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?></dt>-->
<?php if ($info == 1) : ?>
<?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
<dd class="createdby">
<?php $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; ?>
<?php if (!empty($this->item->contactid) && $params->get('link_author') == true) : ?>
<?php
$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getItems('link', $needle, true);
$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author)); ?>
<?php else: ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_parent_category') && !empty($this->item->parent_slug)) : ?>
<dd class="parent-category-name">
<?php $title = $this->escape($this->item->parent_title);
$url = '' . $title . '';?>
<?php if ($params->get('link_parent_category') && $this->item->parent_slug) : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_category')) : ?>
<dd class="category-name">
<?php $title = $this->escape($this->item->category_title);
$url = '' . $title . '';?>
<?php if ($params->get('link_category') && $this->item->catslug) : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_CATEGORY', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_publish_date')) : ?>
<dd class="published">
<!--<!--<span class="icon-calendar"></span>-->-->
<?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON', JHtml::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php endif; ?>
<?php if ($params->get('show_create_date')) : ?>
<dd class="create">
<!--<!--<span class="icon-calendar"></span>-->-->
<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_modify_date')) : ?>
<dd class="modified">
<!--<span class="icon-calendar"></span>-->
<?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_hits')) : ?>
<dd class="hits">
<span class="icon-eye-open"></span> <?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->item->hits); ?>
</dd>
<?php endif; ?>
</dl>
</div>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
?>
<?php endif; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '1')) || ($params->get('urls_position') == '1'))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php //optional teaser intro text for guests ?>
<?php elseif ($params->get('show_noauth') == true && $user->get('guest')) : ?>
<?php echo $this->item->introtext; ?>
<?php //Optional link to let them register to see the whole article. ?>
<?php if ($params->get('show_readmore') && $this->item->fulltext != null) :
$link1 = JRoute::_('index.php?option=com_users&view=login');
$link = new JURI($link1);?>
<p class="readmore">
<a href="<?php echo $link; ?>">
<?php $attribs = json_decode($this->item->attribs); ?>
<?php
if ($attribs->alternative_readmore == null) :
echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
elseif ($readmore = $this->item->alternative_readmore) :
echo $readmore;
if ($params->get('show_readmore_title', 0) != 0) :
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif;
elseif ($params->get('show_readmore_title', 0) == 0) :
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
else :
echo JText::_('COM_CONTENT_READ_MORE');
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif; ?>
</a>
</p>
<?php endif; ?>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && $this->item->paginationrelative) :
echo $this->item->pagination;
?>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayContent; ?> </div>
UPDATE 2
I discovered one thing: if the article is associated with a menu item (type:Category List), the Alternative Layout works. But when the article is associated a menu item (type:Single Article), the Alternative Layout does not work. How do the Alternative Layout function in both cases?
SOLVED!
I Create a custom menu item type.
More informations here: http://docs.joomla.org/Layout_Overrides_in_Joomla_2.5
And here: http://jure-stern.si/blog/custom-menu-item-types-in-joomla-with-xml-files/

Resources