Custom Camel Case by jquery

Problem:some times name field in camel case and also first letter in each word is big like 200% or any custom size.

then the below program can help to do that.

solve:

$(document).ready(function(){

var words = $(‘#user-name’).text().split(‘ ‘);

var html = ”;

$.each(words, function() {

html+='[span_style=”font-size:custom-px;”]’+this.substring(0,1)+'[/span]’+'[span_style=”font-size:custom-px;”]’+this.substring(1)+'[/span]’+ ‘ ‘;

});

html=html+'[span_style=”font-size:custom-px;”]’+”‘s”+'[/span]’;

$(‘#user-name’).html(html);

});

The actual code is given in following picture :

Custom Camel Case

Pagination with database

In your controller make method like below:
note: Here i am creating a pagination with a date between query, so keep clam and read.


public function fn_name(){
        $fdate=$this->uri->segment(3); //getting date from url
        $tdate=$this->uri->segment(4);
        if($fdate!=”” && $tdate!=””){
            $config[“base_url”]=base_url().’controller/method/’.$fdate.’/’.$tdate;
            $config[“total_rows”]=$this->Model->total_row_fn_name($fdate,$tdate);
            $config[“per_page”] = 6;
            $config[“uri_segment”] = 5;
            $choice = $config[“total_rows”] / $config[“per_page”];
            $config[“num_links”] = round($choice);
            $this->pagination->initialize($config);
            $page = ($this->uri->segment(5)) ? $this->uri->segment(5) : 0;
            $result[“data”] = $this->Model->method_Bydate($config[“per_page”],$page,$fdate,$tdate);
            $result[‘pagination_link’]=$this->pagination->create_links();
        }
        $this->load->view(‘pages/slip_report’,$result);

    }

In your model make a method:


public function total_row_fn_name($fdate,$tdate){
        $sql=$this->db->select(‘put your database field to select here’)
            ->join(‘tbl name’,’table.field=tbl.field’,’left’)
            ->join(‘tbl’,’tbl.field=tbl.field’,’left’)
            ->where(‘DATE(chalan_date) >=’,date(‘Y-m-d’,strtotime($fdate)))
            ->where(‘DATE(chalan_date) <=’,date(‘Y-m-d’,strtotime($tdate)))
            ->order_by(‘tbl.field’)
            ->get(‘tbl’);
        return $sql->num_rows();
    }

public function method_Bydate($limit,$start,$fdate,$tdate){
        $sql=$this->db->select(‘ your fields goes here’)
            ->join(‘tbl’,’tbl.field=tbl.field’,’left’)
            ->join(‘tbl’,’tbl.field=tbl.field’,’left’)
            ->where(‘DATE(date_field) >=’,date(‘Y-m-d’,strtotime($fdate)))
            ->where(‘DATE(date_field) <=’,date(‘Y-m-d’,strtotime($tdate)))
            ->order_by(‘field’)
            ->limit($limit,$start)
            ->get(‘dailycirculation’);
        //echo $this->db->last_query();
        return $sql->result_array();
    }

In your view invoke this pagination like below:


<?php echo $pagination_link;?>

Create new user type in gocart

first go to views -> admin -> admin_forms.php file.

go to near this lines: ‘Admin’, ‘Orders’ => ‘Orders’, ‘Software_op’=>’Software Operator’ );

echo form_dropdown(‘access’, $options, set_value(‘phone’, $access)); ?>

* after adding your user like mine, i have added software operator. you will see in this list in your admin panel.

—————————————————————————–

Now you have do some Auth works in your header.php file and those pages you want to restrict.

like here my software operator will see only catalog’s categories and products pages in their admin panel.

in dashboard.php file comment these below lines:

// if($this->auth->check_access(‘Orders’)){

// redirect($this->config->item(‘admin_folder’).’/orders’);

// }

Now go to categories.php controller file and add these lines:

$this->CI =& get_instance();

$admin = $this->CI->session->userdata(‘admin’);

$access=$admin[‘access’];

//$this->auth->check_access(‘Admin’, true);

$this->auth->check_access($access, true);

*** note: you must comment this line on your controller file:

//$this->auth->check_access(‘Admin’, true);

You are done!

Search query [multiple where condition in a tiny code]

codeigniter search query [multiple where condition in a tiny code] *return single row
in controller:
$wc=array(
         ‘table_field1’  =>  $where_value,
         ‘table_field2’  =>  $where_value
); //whatever conditions you can apply here



$product_price=$this->Model->getTableData(‘wp_postmeta’,$wc,’field_name’);


in model:
public function getTableData($tableName,$whereCondition,$tableField){
        $query = $this->db->get_where($tableName,$whereCondition);    
              $res=$query->row_array();
              return $res[$tableField];

    }


——————————————————————————————————
codeigniter search query [multiple where condition in a tiny code] *return multi row
in controller:
$wc=array(
         ‘table_field1’  =>  $where_value,
         ‘table_field2’  =>  $where_value
); //whatever conditions you can apply here



$product_price=$this->Model->getTableData(‘wp_postmeta’,$wc);


in model:
public function getTableData($tableName,$whereCondition){
        $query = $this->db->get_where($tableName,$whereCondition);        
              $res=$query->result_array();
              return $res;

    }

Change url by JavaScript

// set new url

var str = jQuery( ‘#csv-dl-link’ ).attr( ‘href’ ); // getting the url
var res = str.split( “/” ); // spliting / exploding the url
var new_url = ”;

for ( var i = 0; i < res.length - 1; i++ ) { // concatenating new url new_url = new_url + res[ i ] + '/'; } new_url = new_url + 'anything you want to add here for you url'; jQuery( '#csv-dl-link' ).attr( 'href', new_url ); // replacing the url happy coding!

How to add widget in wordpress

go to theme directory then open function.php file then find function function twentyeleven_widgets_init()
add following code inside it:
register_sidebar( array(
‘name’ => __( ‘Main Sidebar’, ‘twentyeleven’ ),
‘id’ => ‘sidebar-1’,
‘before_widget’ => ‘

“,
‘before_title’ => ‘

‘,
‘after_title’ => ‘

‘,
) );

then call it by following code:
if(is_active_sidebar(f-1)):?>

Upload images to custom folder in wordpress

upload images to custom folder in wordpress

* in your functions.php file put the below code:
*** here you can change the uploads_img folder name to anything

function ashique_custom_image_dir( $pathdata ) {
$subdir = ‘/uploads_img’.$pathdata[‘subdir’];
$pathdata[‘path’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘path’]);
$pathdata[‘url’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘url’]);
$pathdata[‘subdir’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘subdir’]);
return $pathdata;
}

add_filter( ‘upload_dir’, ‘ashique_custom_image_dir’ );

WordPress word cutter

<?php $project_page_id=get_page_by_path('interior-decoration')->ID;?>
<?php echo get_the_title($project_page_id);?>

<?php $fcon=get_post($project_page_id)->post_content; //echo substr($fcon,0,100);
$words = explode(" ", $fcon);
$first = join(" ", array_slice($words, 0, 17));
echo $first;
?>

<a class="fprmore" href="<?php echo get_page_link($project_page_id);?>">Read More</a>