how to print specific value using while loop in codeigniter view page? - codeigniter

I want to print the value where country name is Canada. using foreach I have got the all value. In the while loop I restrict the value that which I want to print. are there any error in this line==> ins_country = "Canada"): ?>
<div style="width: 100%">
<?php foreach ($ins as $i) { ?>
<?php while ($i->ins_country = "Canada"): ?>
<div class="lop_div">
<h2> <?php echo $i->ins_country; ?></h2>
<?php echo $i->ins_name; ?><br>
</div>
<?php endwhile; ?>
<?php }
?>
</div>

Instead of while use if condition:
<?php foreach ($ins as $i) { ?>
<?php if ($i->ins_country = "Canada"): ?>
<div class="lop_div">
<h2> <?php echo $i->ins_country; ?></h2>
<?php echo $i->ins_name; ?><br>
</div>
<?php endif; ?>
<?php }
?>

<div style="width: 100%">
<?php foreach ($ins as $i) { ?>
<?php if ($i->ins_country == "Canada"){ ?>
<div class="lop_div">
<?php echo $i->ins_country;?>;
<?php echo $i->ins_name; ?><br>
</div>
<?php } ?>
<?php }
?>
</div>

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

shipping restriction based on the selected currency

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.

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; ?>

How to display Option List in wishlist sidebar magento

How to display Option List in wishlist sidebar magento?
I use this code!
However, it is not working. Thanks in advance.
<?php if ($_options = $this->getOptionList()):?>
<div class="truncated">
<div class="truncated_full_value">
<dl class="item-options">
<?php foreach ($_options as $_option) : ?>
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
<dd>
<?php if (is_array($_option['value'])): ?>
<?php echo nl2br(implode("\n", $_option['value'])) ?>
<?php else: ?>
<?php echo $_option['value'] ?>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
</div>
<?php echo $this->__('Details') ?>
</div>
<?php endif; ?>
try this:
<?php $options = $this->getOptionList(); ?>
<?php if ($options): ?>
<div class="truncated">
<div class="truncated_full_value">
<div class="item-options">
<p><?php echo $this->__('Options Details'); ?></p>
<dl>
<?php foreach ($options as $option): ?>
<dt><?php echo $this->escapeHtml($option['label']) ?></dt>
<dd>
<?php if (is_array($option['value'])): ?>
<?php echo nl2br(implode("\n", $option['value'])) ?>
<?php else: ?>
<?php echo $option['value'] ?>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
</div>
</div>
<?php echo $this->__('View Details') ?>
</div>
<?php endif ?>

CodeIgniter - Undefined variable & Trying to get property of non-object

I'm trying to get data from API in my Controller and pass the data to the View. But it don't seem working and causing error:
Message:Undefined variable: data and
Message:Trying to get property of non-object
Both errors happen in my View.php, on the line when I call variable $data.
This is part of my controller related to data I want to get
$jdwl['jadwal'] = $this->bolalob->api('schedules/bydate|'.$start.'/'.$end.'/10');
$data['jadwal'] = $this->load->view('jadwal', $jdwl, TRUE);
$template['content'] = $this->load->view('jadwal',$data, TRUE);
$this->load->view('template', $template);
And this is my view
<div class="float-left first-column">
<div class="box box-shadow red round-top round-bottom">
<div class="title-box"><strong>JADWAL</strong> TV</div>
<ul class="text-center no-padding">
<?php if ($data->data == 'no data') { ?>
<li class="jadwal-tv"><strong>Belum ada jadwal</strong>
</li>
<?php } else { ?>
<?php foreach ($data->data as $key=>$row) { ?>
<?php if ($key == 0) { ?>
<li class="jadwal-tv"><strong><?php echo $row->team_1->name; ?></strong><br />VS<br /><strong><?php echo $row->team_2->name; ?></strong><br /><span><?php echo $row->television; ?> <?php echo date('d/m/y H:i', $row->pubdate); ?> WIB</span></li>
<?php } else { ?>
<li class="side-padding">
<strong><?php echo $row->team_1->name; ?></strong> vs <strong><?php echo $row->team_2->name; ?></strong>
<br />
<?php echo $row->television; ?> <?php echo date('d/m/y H:i', $row->pubdate); ?> WIB
</li>
<?php } ?>
<?php if ($key == 5) break; ?>
<?php } ?>
<?php } ?>
</ul>
</div>
</div>
The error happens to $data on line the 5 and 9. I've googled it and tried to use $data['jadwal'] instead of $data in my view but I didn't seem working too.
Anyone can help me with this?
Thanks :D
In your view no need to acess the $data array.
you can directly call your data key as a variable.
Ex:
In controller
$data['myVar']="Some string";
$this->load->view('viewName',$data);
In view
echo $myVar;
Try with the following view page..
<div class="float-left first-column">
<div class="box box-shadow red round-top round-bottom">
<div class="title-box"><strong>JADWAL</strong> TV</div>
<ul class="text-center no-padding">
<?php if (empty($jadwal)) { ?>
<li class="jadwal-tv"><strong>Belum ada jadwal</strong>
</li>
<?php } else { ?>
<?php foreach ($jadwal as $key => $row) { ?>
<?php if ($key == 0) { ?>
<li class="jadwal-tv"><strong><?php echo $row->team_1->name; ?></strong><br />VS<br /><strong><?php echo $row->team_2->name; ?></strong><br /><span><?php echo $row->television; ?> <?php echo date('d/m/y H:i', $row->pubdate); ?> WIB</span></li>
<?php } else { ?>
<li class="side-padding">
<strong><?php echo $row->team_1->name; ?></strong> vs <strong><?php echo $row->team_2->name; ?></strong>
<br />
<?php echo $row->television; ?> <?php echo date('d/m/y H:i', $row->pubdate); ?> WIB
</li>
<?php } ?>
<?php if ($key == 5) break; ?>
<?php } ?>
<?php } ?>
</ul>
</div>

Resources