Blocks are regions on a Drupal website that show small but significant pieces of content. Blocks are an important component from the perspective of a Drupal website. Blocks are usually assigned to regions in a page and they are supposed to be printed on a page. However there are many instances where you might want to print a block within a content. It is not directly possible to assign a block to a region within content (node in Drupal speak) as you can do with a page. But as with everything in Drupal there is a way to do that.
Drupal Technical
Sometimes we get requests to update Drupal sites and get it done in less than 5 hours. If we take the Drupal update through the full fail-safe set of steps for Drupal updates we will never be able to complete updates in less than 5 hours on a site we don't maintain. For such sites when the cost of the site going down may not be too high for the site owner it might not be too big an issue if the update is run on a hit or miss approach. We normally do not recommend such an approach but this should work on most small sites without any issues.
Keeping the Drupal core and contributed modules up-to-date (at least on the security updates) is one of the essential steps for keeping a Drupal site safe and secure. Running updates of Drupal modules is usually a straightforward mechanism on a Drupal site that is done right. However what will you do if you do not know how things have been built? What will you do if some of the custom modules used are tied down to specific versions of some contributed module? What if there were custom changes on the site. Here is how you can run updates on a Drupal site almost completely safely.
We were testing our newly implemented modal popup for a login functionality. It was working pretty good in Firefox, Opera, and Chrome but not in IE8. When attempts to login by clicking on a login link the login modal was not appearing in IE8. Firebug said nothing, but jquery-1.7.2.min.js in IE showed the following error:
If you run a reasonably popular site there is a very good chance that you will get crawled by unscrupulous crawlers once in a while. The regular search crawlers from the popular search engines like the Google bot, Yahoo bot, Bing bot themselves are pretty intensive when they crawl sites but they do have limits on the number of pages crawled per visit and the number of simultaneous connections opened to your server. However there are lots of unscrupulous crawlers like spam bots, email harvesting bots and even some search engines who do not set any reasonable limits on the number of simultaneous connections to your server. There are hardware solutions that are available to prevent this but they may not be affordable for everybody. There is however a simple netstat based solution to prevent DDOS.
One of our clients sent us images they want to put in the website as pdf files. There were 100 files each containing a single image. Opening each of these in gimp and then saving it as pngs was a nightmare. For all such situations, ImageMagick is there for your rescue. With mogrify - a command utility available in the ImageMagick package, bulk converting all these pdf files to png was child's play.
On one of the maintenance projects we got we came across a page that used to take around 11 seconds to load. The page was a views listing for users. We were able to speed up the page load times from around 11 seconds to under 3 seconds by taking out just the distinct option used in the view. The following was the select query that was originally generated from the view with the time logged by views in the preview panel.
In every operating system, there are a lot of tasks that need to be scheduled to run at a particular time - some, very often (as in, every 5 minutes), and some, less (like, once every month). For a quick example, you might want to run a temporary files deletion operation at midnight each day - this is where you need to write a cron job.Crontab and Cron jobs are Linux’s version of a complete job scheduling system.Let us see these in detail.
Boost is a module in Drupal that enables file based static page caching in Drupal. When an anonymous user visits a page for the first time in a Boost-enabled Drupal site, the page will get stored as a static html file in a cache folder. When the next anonymous user visits the same page the htaccess rules created by Boost will serve the static file cached in the cache folder instead of bootstrapping drupal for generating the page. This saves a lot of processor usage and would help even entry level hosting servers serve reasonably good volume of traffic. Here is how you can install and configure Boost in a Drupal 6 site.
We recently saw this error on a Drupal 6 site that had not been updated for quite a while."warning: call_user_func_array() expects parameter 2 to be array, string given in sites/all/modules/contrib/views/views.module" means what it says. call_user_func_array expects the second parameter to be an array whereas a string was given instead. You can troubleshoot problems like this by writing a bit of debug code before the line where the error is reported.
As the world of internet grows day to day, the more educated and ever-wanting userbase now needs more data asynchronously. They don’t like to wait or load another page to see their data. In such situations we developers need to use more and more AJAX (Asynchronous JavaScript and XML - http://en.wikipedia.org/wiki/Ajax_(programming)) in the development of websites. Using AJAX in your web-development workflow is not that much difficult as you think. There is already a wide range of famous ajax libraries that make handling asynchronous requests easy for us.
Drupal’s Nice Menus Module provides a highly customizable and nice-looking dropdown menu for Drupal websites. To allow maximum customizability, it includes a CSS file and a javascript file where you can try out your own recipes. The following steps should help you make nice looking drop down menus for your Drupal website using the Nice Menus module:
Have you ever wondered how that cool site you saw last day had those cool interfaces and you wished your Drupal site could have the same coolness? jQueryUI is your saviour here. jQueryUI is one of the most popular JavaScript libraries out there in the world of web development. jQueryUI allows you to add very cool user interface elements to your website without much effort.
Solution for CKEditor not working in a Drupal 6 site.
One day, all of a sudden we found out that the CKEditor was not working on our Drupal 6 site. It had literally disappeared from our website taking the whole text area on the edit page with it. This meant that we could not create any articles as long as the CKEditor was not working. On seeing this, the first thoughts that flashed through our head was to either update the module or apply a patch believing that the CKEditor module had crashed. However our fears were unfounded and the solution turned out to be more simple than we expected.
Developing a Drupal website is a complicated and long process. You have to check whether all the design and functionalities meet with the client specifications. And before the site going to be live you have to check certain criteria.These checklists describes the criteria that should be tested before a site going to be live.
Do you want to display a login form in a popup? Here is a simple way of displaying the login form in popup using Colorbox in Drupal 7. For this, we need Colorbox module for Drupal 7 installed. Now, follow these steps:
Sometimes we may require updating several rows of data with different queries and make sure every query execute correctly to keep the database consistency. Here is a simple solution to enable such transactions with Mysql and Python. To do this, we can start a transaction and commit the changes to the table. The data will be written to the table only after the commit statement is executed. If there is an error in between, we can rollback, so that all the inconsistencies are cleared.
Password-protecting drupal development site with .htaccess file
There might be few scenarios when we need to protect our site from the general public and make it accessible to a selected group of users. One of the most common scenarios in the development workflow of a Drupal site is when you want to avoid your half-complete drupal site showing up in Google search results.For such needs, it is advisable to go for password-protecting the site using HTTP authentication.
If you have cPanel installed on your hosting server, you can use the ‘Password Protect Directories’ option from the ‘Security’ section on the cPanel home page. Click here to read on How to enable HTTP Authentication using cPanel (link to an article for the same on our site)
For those without cPanel, here’s how to get Apache work your way:
Once in a while you will come across a Drupal site where you have to login to the site without having access to the credentials of user 1. You can easily reset the password of user 1 directly in the database or you can create a small work around to login to the site. Here is how you can login to the Drupal 7 site programmatically as user 1 without knowing user 1 credentials.
If you have a Drupal 6 site where you have access to the ftp account but not to the user 1 credentials here is how you can login programmatially to the site as user 1 without resetting the user 1 password. Now that you know that this is possible, remember to not give ftp access to users who do not have access to user 1 credentials as well.