Posts

Showing posts from June, 2015

Getting data from post array using codeigniter

You are referencing the input name wrong. You need to change the line $std_id = $this->input->post("std_id[]",true); With: $std_id = $this->input->post("std_id",true);

Get model query in helper codeigniter

First, you need a reference to your CI instance:
$CI =& get_instance();
Then, if you need to load the model you can do it like so:
$CI->load->model('model_name');
And finally call any function in your model like this:
$CI->model_name->function_name();

Example:

function helper_function()
{
$ci=& get_instance();
$ci->load->model('creator_model'); 
$res = $ci->creator_model->getDetails();
// do anything
}

Add dynamic body class and id of OpenCart pages

go to YourTheme/header.tpl
and search for <body> tag
and replace the above tag with this code:

<body <?php 
               if(isset($this->request->get['route'])){
                  $class     = explode('/',$this->request->get['route']);
                  $id     = 'p'.$class[1];
                  $class     = 'p'.implode(' ',array_splice($class,1));
                  $class    .= ' class-'.str_replace('/','-',$this->request->get['route']);
                  if(isset($this->request->get['path'])){
                     $this->load->model('catalog/category');
                     $cats     = explode('_',$this->request->get['path']);
                     $cats    = !is_array($cats)? array($cats) : $cats;
                     foreach($cats as $cat){
                        $model    = $this->model_catalog_category->getCategory($cat);
      …

List of True 16:9 Resolutions

In an effort to enhance the knowledge of the video-making community, I have compiled a list of all true 16:9 video resolutions, including their associated standard when applicable, as well as when the resolution is divisible by 8, which is useful for limited video encoders. The table goes up to 1080p and includes common resolutions like that of a typical 27 inch 16:9 computer monitor and Super Hi-Vision.

WidthHeightStandardDivisible by 8169

3218

4827

6436

8045

9654

11263

12872
Yes14481

16090

17699

192108

208117

224126

240135

256144
Yes272153

288162

304171

320180

336189

352198

368207

384216
Yes400225

416234

432243

448252

464261

480270

496279

512288
Yes528297

544306

560315

576324

592333

608342

624351

640360
Yes656369

672378

688387

704396

720405

736414

752423

768432
Yes784441

800450

816459

832468

848477

864486

880495

896504
Yes912513

928522

944531

960540

976549

992558

1008567

1024576
Yes1040585

1056594

1072603

1088612

1104621

1120630

1136639

1152648
Yes1168657

1184666

1200675

1216684

1232693

1248702

1264711

1280720720p HDYes1296729

1312738

1328747

1344756

1360765

13…

Save a Base64 Encoded Canvas image to a png file using PHP

<?php // requires php5define('UPLOAD_DIR', 'images/');$img=$_POST['img'];$img=str_replace('data:image/png;base64,', '', $img);$img=str_replace('', '+', $img);$data=base64_decode($img);$file=UPLOAD_DIR.uniqid() .'.png';$success=file_put_contents($file, $data);print$success ? $file : 'Unable to save the file.';?>

Remove Controller Name From URL in CodeIgniter

Here is a way to remove the default controllernamefrom the URLS

Say you have a default controller (home in our case), your URLs will be of this format

You can now use these URLS

Code:
http://website.com/
http://website.com/aboutus
http://website.com/contact
http://website.com/faq
http://website.com/resources
Another solution would be by exclusion e.g.
In your application/config/routes.php file, just set each page like this:


$route['^(?!users|blog|controller3|controller4).*'] = "home/$0";

how to bring live magento site to localhost?

Copy your LIVE Magento site to your Local computer:
Download the magento files using any ftp client.Export the database from live server.Put the downloaded Magento files in your localhost root folder.Create a blank database(lets say it 'local-database') in your local computer and import the database backup that you exported from the live one.Delete/Rename the file app/etc/local.xmlRe-install the Magento using the local-database.After installation, go to Admin section and then (i)Flush all cache. (ii)Re-Index all data. (iii)Flush all cache. That's it. You are done.See another way please visit:

How to check if CURL is enabled on your server?

cURL is a useful PHP library that allows you to connect to servers using a variety of different protocols. These include HTTP,FTP, LDAP and HTTPs.

function _is_curl_installed() {
    if  (in_array  ('curl', get_loaded_extensions())) {
            return true;
        }
        else {
            return false;
        }
    }

    if (_is_curl_installed())
    {
          echo "cURL is <span style='color:blue'>installed</span> on this server";   
    } else {
          echo "cURL is NOT <span style='color:red'>installed</span> on this server";
    }



An alternative is to use this script :

<?php phpinfo(); ?>

Get Am/PM from a datetime in php

$DateTime ='2015-06-05 13:59:30'; $newDateTime = date('m/d/Y - h:iA', strtotime($DateTime ));Result:06/05/2015 - 01:59PM $date ='08/04/2015 22:15:00'; echo date('h:i A', strtotime($date));Result: 10:15 PM

Stop video playing when Bootstrap modal is closed

If you add a video to a Bootstrap Modal and either dismiss or close the modal whilst the video is playing the video will keep on playing. You can adjust this behaviour by adding in some Bootstrap javascript/jQuery that acts to stop the video if either the modal window is either clicked to close or the background is clicked to dismiss the modal.
Javascript//Stop Video <script> jQuery('#myModal1').on('hidden.bs.modal', function (e) { // do something... jQuery('#myModal1video').attr("src", jQuery("#myModal1video").attr("src")); }); </script> So change to your modal ID and change your HTML element, here I am using video , but iframe will also be commonplace.

Youtube Video Still Playing When Bootstrap Modal Close

Here's a little bit lighter of an answer based on dizarter's version and
one of the solutions he links to.
$('#modal-video').on('hidden.bs.modal',function(){ $("#modal-video iframe").attr("src", $("#modal-video iframe").attr("src"));});