Friday, May 16, 2014

Cakephp Disable Behaviors

$this->Banner->Behaviors->disable('FileUpload');

Cakephp date, month and year dropdown

<div class="form-group">
                                    <label for="QualificationSchool" class="float_left">Date Attended</label>
                                    <?php
                                    echo $this->Form->input('month_val', array('class' => 'form-control left_month_box', 'dateFormat' => 'M', 'monthNames' => true, 'separator' => '&nbsp;', 'type' => 'date', 'label' => false, 'div' => false));
                                    echo $this->Form->input('year_val', array('class' => 'form-control right_year_box', 'dateFormat' => 'Y', 'separator' => '&nbsp;', 'minYear' => date('Y') - 70, 'maxYear' => date('Y', strtotime('+0 years')), 'type' => 'date', 'label' => false, 'div' => false));
                                    ?>
                                </div>

Friday, January 10, 2014

cakephp theme path

App::themePath('Front');

cakephp subdomain htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    # http|https www to non-www
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^(.*)$ http%1://domain.com/$1 [R=301,L]

    # redirect all subdomains
    RewriteCond %{HTTP_HOST} !^domain\.(.*)$ [NC]
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ /%{HTTP_HOST}/$1 [NC,L,NS]

    RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
    RewriteRule ^$ app/webroot/    [L]
    RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

/public_html/sub1.domain.com/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^/%{HTTP_HOST}
    RewriteRule ^%{HTTP_HOST}(.*)$ /$1

    RewriteCond %{HTTPS} on
    RewriteRule ^$ %{HTTP_HOST}/app/webroot/    [L]
    RewriteCond %{HTTPS} on
    RewriteRule (.*) %{HTTP_HOST}/app/webroot/$1 [L]

    RewriteRule ^$ app/webroot/    [L]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

/public_html/sub1.domain.com/app/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteRule ^$    webroot/    [L]
    RewriteRule (.*) webroot/$1    [L]
</IfModule>

/public_html/sub1.domain.com/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ %{HTTP_HOST}/index.php [QSA,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{HTTPS} !on
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

Tuesday, August 6, 2013

cakephp string truncate function

String::truncate(string $text, int $length=100, array $options)
 
Parameters:
  • $text (string) – The text to truncate.
  • $length (int) – The length to trim to.
  • $options (array) – An array of options to use.
Example:
// called as TextHelper
echo $this->Text->truncate(
    'The killer crept forward and tripped on the rug.',
    22,
    array(
        'ellipsis' => '...',
        'exact' => false
    )
);

// called as String
App::uses('String', 'Utility');
echo String::truncate(
    'The killer crept forward and tripped on the rug.',
    22,
    array(
        'ellipsis' => '...',
        'exact' => false
    )
);
 
Output:
The killer crept... 

Reference url: http://book.cakephp.org/

Get Google Maps v3 to resize height of InfoWindow

Js
var infowindow = new google.maps.InfoWindow({
                                 content: lng,
                                 maxWidth: 200
                            });

google.maps.event.addListener(marker, 'click', function() {       
        var $content = $('<div class="infobox">').html("content here");
        infowindow.setContent($content.get(0));
        infowindow.open(map, marker);
});

CSS

.infobox{
    padding-bottom: 30px;
}

Have just one InfoWindow open in Google Maps API v3

google.maps.event.addListener(someMarker, 'click', function() {
   infowindow.setContent('Hello World');
   infowindow.open(map, someMarker);
});