Dec
02
To check in a smarty template if it was the last page of the page results

Here’s a method to check in a smarty template if it was the last page of page results.

{if $listings.current_page gte ($listings.total / $results_per_page)|ceil}
    True
{else}
    False
{/if}

where $listings.current_page is the current page user is on, $listings.total is the number of totals results and $results_per_page is the number of listings or rows that are displayed on each page. “gte” is >= operator and |ceil as the mathematical modifier which returns next lowest integer.

Tags : , ,

Nov
28
Formatting date in a php smarty template

The date string can be formatted in a smarty template like this:

$payment.creation_date|date_format:"%d-%m-%Y"

where creation_date is an element of $payment array.

Tags :

Nov
27
New features in Gmail

New features in GmailGmail new look at a glance

(I should have had it posted about 15-20 days ago but could not post due to break from office for some other personal stuff. Posting it as it is now (although it is not a complete list of new features in new look and feel of gmail))

Gmail presented a whole new ‘clean’ look yesterday(that day). Here are few things i noticed at a cursory look and thus liked (merely unliked anything) many of them. I hope you also like them. Click to continue »

Tags : , , ,

Nov
27
An advanced HTML to PDF conversion using ezpdf php class

Posting a link to the working example of HTML Form to PDF using “ezpdf” php class. I added some code to this class in order to create more advanced HTML tables cells with borders as shown in the output PDF document. Click to continue »

Tags : , ,

Nov
23
jQuery way to limit input characters using javascript substring function

It’s an example of useful jQuery way to limit user entering a maximum set number of character in your input fields. Example makes use of javascript substring function to limit user upto 20 character which is triggered on keyup event. It truncate anything extra to that limit.

$("input[name=Title]").keyup(function(){
		var text = $(this).val();
		if(text.length > 20) {
			text = text.substring(0, 20);
			$(this).val(text);
		}
	})

Oct
30
Getting a way around the “No protocol specified, …cannot open display:0.0″ message

After doing sudo su - (to give myself root privileges) when I tried editing a file using gedit info.txt it would show me the following error message: Click to continue »

Tags : , , ,

Oct
29
How to get current theme name or theme working in cakephp

Making theme set and available by setting theme related properties in controller

Prior to cakephp 2.0

class UserController extends AppController {
    var $view = 'Theme'; //tells controller to use "ThemeView" class instead of the default "View" class
    var $theme = 'WhiteFeather'; //name of the theme folder which is supposed to be placed at views/themed/
}

Cakephp 2.0

class UserController extends AppController {
    public $viewClass = 'Theme'; //tells controller to use "ThemeView" class instead of the default "View" class
    public $theme = 'WhiteFeather'; //name of the theme folder which is supposed to be placed at View/Themed
}

Theme can be changed within a controller function or in beforeFilter/beforeRender by overriding the theme property:

$this->theme = 'BlackFeather';

You may want to know more about themes, here:
CakePHP 1.3 link http://book.cakephp.org/view/1093/Themes
Cakephp 2.0 documentation http://book.cakephp.org/2.0/en/views/themes.html

Tags : ,

Oct
28
Get post thumbnail out side of the Loop in wordpress

Just got a way to get the post thumbnail outside of the Loop which (the thumbnail) was entered through the Post Image > Set the URL for an image/icon for this post: field on Edit Post page. Here it is.

$thumb = get_post_meta($post->ID,'_rs_icon',false);
$thumb = $thumb[0];

Tags : , ,

Oct
18
Conditional skip for a field from model validation in a cakephp controller

In a controller, a table field could be skipped from model validations by editing the “validate” property of a model. For example, i have a “date” validation for “dob” (date of birth) field set in my “User” model. Click to continue »

Tags : , , ,

Oct
18
A note on $form->dateTime(‘field_name’) generating offset warning in CakePHP

This is a note on $form->dateTime(‘field_name’) generating offset warning i.e. “Notice (8): Undefined offset: 1 [CORE/cake/libs/view/helpers/form.php, line 1836..“. If your “date” form field in a view is generating a similar warning you may need to look into the following scenario. Click to continue »

Tags : , ,

Freelance Jobs