Change gender dropdown to radio button in magento - magento

Today i started working in registration form in magento site. As you know by default it's having gender drop down. I need to change that to checkbox.
So far i went to register.phtml file, and tried to add <input type="radio" ...../> select files, but this didn't worked.
Did anyone know how to solve this !
please give me some suggestions to so this....

Do not forget the validation!
<div class="input-box">
<?php
$options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
$value = $this->getGender();
$_last = count($options);
$_index = 0;
?>
<?php foreach ($options as $option):?>
<?php if($option['value'] != ''): ?>
<input id="<?php echo $this->getFieldId('gender')?>-<?php echo $option['value'] ?>"
class="radio<?php if ($this->isRequired() && $_index == $_last - 1):?> validate-one-required<?php endif; ?>"
type="radio" title="<?php echo $option['label'] ?>"
value="<?php echo $option['value'] ?>" name="<?php echo $this->getFieldName('gender')?>"
<?php if ($option['value'] == $value) echo ' checked="checked"' ?>>
<label for="<?php echo $this->getFieldId('gender')?>-<?php echo $option['value'] ?>">
<?php echo $option['label'] ?>
</label>
<?php endif; ?>
<?php $_index++; ?>
<?php endforeach;?>
</div>

Magento uses widgets on registration form. In fact in template register.phtml you can see lines:
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
<?php if ($_gender->isEnabled()): ?>
<li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
<?php endif ?>
This particular widget can be found in template/customer/widget directory. So in order to change select into radio buttons, copy it (template) to your theme and modify, e.g.:
<div class="input-box">
<label><?php echo $this->__('Gender'); ?></label>
<?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();?>
<?php $value = $this->getGender();?>
<?php foreach ($options as $option):?>
<input type="radio" name="<?php echo $this->getFieldName('gender')?>" value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' selected="selected"' ?> /><?php echo $option['label'] ?>
<br />
<?php endforeach;?>
</div>
Hope didn't make any typo.

Related

Magento Payment Method Drop Down Menu

I am trying to change the payment method radio buttons to a drop down menu.
/app/design/frontend/default/modern/template/checkout/onepage/payment/methods.phtml
This method below works to a degree but while Sagepay processes the order via the radio buttons, it doesn't seem to process successfully when on the drop down menu.
Please could you take a look and let me know what needs to be called? Many thanks in advance!
<dl class="sp-methods" id="checkout-payment-method-load">
<?php
$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>
<?php
$txtArr = array();
$txt ="<select name='payment[method]' onchange='payment.switchMethod(this.value)'>";
foreach ($methods as $_method):
$_code = $_method->getCode();
?>
<!-- <dt>-->
<?php $txt = $txt."<option value='".$_code."' id='p_method_".$_code."'>".$this->htmlEscape($_method->getTitle())."</option>" ?>
<?php if(!$oneMethod): ?>
<!--<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />-->
<?php else: ?>
<!--<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>-->
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<!-- <label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>-->
<!--</dt>-->
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<!-- <dd>-->
<?php //echo $html; ?>
<!--</dd>-->
<?php $txtArr[] = $html;?>
<?php endif; ?>
<?php endforeach; ?>
<?php $txt = $txt."</select>" ?>
<dt>
<?php echo $txt;?>
</dt>
<?php for($i=0;$i<count($txtArr);$i++){?>
<dt><?php echo $txtArr[$i];?></dt>
<?php } ?>
</dl>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>

Magento language switcher how to show unselected language

Please I need your help to show unselected language instead of the selected.
in other words, if you open default language (English) will load and in the top bar will show English to click on it to change to French so i need to show French if the store using English view and same if using French view will show English in topbar.
<?php if(count($this->getStores())>1): ?>
<div class="form-language top-select">
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value" style="width:auto;">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>" <?php if($lang_flag): ?> data-image="<?php echo $this->getSkinUrl('images/flags/'.$_lang->getCode().'.png'); ?>" <?php endif; ?> <?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
<script type="text/javascript">
(function($){
$("#select-language").selectbox();
})(jQuery);
</script>
</div>
<?php endif; ?>

Joomla loginform gives 500 error on bad attempt

At http://falkotl76.seventysix.axc.nl/youcollect/nl/inloggen I have a joomla loginform as a menu-item and it shows well.
When I make an attempt to login without any details it gives me a 500error and I cant figure out how to solve that.
Does anybody know how I can solve this ?
Thanks in regards,
Falko
Once I had the same issue and I fixed it by giving write permission to error.php file.
Path is - your joomla folder/log/error.php
Also make sure log and tmp path is correct in configuration.php
You need to load the client side validation javascript library. Create a template override for the com_users login view file default_login.php. At the top, add the JHtml::_('behavior.formvalidation'); line to load the library. And then add the class 'form-validate' to the form element. Below is an example:
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidation');
?>
<div class="login<?php echo $this->pageclass_sfx?>">
<?php if ($this->params->get('show_page_heading')) : ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<?php if (($this->params->get('logindescription_show') == 1 && str_replace(' ', '', $this->params->get('login_description')) != '') || $this->params->get('login_image') != '') : ?>
<div class="login-description">
<?php endif ; ?>
<?php if($this->params->get('logindescription_show') == 1) : ?>
<?php echo $this->params->get('login_description'); ?>
<?php endif; ?>
<?php if (($this->params->get('login_image')!='')) :?>
<img src="<?php echo $this->escape($this->params->get('login_image')); ?>" class="login-image" alt="<?php echo JTEXT::_('COM_USER_LOGIN_IMAGE_ALT')?>"/>
<?php endif; ?>
<?php if (($this->params->get('logindescription_show') == 1 && str_replace(' ', '', $this->params->get('login_description')) != '') || $this->params->get('login_image') != '') : ?>
</div>
<?php endif ; ?>
<form action="<?php echo JRoute::_('index.php?option=com_users&task=user.login'); ?>" method="post" class="form-validate">
<fieldset>
<?php foreach ($this->form->getFieldset('credentials') as $field): ?>
<?php if (!$field->hidden): ?>
<div class="login-fields"><?php echo $field->label; ?>
<?php echo $field->input; ?></div>
<?php endif; ?>
<?php endforeach; ?>
<?php if (JPluginHelper::isEnabled('system', 'remember')) : ?>
<div class="login-fields">
<label id="remember-lbl" for="remember"><?php echo JText::_('JGLOBAL_REMEMBER_ME') ?></label>
<input id="remember" type="checkbox" name="remember" class="inputbox" value="yes" alt="<?php echo JText::_('JGLOBAL_REMEMBER_ME') ?>" />
</div>
<?php endif; ?>
<button type="submit" class="button"><?php echo JText::_('JLOGIN'); ?></button>
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
</fieldset>
</form>
</div>
<div>
<ul>
<li>
<a href="<?php echo JRoute::_('index.php?option=com_users&view=reset'); ?>">
<?php echo JText::_('COM_USERS_LOGIN_RESET'); ?></a>
</li>
<li>
<a href="<?php echo JRoute::_('index.php?option=com_users&view=remind'); ?>">
<?php echo JText::_('COM_USERS_LOGIN_REMIND'); ?></a>
</li>
<?php
$usersConfig = JComponentHelper::getParams('com_users');
if ($usersConfig->get('allowUserRegistration')) : ?>
<li>
<a href="<?php echo JRoute::_('index.php?option=com_users&view=registration'); ?>">
<?php echo JText::_('COM_USERS_LOGIN_REGISTER'); ?></a>
</li>
<?php endif; ?>
</ul>
</div>
I added a couple of links of template overrides for reference. This should solve your issue.
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
http://docs.joomla.org/Understanding_Output_Overrides

latest product with add-to-cart in magento

I'm new for Magento. I need to display latest added product in home page. I'm using following code in 2columns-left.phtml
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
<?php
$productsCollection = Mage::getModel("catalog/product")->getCollection()
->addAttributeToSort("entity_id","DESC")
->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds())
->setPageSize(6)
->setCurPage(1);
foreach ($productsCollection as $product) {
$model = Mage::getModel('catalog/product')->load($product->getId());
echo $model->getName().'<br>';
echo $model->getPrice().'<br>';
echo $model->getImageUrl().'<br>';
echo "<br><br>";
}
?>
</div>
</div>
It's working fine. But I can't correct code for add-to-cart option.
I found fllowing code from addtocart.phtml with script,
<?php $_product = $this->getProduct(); ?>
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form">
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart">
<?php if(!$_product->isGrouped()): ?>
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
<?php endif; ?>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<?php echo $this->getChildHtml('', true, true) ?>
</div>
<?php endif; ?>
</form>
But, if I click add-to-cart, going to home page.
Help me.
Call a block on home page through static block with content value as
{{block type="catalog/product_list" name="product_listing" template="catalog/product/latest.phtml"}}
or you can directly call this block on cms home , paste this
{{block type="catalog/product_list" name="product_listing" template="catalog/product/latest.phtml" }}
in your cms home page content.
create a file in folder frontend/theme_folder/default/template/catalog/product as latest.phtml.
Paste the below code in it as :
Latest Products
<?php
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setVisibility(array(2,3,4))
->setOrder('created_at', 'desc')
->setPage(1, 4);
?>
<?php $_iterator = 0; ?>
<ul class="products-grid">
<?php foreach($_productCollection as $_product) : ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<?php // Product Image ?>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<div class="product-shop">
<div class="f-fix">
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl(); ?>"><?php echo $_product->getName(); ?></h2>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
Thats it you will be able to see the latest 4 product on home page. you can increase the number of product by increasing the ->setPage(1, 4); to your required number of product on home page.

magento mobileshoppe theme - Fatal error: Call to a member function getSize() on a non-object in

I am using mobileshoppe magento theme for our store, when i installed magento it was showing latest products on home page using the code below.
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
Then we customized the theme and it stopped to display latest products on home page even the code above is as it is in admin.
It shows the error -
Fatal error: Call to a member function getSize() on a non-object in D:\wamp\www\magento\app\design\frontend\default\mobileshoppe\template\catalog\product\list\toolbar_top.phtml on line 34
toolbar_top.phtml
<?php if($this->getCollection()->getSize()): ?>
<div class="toolbar">
<?php if( $this->isExpanded() ): ?>
<div class="sorter">
<?php if( $this->isEnabledViewSwitcher() ): ?>
<p class="view-mode">
<?php $_modes = $this->getModes(); ?>
<?php if($_modes && count($_modes)>1): ?>
<label><?php echo $this->__('View as') ?>:</label>
<?php foreach ($this->getModes() as $_code=>$_label): ?>
<?php if($this->isModeActive($_code)): ?>
<strong title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?>"><?php echo $_label ?></strong>
<?php else: ?>
<?php echo $_label ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</p>
<?php endif; ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
<?php echo $_limit ?>
</option>
<?php endforeach; ?>
</select> <?php echo $this->__('per page') ?>
</div>
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<img src="<?php echo $this->getSkinUrl('images/i_desc_arrow.gif') ?>" alt="<?php echo $this->__('Set Ascending Direction') ?>" class="v-middle" />
<?php else: ?>
<img src="<?php echo $this->getSkinUrl('images/i_asc_arrow.gif') ?>" alt="<?php echo $this->__('Set Descending Direction') ?>" class="v-middle" />
<?php endif; ?>
</div>
</div>
<?php endif; ?>
can anyone please help me on this? Thanks...
Hello Guys I had the same issue on my Mobileshoppe Template. I tried to add products of a category and it didn't work for me.
In the end the solution was to use as mentioned on the official Mobileshoppe page "readme" file: http://magresponsive.devdemoz.com/readme.html
I used the code where it says: 2) Create cms page (home page) step bellow.
Hope it helps somebody.

Resources