Tuesday, June 14, 2011

Dob day validation error for 08 in magento customer registration

Plz put the following script in the top of dob.phtml

< script type ="text/javascript">
<!--
Varien.DateElement = Class.create();Varien.DateElement.prototype {
    initialize
: function(typecontentrequiredformat{
        
if (type == 'id'{
            
// id prefix
            
this.day    = $(content 'day');
            
this.month  = $(content 'month');
            
this.year   = $(content 'year');
            
this.full   = $(content 'full');
            
this.advice = $(content 'advice');
        
else if (type == 'container'{
            
// content must be container with data
            
this.day    content.day;
            
this.month  content.month;
            
this.year   content.year;
            
this.full   content.full;
            
this.advice content.advice;
        
else {
            
return;
        
}

        this
.required required;
        
this.format   format;
        
        
this.day.addClassName('validate-custom');
        
this.day.validate this.validate.bind(this);
        
this.month.addClassName('validate-custom');
        
this.month.validate this.validate.bind(this);
        
this.year.addClassName('validate-custom');
        
this.year.validate this.validate.bind(this);

        
this.year.setAttribute('autocomplete','off');

        
this.advice.hide();
    
},
    
validate: function() {
        
var error false;
        if (
this.day.value=='' && this.month.value=='' && this.year.value==''{
            
if (this.required{
                error 
'<?php echo $this->__('Das Datum ist eine ben&ouml;tigte Angabe.');?>';
            
else {
                this
.full.value '';
            
}
        } 
else if (this.day.value=='' || this.month.value=='' || this.year.value==''{
            error 
'<?php echo $this->__('Please enter a valid full date.');?>';
        
else {
            
var date = new Date();
            if (
this.day.value<|| this.day.value>31{
                error 
'<?php echo $this->__('Please enter a valid day (1-31).');?>';
            
else if (this.month.value<|| this.month.value>12{
                error 
'<?php echo $this->__('Please enter a valid month (1-12).');?>';
            
else if (this.year.value<1900 || this.year.value>date.getFullYear()) {
                error 
'<?php echo $this->__('Please enter a valid year (1900-2010).');?>';
            
else {
                this
.full.value this.format.replace(/(%m|%b)/ithis.month.value).replace(/(%d|%e)/ithis.day.value).replace(/%y/ithis.year.value);
                var 
testFull this.month.value '/' this.day.value '/'this.year.value;
                var 
test = new Date(testFull);
                if (
isNaN(test)) {
                    error 
'Please enter a valid date.';
                
}
            }
        }

        
if (error !== false{
            
try {
                this
.advice.innerHTML Translator.translate(error);
            
}
            
catch (e{
                this
.advice.innerHTML error;
            
}
            this
.advice.show();
            return 
false;
        
}
        
        
// fixing elements class
        
this.day.removeClassName('validation-failed');
        
this.month.removeClassName('validation-failed');
        
this.year.removeClassName('validation-failed');
        
        
this.advice.hide();
        return 
true;
    
}
}
;
Varien.DOB = Class.create();Varien.DOB.prototype {
    initialize
: function(selectorrequiredformat{
        
var el = $$(selector)[0];
        var 
container       {};
        
container.day       Element.select(el'.dob-day input')[0];
        
container.month     Element.select(el'.dob-month input')[0];
        
container.year      Element.select(el'.dob-year input')[0];
        
container.full      Element.select(el'.dob-full input')[0];
        
container.advice    Element.select(el'.validation-advice')[0];
        
        new 
Varien.DateElement('container'containerrequiredformat);
    
}
}
;//--></script>



and enjoy............

Friday, May 20, 2011

DOB select boxes on Magento customer registration form

<?php echo $this->getLayout()->createBlock('customer/widget_dob')
   ->setDate($this->getCustomer()->getDob())
   ->toHtml() ?>

For checkout/onepage/billing.phtml:

<?php echo $this->getLayout()->createBlock('customer/widget_dob')
   ->setDate($this->getCustomer()->getDob())
   ->setFieldIdFormat('billing:%s')
   ->setFieldNameFormat('billing[%s]')
   ->toHtml() ?>

NOTE: Regarding styles - if we leave it this way, we'll move it to boxes.css
      Alternatively we could calculate widths automatically using block input parameters.
*/

/**
 * @see Mage_Customer_Block_Widget_Dob
 */
?>
<label for="<?php echo $this->getFieldId('month')?>"<?php if ($this->isRequired()) echo ' class="required"' ?>><?php if ($this->isRequired()) echo '<em>*</em>' ?><?php echo $this->__('Date of Birth') ?></label>
<div class="input-box customer-dob">
<?php
    $this->setDateInput('d',
        '<div class="dob-day">
             <input type="text" id="' . $this->getFieldId('day') . '" name="' . $this->getFieldName('day') . '" value="' . $this->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" ' . $this->getFieldParams() . '  />
             <label for="' . $this->getFieldId('day') . '">' . $this->__('DD') . '</label>
         </div>'
    );?>
<select name="nday" id="nday" onchange="getElementById(<?php echo $this->getFieldId('day');?>).value=this.value" style="width:90px;">
<option value="">Select</option>
<?php
for($i=1;$i<=31;$i++)
{
echo "<option value='".$i."'>".$i."</option>";
}
?>
</select>
<select name="nmon" id="nmon" onchange="getElementById(<?php echo $this->getFieldId('month');?>).value=this.value" style="width:90px;">
<option value=''>Select</option>
<?php echo '<option value="">'.$this->__("Select").'</option>'.'<option value="01">'.$this->__("January").'</option>'.'<option value="02">'.$this->__("February").'</option>'.'<option value="03">'.$this->__("March").'</option>'.'<option value="04">'.$this->__("April").'</option>'.'<option value="05">'.$this->__("May").'</option>'.'<option value="06">'.$this->__("June").'</option>'.'<option value="07">'.$this->__("July").'</option>'.'<option value="08">'.$this->__("August").'</option>'.'<option value="09">'.$this->__("September").'</option>'.'<option value="10">'.$this->__("October").'</option>'.'<option value="11">'.$this->__("November").'</option>'.'<option value="12">'.$this->__("December").'</option>'; ?>
</select>
<select name="nyear" id="nyear" onchange="getElementById(<?php echo $this->getFieldId('year'); ?>).value=this.value" style="width:90px;">
<option value="">Select</option>
<?php
for($j=date('Y')-80;$j<=date('Y');$j++)
{
echo "<option value='".$j."'>".$j."</option>";
}
?>
</select>
</p>
<?php
    $this->setDateInput('m',
        '<div class="dob-month">
             <input type="text" id="' . $this->getFieldId('month') . '" name="' . $this->getFieldName('month') . '" value="' . $this->getMonth()  . '" title="' . $this->__('Month')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . '/>
             <label for="' . $this->getFieldId('month') . '">' . $this->__('MM')  . '</label>
         </div>'
    );

    $this->setDateInput('y',
        '<div class="dob-year">
             <input type="text" id="' . $this->getFieldId('year') . '" name="' . $this->getFieldName('year') . '" value="' . $this->getYear()  . '" title="' . $this->__('Year')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . ' />
             <label for="' . $this->getFieldId('year') . '">' . $this->__('YYYY')  . '</label>
         </div>'
    );
?>
 <?php echo $this->getSortedDateInputs() ?>
    <div class="dob-full" style="display:none;">
        <input type="hidden" id="<?php echo $this->getFieldId('dob')?>" name="<?php echo $this->getFieldName('dob')?>" />
    </div>

    <div class="validation-advice" style="display:none;"></div>
</div>
<script type="text/javascript">
//<![CDATA[
    var customer_dob = new Varien.DOB('.customer-dob', <?php echo $this->isRequired() ? 'true' : 'false' ?>, '<?php echo $this->getDateFormat() ?>');
//]]>
</script>



Friday, May 6, 2011

how to show product's more review images in main zoom frame in magento


replace the following line of code in ..../template/catalog/view/media.phtml
<li>
<a href="#" onclick="popWin(’<?php echo $this->getGalleryUrl($_image) ?>’, ‘gallery’, ‘width=200,height=200,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes’); return false;” title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>” width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>” /></a>
</li>
to
<li>
<a href="[removed]void(0)" onclick=’document.getElementById("image").setAttribute("src","<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(256); ?>")’ title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>” width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>” /></a>
</li>
and enjoy....