Friday, January 20, 2012

How to remove blank new line space in dreamweaver using regular expression

  1. >> open file
2. press Ctl+F
3. Choose regular expression select box in footer of search & replace window.
4. put "[\r\n]{2,}" in Find field
5. put "\n" in replace field
6 . press replace or replace all button.


Tuesday, January 10, 2012

How to show customer group selecter in registration form

Make a copy of config.xml from app > code > core > Mage > Customer > etc > config.xml and add the following line of code into the customer account fieldset and save it to app > code >local>config.xml and in this file add the following line of code into the customer account fieldset:


add code to the frontend of the store, in the registration form. Open template/customer/form/register.phtml and add the following code somewhere in the form:

<div class="input-box">
<label for="group_id"><?php echo $this->__('Group') ?><span class="required">*</span></label><br/>
<select name="group_id" id="group_id" title="<?php echo $this->__('Group') ?>" class="validate-group required-entry input-text" />
<?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
<?php foreach($groups as $group){ ?>
<option value="<?php print $group['value'] ?>"><?php print $group['label'] ?></option>
<?php } ?>

also change some code in app\code\core\Mage\Customer\controllers\AccountController.php now
replace $customer->getGroupId();

 { $customer->setGroupId($this->getRequest()->getPost('group_id'));
 } else {
$customer->getGroupId(); }


Thursday, January 5, 2012

PHP: Random password with numbers and letters

function genRandomString() {
    $length = 10;
    $characters = ’0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
    $string = ;    

    for ($p = 0$p < $length$p++) {
        $string .= $characters[mt_rand(0strlen($characters))];
    return $string;