Skip to main content

Posts

Showing posts from 2013

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 SVN. If central repository

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 compression  9. Use boost/mamca

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

Getting content from xml url using php

step1:first declare a url: $url ="[url]"; step2: getting content for  url:   $results = file_get_contents($url);   ( Note: file_get_contents: which reads entire file into string) step3: Load a xml content into a variable: $xml = simplexml_load_string($results); (NOTE: simplexml_load_string: Interprets a string of XML into an object) then u get content by echo $xml->[tag_name];

Break a string without losing html tags in PHP

< ? php /** * Using this function, we can break ( substr ) a string without losing html tags, * * @param $text *    String which is to be shortened. * * @param $length *    The length of the string . * * @param $ending *    The string that is to be appended after shortening.  Defaults to &hellip; * * @param boolean $exact *   If false, $text will not be cut mid-word * * @param boolean $considerHtml *   If true, HTML tags would be handled correctly * * * @return *     string Trimmed string.. */ Function _html_substr ($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) {     if ($considerHtml) {       // If the plain text is shorter than the maximum length, return the whole text       if (strlen ( preg_replace ( '/<.*?>/', '', $text)) <= $length) {         return $text;       }       // splits all html-tags to scanable lines       preg_match_all ( '/(<.+?>) ? ([^<> ] * )