Saturday, 9 November 2013

How to create file selection element in Zend Framework?

// creating object for Zend_Form_Element_File
$doc_file = new Zend_Form_Element_File('doc_file');

$doc_file->setLabel('Image')
     ->setMaxFileSize('512000')
     ->addValidator('Count', true, 1)
     ->addValidator('Size', true, 512000)
->setRequired(true)
     ->addValidator('Extension', true, 'jpg,jpeg,png,gif');

$doc_file->getValidator('Count')->setMessage('You can upload only one file');
$doc_file->getValidator('Size')->setMessage('Your file size cannot upload file size limit of 512 kb');
$doc_file->getValidator('Extension')->setMessage('Invalid file extension, only valid image with file format jpg, jpeg, png and gif are allowed.');

How to create selection box element in Zend Framework?

$required = new Zend_Validate_NotEmpty ();
$required->setType ($required->getType() | Zend_Validate_NotEmpty::INTEGER | Zend_Validate_NotEmpty::ZERO);

$country = $this->createElement('select','country');
$country->setLabel('Country')
->addValidator($required);

$country->setErrorMessages(array(
'isEmpty'=>'You should must select your country.'
));

$country->addMultioptions(array(

'0'=>'select',

'india' => 'India',

'sri lanka' => 'Sri Lanka',

'usa' => 'USA',

'pakistan' => 'Pakistan'

));

How to create password box element in Zend Framework?

 $password = new Zend_Form_Element_Password('password');
$password->setLabel('Password:')
            ->addValidator('StringLength', false, array(1,24))
            ->setLabel('Choose your password:')
            ->setRequired(true);

How to create multiple checkbox element in Zend Framework?


$hobbies = new Zend_Form_Element_MultiCheckbox('hobbies[]', array(
    'multiOptions' => array(
        'cricket' => 'Cricket',
        'singing' => 'Singing',
        'cycling' => 'Cycling',
        'swimming' => 'Swimming',
    )
))

$hobbies->setLabel('Hobbies');;

How to create radio button element in Zend Framework?

$gender = new Zend_Form_Element_Radio('gender');
$gender->setLabel('Gender')
->setRequired(true)->setErrorMessages(array(
'isEmpty'=>'You should must select your gender.'
))
->setRequired(true)
->addMultiOptions(array(
'male' => 'Male',
'female' => 'Female'
));

How to create textbox element in Zend Framework?

$artist = new Zend_Form_Element_Text('artist');
        $artist->setLabel('Artist')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty')
  ->setErrorMessages(array(
'isEmpty'=>'You should must enter your First Name.'
));

Tuesday, 1 October 2013

How to repair wordpress database of a particular website?

To allow use of repair page to automatically repair database problems, please add the following line to your wp-config.php file. 
define('WP_ALLOW_REPAIR', true);
Once this line is added to your config, open the following URL...
http://localhost/sofee/wp-admin/maint/repair.php

When repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.
define('WP_ALLOW_REPAIR', true);

Thursday, 26 September 2013

Control Excerpt Length using Filters

By default, excerpt length is set to 55 words. To change excerpt length using excerpt_length filter, add the following code to functions.php file in your theme:


function new_excerpt_length($length) {
 return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

Saturday, 21 September 2013

How to take backup(project & database) from XAMPP?

We can take database backup from 

C:\xampp\mysql\data Directory

and code from 

c:\xampp\htdocs

then reinstall xampp.

Tuesday, 23 July 2013

How to call our custom sidebar on the required position?


Go to 
<a> wp-admin folder.
<b> themes.
<c> select your current theme.
<d> Open required file such as 'header.php', 'footer.php', index.php',
           'page.php' or any custom page template and paste the following code
in the required container such as <div>, <span> etc. and pase the following code.
<e> Here 'copy_right' is the id of the custom sidebar.

<?php dynamic_sidebar('copy_right'); ?>

How to create our custom sidebar?


Go to 
<a> Wordpress admin panel.
<b> Appearance.
<c> Editor.
<d> Open config.php file from 'Themes Functions' section.
<e> Append the following code in 'functions.php' file...
<f> Here sidebar 'id'='copy_right' which is used to call it on the required
                                position and 'name' => __( 'Footer Copy Right', 'twentyeleven' ) 
                                which is display in admin panel widget area.

function twentyeleven_widgets_init() 
{
register_sidebar( array(
'name' => __( 'Footer Copy Right', 'twentyeleven' ),
'id' => 'copy_right',
'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'twentyeleven_widgets_init' );

How calulation total value for HTML input text?

<script> $j(document).ready(function(){ $j(":text").keyup(function(){ if (isNaN($j(this).val())) { alert(...