Drupal Technical

Zyxware default image2
| 3 min read
The default behavior of drupal_redirect_form in Drupal 6 is to redirect the user to $_GET['q'] when an explicit redirect location is not set in $form_state['redirect']. So any form submission from a Drupal page with additional querystrings like in a paginated form (for example admin content listing forms or admin comment listing forms) will result in the querystrings being lost. This can be frustrating when you administer content from such forms as you have to click the pager link and go back to the previous page after form submission. This can easily be fixed by adding a submit handler for the form in question and setting form_state redirect correctly.
Zyxware default image3
| 3 min read
The default comment moderation system in Drupal 6 is crude at best primarily because of the limitation of the admin comment listings. The information that is shown by default are 'Subject', 'Author', 'Posted in', 'Time' and 'Operations'. Now the main objective of comment moderation is to reject spam comments. None of these fields give any information about whether the comment is a spam comment or not and you will have to view each comment by going to the edit view of the comment and then approve or reject the comment. This is a very laborious and frustrating process. You have three options to solve this problem and get a better comment administration interface - one is to create a comment view, another is to alter the default comment administration form and the third is of course a custom solution for comment administration.
Zyxware default image2
| 3 min read
This is how you would normally render a view display passing filter inputs via code: $view = views_get_view('view-name'); $view->set_display('display-name'); $view->is_cacheable = FALSE; $filter_1 = $view->get_item('display-name', 'filter', 'filter_1_id'); $filter_2 = $view->get_item('display-name', 'filter', 'filter_2_id'); $filter_1['value'] = "value1"; $filter_2['value'] = "value2"; $view->set_item('display-name', 'filter', 'filter_1_id', $filter_1); $view->set_item('display-name', 'filter', 'filter_2_id', $filter_2); dpm($view->render());
Zyxware default image4
| 3 min read
One of the Drupal sites we maintain had recently started slowing down considerably in spite of the site mostly being static and in spite of boost set up on the server. On examination of the site we found that two things were happening on the site. One was that the site was being crawled indiscriminately by rogue crawlers. This we solved using the DDOS deflate script and setting DDOS deflate to run every 10 seconds. The second problem was that there were some bots which were continuously sending POST requests to /comment/cid/reply pages. For this we had to come up with a workaround.
Zyxware default image4
| 2 min read
In Drupal every path in the site goes via index.php and goes through some Drupal menu. However to make the Drupal application behave live a typical static website in terms of URL architecture sometimes clients request for adding slashes to the end of virtual direcotry paths. At the same time slashes would not look good at the end of virtual file paths. There is an easy way to do this using apache htaccess rules
Zyxware default image2
| 3 min read
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.
Zyxware default image2
| 2 min read
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.
Zyxware default image2
| 3 min read
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.
Zyxware default image3
| 3 min read
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.
Zyxware default image2
| 2 min read
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.
Zyxware default image2
| 2 min read
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.
Zyxware default image2
| 4 min read
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.
Zyxware default image2
| 2 min read
Boost is a module that allows for static caching on a Drupal site for improving performance for anonymous users. You can read more about how to install and configure boost here. Boost comes with a boost crawler that can crawl your site and refresh the boost cache. Here is a simple script that can be used to refresh the boost cache without enabling the boost crawler.
Zyxware default image4
| 3 min read
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.
Zyxware default image4
| 1 min read
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.
Zyxware default image3
| 3 min read
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.
Zyxware default image2
| 2 min read
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: