May
13
2014

Show Limit Words from a String

<?php

function getWords($string, $no_of_words){
$words = explode(” “,$string);
return implode(” “,array_splice($words,0,$no_of_words));
}

/*  Example Usage */

$string = “Life insurance plans offer you security after you die or on maturity, but what happens if you do not die and are instead saddled with some kind of disability?  A sudden paralytic attack may not leave you dead but certainly restrict your ability to function normally. What to do in a situation when you are unable to work but still need funds to run your home and even fund your treatment expenses?  Such situations are covered by specialized insurance plans for critical illnesses. “;

echo getWords($string,25);

?>

Apr
25
2014

Calculate Age With JavaScript

var dateString = “10/25/1999″; (mm/dd/yyyy)
var age = getAge(dateString);

function getAge(dateString) {

var now = new Date();
var today = new Date(now.getYear(),now.getMonth(),now.getDate());

var fullyear = now.getFullYear();
var yearNow = fullyear – 1900;
var monthNow = now.getMonth();
var dateNow = now.getDate();

var dob = new Date(dateString.substring(6,10),
dateString.substring(0,2)-1,
dateString.substring(3,5)
);

var fullyeardob = dob.getFullYear();
var yearDob = fullyeardob – 1900;
var monthDob = dob.getMonth();
var dateDob = dob.getDate();

var age = {};
var ageString = “”;
var yearString = “”;
var monthString = “”;
var dayString = “”;
var yearAge = “”;

yearAge = yearNow – yearDob;

if (monthNow >= monthDob)
var monthAge = monthNow – monthDob;
else {
yearAge–;
var monthAge = 12 + monthNow -monthDob;
}

if (dateNow >= dateDob)
var dateAge = dateNow – dateDob;
else {
monthAge–;
var dateAge = 31 + dateNow – dateDob;

if (monthAge 1 ) yearString = ” years”;
else yearString = ” year”;
if ( age.months> 1 ) monthString = ” months”;
else monthString = ” month”;
if ( age.days > 1 ) dayString = ” days”;
else dayString = ” day”;

//alert(age.years+’ ‘+age.months+’ ‘+age.days);

if ( (age.years > 0) && (age.months > 0) && (age.days > 0) )
ageString = age.years + yearString;
else if ( (age.years == 0) && (age.months == 0) && (age.days > 0) )
ageString = age.days + dayString;
else if ( (age.years > 0) && (age.months == 0) && (age.days == 0) )
ageString = age.years + yearString;
else if ( (age.years > 0) && (age.months > 0) && (age.days == 0) )
ageString = age.years + yearString;
else if ( (age.years == 0) && (age.months > 0) && (age.days > 0) )
ageString = age.months + monthString;
else if ( (age.years > 0) && (age.months == 0) && (age.days > 0) )
ageString = age.years + yearString;
else if ( (age.years == 0) && (age.months > 0) && (age.days == 0) )
ageString = age.months + monthString;
else
ageString = “Oops! Could not calculate age!”;

return ageString;
}

Apr
25
2014

Enabling Gzip with .Htaccess

#Gzip Start
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip

Sep
23
2013

Drupal theme Structure

Overview of theme files – A theme is a collection of files that define the presentation layer.

theme7_anatomy
.info (Required file)
Only the .info file is required. The internal name of the theme is also derived from this file. For example, if it is named “drop.info”, then Drupal will see the name of the theme as “drop”.

.tpl.php (Template File)
These templates are used for the HTML markup and PHP variables. Each .tpl.php file handles the output of a specific themable chunk of data, and in some situations it can handle multiple .tpl.php files

template.php
For all the conditional logic and data processing of the output, there is the template.php file. This file must start with a PHP opening tag “<?php”, but the close tag is not needed
Here’s a list of the core TPL files. There are many more TPL files but these are the most used ones.

html.tpl.php
page.tpl.php
region.tpl.php
block.tpl.php
node.tpl.php
comment-wrapper.tpl.php
comment.tpl.php
field.tpl.php

Apr
30
2013

Configure Idle Time-out Settings for an Application Pool (IIS 7)

To configure idle time-out settings for an application pool


You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.

  1. Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
  2. In the Connections pane, expand the server node and click Application Pools.
  3. On the Application Pools page, select the application pool for which you want to specify idle time-out settings, and then click Advanced Settings in the Actions pane.
  4. In the Idle Time-out (minutes) box, type a number of minutes, and then click OK.

To configure the idle time-out value for an application pool, use the following syntax:

appcmd set config /section:applicationPools /[name=' string '].processModel.idleTimeout: timeSpan

where string is the name of the application pool that you want to configure. The variable timeSpan is the period of time at which the worker process or processes in the application pool are considered idle. The format for timeSpan is d.hh:mm:ss where d is the optional number of days, and hh:mm:ss is the number of hours, minutes, and seconds at which to shut down the worker process. For example, to set the idle time-out value to 30 minutes for an application pool named Marketing, type the following at the command prompt, and then press ENTER:

appcmd set config /section:applicationPools /[name=' Marketing '].processModel.idleTimeout:0.00:30:00

For more information about Appcmd.exe, see Appcmd.exe (IIS 7).

The procedure in this topic affects the following configuration elements:

idleTimeout attribute of the <processModel> element under <add> under <applicationPools>

For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.

Use the following WMI classes, methods, or properties to perform this procedure:

  • ApplicationPool.ProcessModel.IdleTimeout property
Apr
12
2013

Send Newsletter through SendGrid in Drupal 7

Newsletter Configuration

Simplenews Module – Simplenews publishes and sends newsletters to lists of subscribers. Both anonymous and authenticated users can opt-in to different mailing lists. HTML email can be sent by adding Mime Mail module.

  • Step to Newsletter Configuration
  • Download Simplenews module from http://drupal.org/project/simplenews
  • Activate Simplenews module
  • After activation of simplenews a content type will be created with name “simplenews” and vocablury will be created with name “Newsletter”, now you can create content as simplenews and different taxonomy can be create under “Newsletter” to categorise your newsletter
  • Configure newsletter from admin/config/services/simplenews
  • There will be list of taxonomy which you created to categorize your newsletter, can be edit there settings.
  • Set default newsletter options from admin/config/services/simplenews/settings
  • Set no of mail to sent on running of cron admin/config/services/simplenews/settings/mail
  • Manage subscriber list admin/people/simplenews (There will be list of all subscriber)
  • Mass subscribe option admin/people/simplenews/import (put a list of email address and select taxonomy then all the newsletter of that category will be subscribe to that email list)
  • Mass unsubscribe from admin/people/simplenews/unsubscribe (put a list of email address to unsubscribe)
  • Set cron running time according to your requirement from admin/config/system/cron (mail will be send on cron running)

To send mail in HTML Format use Mime Mail – It permits users to receive HTML email . The mail functionality accepts HTML message body

  • Download Mime Mail from http://drupal.org/project/mimemail
  • Activate Mime Mail module
  • Configure Mime Mail from admin/config/system/mimemail

Send Newsletter throught SendGrid

This module changes Drupal email sending behavior, sending them through SendGrid’s cloud-based email delivery services by using their Web API instead of SMTP Server.

Follow these step.

  • 1. Download SendGrid Integration module from http://drupal.org/project/sendgrid_integration
  • 2. Activate module SendGrid Integration
  • 3. Create account at http://sendgrid.com/ and configure your SendGrid Username and API-Key
  • Authentication Support module from http://drupal.org/project/smtp (The module supports SMTP authentication and can even connect to servers using SSL if supported by PHP)
  • 4. Download SMTP Authentication Support module from http://drupal.org/project/smtp
  • 5. Configure mailing process from admin/config/system/smtp (put your sendgrid detail)
  • 6. Configure mailong system from admin/config/system/mailsystem
  • 7. SmtpMailsystem from drop down list Site-wide default MailSystemInterface class
Apr
5
2013

BasicTutorial on .htaccess

Hypertext Access or htaccess is an Apache configuration web server configuration file. It is loaded by the server and allows you to significantly modify its behaviour by specifying redirects, turning features on and off or protecting special sections of your site. In a most literal way htaccess is simple a small text file with the filetype of .htaccess and no name.

Table of contents :

  • What is .htaccess?
  • How to use .htaccess?
  • Error documents
  • Redirects & Rewrites
  • Password protection
  • Deny visitors by IP address
  • DirectoryIndex uses
  • Adding MIME types
  • Activate Caching
  • Disable directory listings
  • Setting server timezone
  • Changing server signature
  • Preventing access to your PHP includes files
  • Prevent access to php.ini
  • Ensuring media files are downloaded instead of played
  • Setting up Associations for Encoded Files
  • Preventing requests with invalid characters
  • Regular Expressions
  • Useful Resources

For more details please find the PPT file

Mar
18
2013

How to upload a file inside ckEditor

We generally face problem when we need to add some pdf or xls or csv files inside a content. Here i am listing steps for solve this problem. Make sure you had installed ICME Module.
Step 1: Write some text in editor and select it

Step 2: Click on link icon for open option pop-up window.

link button-1
Step 3: Click on browse Server link.

link of browse server
Step 4: Select files from already uploaded file or upload new file.

upload file-3
Step 5: click on ok and closed the file pop-up window. Now file has been uploaded and you can see here as file as link.final

Mar
13
2013

Image upload With CKEditor by using IMCE module in Drupal 7

Image upload With CKEditor by using IMCE module in Drupal 7
Step to active image upload button with ckeditor in Drupal 7, we assume that ckeditor already working in your website.
1. Need to download IMCE module from http://drupal.org/project/imce
2. Upload IMCE module in sites/all/modules folder
3. Enable module from admin/modules (in Drupal 7) admin/build/modules (Drupal 6)
4. Now check configuration option Configuration->IMCE (/admin/config/media/imce) , if you have many roles then can set permission by default have permission for admin.
5. Now configure cKEditor go to Configuration->CKEditor (admin/config/content/ckeditor)
There is two Profiles by default in Drupal 7 now edit ‘Advanced’ profile.
6. Select ‘FILE BROWSER SETTINGS’ select ‘IMCE’ from File browser type drop down list
Now brows button will be activated with image uploading button in CKEditor

Step to active image upload button with ckeditor in Drupal 7, we assume that ckeditor already working in your website.

  1. Need to download IMCE module from http://drupal.org/project/imce
  2. Upload IMCE module in sites/all/modules folder
  3. Enable module from admin/modules (in Drupal 7) admin/build/modules (Drupal 6)
  4. Now check configuration option Configuration->IMCE (/admin/config/media/imce) , if you have many roles then can set permission by default have permission for admin.
  5. Now configure CKEditor go to Configuration->CKEditor (admin/config/content/ckeditor). There is two Profiles by default in Drupal 7 now edit ‘Advanced’ profile.
  6. Select ‘FILE BROWSER SETTINGS’ select ‘IMCE’ from File browser type drop down list

Now brows button will be activated with image uploading button in CKEditor

Mar
13
2013

How to set the default text format on Drupal 7 ?

In Drupal we have Filter HTML set as default text format. But most of the time we have to deliver project with Full HTML as default text format.
Here i am listing steps to set Full HTML as default text format:-
Step 1: Login with Admin permission
Step 2: Go to Configuration » Text Formats. It will list all the available text formats.
Step 3: Either drag-drop listed text formats as you want or click on Show Row weights and give them weight manually.
Step 4: Click on Save Changes Button and clear the site cache from performance.

Now you will get all text editors listed in order as you had set it

Pages:1234567»
iPage's new control panel makes it easier to update your site.