Skip to main content

Posts

Difference between session.gc_maxlifetime and session.cookie_lifetime in Drupal setting.php

ini_set('session.gc_maxlifetime', 200000); This value is for the server. It is a settings for Session Garbage Collection. If the users last visit happened before 200000s then this session is eligible for garbage collection. Since it is GC, the session value may be discarded and not compulsory. If a GC action happens after the session was made eligible for the GC, it will be deleted. ini_set ( 'session.cookie_lifetime' , 2000000 ); This value is for the browser. This is the absolute maximum time till which a browser can keep this cookie active. A 0 value here means immediate or when the browser is closed. Source: 

Difference between webform vs entityform in Drupal 7

Drupal has a lot of modules aimed at helping site builders and users add forms to their sites. What follows is a rough comparison of 2 of them. If there are any I've missed, please add them. Webform Webform is a module designed to allow you to add custom forms to the front-end of your site. Each form is stored against a node, so you add new forms to your site as if you were adding content. It's useful for things like Survey websites or just where you want a couple of forms that differ from the standard contact form. Pros Webform has been around for a long time, its very well established and has a large number of modules that  integrate with it . Webform can make a wide variety of forms with lots of different elements available out of the box. Because Webforms are nodes, they inherit all the functionality that nodes have (scheduled publishing, cloning, access control, etc.). Webforms are lighter-weight and more scalable than entity-based forms. Can handle multiple-p...

Fatal error: Call to undefined function db_fetch_object in Drupal 7

db_fetch_object no longer in Drupal 7 Now its completely new database API has been added Drupal 7 introduces a completely new database API, utilizing a number of dynamic query builders and formal prepared statements. The following Drupal 6 functions and hooks were removed: db_affected_rows ( ), db_distinct_field ( ), db_error ( ),  db_last_insert_id ( ), db_placeholders ( ), db_lock_table ( ),  db_prefix_tables ( ), db_result ( ),  db_fetch_* ( ), db_version ( ), db_rewrite_sql ( ),  hook_db_rewrite_sql ( ), pager_query ( ), tablesort_sql ( ), and others. For full information, read the Database API guide.

Drupal 7 Menu Link update through update.php

This is for hook_update_N function If we have a default menu, use below code in install file. /**  * Implements hook_update_N to create menu reports.  */ function mymodule_update_7120 ( ) {   $menus = array (     'menu_name' => 'my_parent_menu',     ' title ' => 'My parent menu title',     ' description ' => 'My parent menu description',   );   $links = array (     'link_title' => 'My menu link title',     'link_path' => 'custom_path_for_menu_link',     'menu_name' => 'my_parent_menu',     ' weight ' => 0,     ' expanded ' => 0,   );   // Save menu group into menu_custom table   // Look the table first if the data does exist   $exists = db_query ( "SELECT title FROM {menu_custom} WHERE menu_name= : menu_name", array ( ' : menu_name' => $menus [ 'menu_name']) ) -> fetchField ( );   // Save the rec...

Set the default language in Notepad++

I am showing this for the PHP language. In Notepad++   Click on Settings -> Preferences   Click on the New Document tab   Change the Default Language to PHP See below inage   To add an extension to load PHP editor for different extensions.   Click on Settings -> Style Configurator   In Language scroll down to PHP and click it.   In below it will show default ext.     Add your extensions at user exit. (Don't need '.').       eg:  inc install module   Click on Save & Close See below image for reference.

CKFinder Installation in the CKEditor for Drupal 7 Module

Please follow the steps below;  Go to http://ckfinder.com/download and download CKfinder Unpack the contents of the installation package into the directory that contains the CKEditor module and place it in thesites/all/modules/ckeditor/ckfinder (or sites/all/libraries/ckfinder) folder. . When the files are unpacked, you should see the following file structure inside the drupal/sites/all/modules directory: Now open the CKFinder configuration file (ckfinder/config.php) and introduce the code changes described below. Firstly, remove the CheckAuthentication() function (do not worry, this function is defined in filemanager.config.php, see below): function CheckAuthentication()       <- remove it {                                    <- remove it    //WARNING : DO NOT simply...      <- remove it    ...        ...

Install cURL in Windows.

What is cURL? curl is a  curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP . curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other  useful tricks . How to install cURL? Open  http://curl.haxx.se/dlwiz?type=bin  in a browser. Select your operating system in the dropdown box: either Windows /Win32 or Win 64. Click Select! For Win 32, choose whether you will use curl in a Windows Command Prompt (Generic) or in a Cygwin terminal (cygwin). For Win 64, choose whether you will use curl in a Windows Command Prompt (Generic) or MinGW (MinGW64). Click Select! If required, choose your Windows operating sys...

Files that Drupal Themes Use

A drupal theme is a collection of files that define the presentation layer. You can also create one or more "sub-themes" or variations on a drupal theme. Only the .info file is required, but most themes and sub-themes will use other files as well. The following diagram illustrates the files that are found in a typical drupal theme and sub-theme. Drupal 6: Drupal 7: .info   (required) All that is required for Drupal to see your theme is a ".info" file. Should the theme require them, meta data, style sheets ,  JavaScripts ,  block regions  and more can be defined here. Everything else is optional in drupal theme. 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".  Drupal 5 and below used the name of the enclosing folder of the theme. Info files for themes are new in Drupal 6. In version 5, .info files were used solely for dru...

Drupal User, Permission, Role in Drupal

Every visitor to your  drupal  site, whether they have an account and log in or visit the site anonymously, is considered a  user   to Drupal. Each drupal user has a numeric user ID, and non-anonymous users also have a user name and an email address. Other information can also be associated with drupal users by modules; for instance, if you use the core  Profile Drupal module , you can define user profile fields to be associated with each drupal user. Anonymous drupal users have a user ID of zero (0). The drupal user with user ID one (1), which is the user account you create when you  install Drupal , is special: that user has permission to do absolutely everything on the site. Other users on your site can be assigned permissions via  roles . To do this, you first need to create a role, which you might call "Content editor" or "Member". Next, you will assign  permissions  to that role, to tell Drupal what that role can and can't do on t...

Basics of Regular expressions

Basic Syntax of Regular Expressions (as from PHPBuilder.com ) First of all, let's take a look at two special symbols: '^' and '$'. What they do is indicate the start and the end of a string, respectively, like this: "^The": matches any string that starts with "The"; "of despair$": matches a string that ends in the substring "of despair"; "^abc$": a string that starts and ends with "abc" -- that could only be "abc" itself! "notice": a string that has the text "notice" in it. You can see that if you don't use either of the two characters we mentioned, as in the last example, you're saying that the pattern may occur anywhere inside the string -- you're not "hooking" it to any of the edges. There are also the symbols '*', '+', and '?', which denote the number of times a character or a sequence of characters may occur. What they mean ...

Drupal 7 admin pages slow

So for some time I've been running Drupal 7 for my private webpage. It has been slow as hell on the admin pages. The "frontend" side works fast and without any slowdown. There are  others experiencing the same trouble . A lot of others it seems. For years I've been running Drupal now and it's only since I switched to version 7 that it started to have speed problems. It has a major slowdown on all admin pages. They take sometimes 30+ seconds to load and almost every admin page uses 10+ seconds. The high times cause PHP to throw an error (Maximum execution time of 30 seconds exceeded) that some function was running too long. I constantly got these errors on admin pages. It was barely usable. I had to reload pages multiple times (often 5+ times) to finally get them to show. Each time I had to wait till the timeout came. Furthermore the update.php page had the same problem. I couldn't update more than 2 modules for some time. Now I updated to ver...

Difference between SVN and GIT

A summary of Differences: 1. Git branches carry entire history. 2. Git was designed  to be fully distributed from start, allowing each developer to have full control. 3. Git’s repositories are much smaller than SVN’s. 4. Git repository clones acts as full repository backup. 5. Git is much faster than SubVersion Git’s major features Over Subversion(SVN) Distributed Nature: In Git, every has complete copy of repository data stored locally, there by making access to file history is fast, as well as allowing full functionality when disconnected to network. If you have 10 users, then you will have 10 backups of repositories . If any repository is lost then only the changes which were unique to that repository is lost. In centralized SVN, Only have central repository has a complete history. This means that user must communicate over a network with central repository to obtain the history about the file. backup are maintained independently of...

Optimize Drupal 7

Hi, There can be a number of approaches u can think of. I am listing some of those based on my recent experinces :  1. Try to have minimum no of tpl files in your theme folder. We should avoide writing separate tpl for each type of content or node  2. Try to include internal css & js files on at the apprpriate location under speific hooks or so, sothat those don't get loaded unnecessarily  3. Try to make use of modules like cache_external_files to load external js files from ur local system and get it updated on cron run  4. Write ur code under best possible drupal way, I mean say , if we can have some code be working under page preprocess , we shouldn't write it in hook_init.  5. can take help of sites like http://gtmetrix.com/ , newrelic to check the site performance & follow the suggestions they provide  6. Combine images using CSS sprites  7. Leverage browser caching  8. Enable gzip comp...

Smart pagination or page break in Drupal 7(CK editor)

1. Install Smart Paging module   Go to Administration › Configuration › Administer Smart Paging settings.   Under 'Default page break method', select "Manual placement of page break placeholder". 2.  Install  'Ckeditor' Module   Go to Administration › Configuration > Ckediotr profiles > Filtered HTML   Edit the settings of the Advanced (Filtered HTML) Profile. Under 'Editor Appearance' section, In plugins check the required options like " Plugin for inserting a Drupal teaser and page breaks. ". 3.  Edit the configuration settings of input formats (Filtered HTML, Full HTML, Plain Text)   Go to Administration › Configuration > Text formats. Edit the required input format. For example say "Filtered HTML". Under  "Enabled filters" section, check the 'Smart Paging' option and uncheck all the remaining checkboxes. 4. Go to Content type 'article' and create new content. We will s...

To find broken links on a site?

There are literally a bazillion SEO tools on the internet (literally!), this post discusses just one such tool; Xenu's Link Sleuth. Many people in the SEO industry are already aware of this tool but many people I've spoken to only treat the tool as a broken link finder. It's so much more than that.  What is Xenu? Xenu's Link Sleuth  is a FREE download (everyone loves free) that runs on all versions of Windows (but not quite on Macs unfortunately). It's a lightweight download and I've never had issues with it crashing or hanging. In a nutshell it's a site crawler and once you point it at a URL it will crawl around the site and spit out a report at the end. Its main focus and branding is all about finding broken links on your site (so where you link internally to a 404 error) but I've found that I use it to solve a whole host of different SEO-related issues. Problem - How do I find broken links on my site? This is the most basic use of Xenu in my opin...