Wednesday 10 September 2014

Extremely Useful Drupal Tips and Tricks, you proably ignored

Below is a compilation of some extremely useful Drupal Tips and Tricks. Its those small important things we ignore or keep searching for. This post collates it in one place. Feel free to bookmark and share it.

Drupal Configuration related tips

  1. Customize Error Pages of your website.
Drupal gives a default error  when a  user  navigates to a web page that they don’t have permission to view or a page that is not found. This is okay but not useful enough for users. To better manage your 403 and 404 pages you can create your own pages and mention the URLs of those pages here..
http://<website (link is external) URL>/admin/settings/error-reporting
Further you can also use http://drupal.org/project/logintoboggan (link is external) module to show login block on access denied pages. This works well for community websites.              
  1. Speeding up database tables
If you have a large website with lot of database reads, DB maintenance (link is external) module will optimize the administrator-selected tables in the database during regular cron.php executions. For MyISAM tables, OPTIMIZE TABLE repairs a table if it has deleted or split rows, sorts table indexes, and updates table statistics. For BDB and InnoDB, OPTIMIZE rebuilds the table. Note, MySQL locks tables during the time OPTIMIZE TABLE is running. Optionally the user can select to attempt a REPAIR TABLE in the event errors are found during attempted OPTIMIZE TABLE. If you enable this ensure you have proper working backups.
OPTIMIZE works best on tables with large deletions (e.g. cache or watchdog), however MySQL will reuse old record positions, therefore in most setups, OPTIMIZE TABLE is unnecessary unless you just like defragmenting. The Overhead column in phpMyAdmin's database view is the most common way to determine the need of an OPTIMIZE TABLE query. It essentially shows the amount of disk space you would recover by running an optimize/defragmentation query.
Think of OPTIMIZE TABLE like defragmenting your hard drive. Sure your system will run without it, and it might even be fast, but isn't it nice to run a defrag when you can?
  1. If you have not done the overall optimization and want to learn how you can speed up and optimize your drupal website read all about it here. This article has simple things like configuration changes to using some modules. How to Speed up and Optimize Drupal 7. Though drupal has built-in cache mechanism, by default, Drupal will save all its caches to database, which means, every time you hit a cache, there will be a database query. This is obviously not the best solutions.To speed up your site's cache, a better way is use a 3rd party caching system, such as Memcached, and stores all caches in memory. And in this article, we will tell you how to integrate Memcached with drupal. Memcached is a distributed memory object caching system which is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. It is now widely used by hundreds of thousands of sites on the internet such as YouTube, Zynga, Facebook and Twitter. Memcached runs on Unix, Linux Windows and MacOSX and is distributed under a permissive freee software license. Read here about Drupal Memcached Integration
  2. WYSIWYG Editor is there a better option ?
You should add a WYSIWYG editor to your drupal website. Contributed module a WYSIWYG editor (link is external) has all the functionality and integrations with popular editors.  You will have to use IMCE (link is external) along with WYSIWYG editor for image support.
If you are looking for a fastest and light weight WYSIWYG Editor for Drupal,  Then Whizzwyg (link is external) is the answer. Fastest and smallest WYSIWYG Editor but features rich.
In old days there was no proper module to have WYSIWYG editor on your drupal webite. There were many options available , in case you don’t want to use WYSIWYG editor

Drupal Moderation and Administration related tips and tricks

  1. Controlling spams, Cleaning up , Purges etc.
Drupal is best used for community websites. But if you keep community website open for users to post content or comments, you will only end up seeing loads of spam. Spam is dangerous if not cleaned since if you use Adsense account,  your account may be disabled, since spam post may violate adsense guidelines.   First you must know how to control spam, read this post  Stopping spam in Drupal – Users, Posts, Comments, Next you must know how to manage after the fact, meaning after your website has been spammed, for that check this post    5 drupal modules to Purge users, Clean-up Spammers and Spam posts

  1. Flagging content - To further control Spam and take help from your forum or website members use Flag Abuse (link is external) module.  provides default abuse flags for nodes, comments and users and gives an administrative interface for reviewing and resetting said flags

  1. Regular Drupal housekeeping
Keeping the website free from junk and removing old and unwanted  posts is also very important.  We often get stuck because there is not bulk method to do this effectively. Even if you want to purge users or comments, we have to struggle finding the right modules to do that. Check this post for solution Deleting / Purging Cache, Users, Nodes, Comments (Housekeeping)

  1. For plain simple mass deletions, without much options, check out this page (link is external)

  1. Backing up your website - If you are a new to drupal then you MUST take backups before making any major changes or installing major modules so that you can restore the original in case things screw up. During my early years, I myself have wasted several precious hours since I did not take the backup and had to  work several hours to restore the site. Use  Backup & Migrate (link is external) module that helps making this task
  2. Hosting your drupal website -  if you are looking for shared hosting and something which is good for your pocket, then you may not get good performance, security or customer support. Having said that , there are good shared hosting providers for Drupal. If you are looking to host professional and high end sites, then its better you consider and choose from this list of features, in addition to the standard features provided by webhosting. Drupal is a powerful CMS and if the hardware or hosting supports it well then it can really do wonders for you. Fast websites are still in fashion and will continue to outsmart the slower alternatives
  3. Installing Themes and modules in the right directories
This causes issues later on, when you have to upgrade the drupal to next version . Follow the directory structure recommended, that way it will be easy to debug.
/<Your drupal-root >
  /includes
  /misc

  /modules      <-- core modules here
  /profiles
  /scripts
  /sites
    /all
      /modules  <-- contributed modules here

Drupal Troubleshooting related tips and tricks

  1. White screen of death ( Completely blank page)
Occasionally a site user or developer will navigate to a page and suddenly the page content disappears, and is completely blank. No content. No errors. Nothing. This often, but not always, happens after updating a module, theme, or Drupal core. This is what is referred to by most members of the Drupal community as the White Screen of Death or WSOD. There are several reasons why this might occur, and therefore several possible solutions to the issue.  Check this page for more info http://drupal.org/node/158043 (link is external)
  1. Not sure what to do use “Flush Cache Function”
Drupal has a caches for all your content so whenever a page is requested, it doesn’t have to generate it dynamically all of the time (quering the database), it can pull it up from cache. This speeds up the website as it reduces the amount of PHP processes and SQL queries being made.
Whenever you see that your site acts strangely or your changes to themes are not reflecting, you must Flush Cache. Flushing your cache clears out your Drupal cache and allows the site to rebuild itself with up-to-date information. Click on the left most icon on your Administration menu to invoke Flush Cache related functions.

Drupal SEO and Traffic Related tips and Tricks

  1. Once you have your drupal website up and running, you need to do some Search engine optimization. Even if you have already done SEO, this article will give you some new insights and pointers and help you increase your website traffic and SERPS. Drupal is very strong in SEO that is why I am still hooked on to it.  Top Drupal SEO Modules, Tips and Tricks to increase traffic
  2. Social bookmarking and sharing helps bring traffic to your site and increases SERPs.  I have myself struggled with many different modules, kept changing and finally learnt few good ones which does the trick. Check this page to decide what you should be using >> Best Drupal Sharing and Social bookmarking module reviews
  3. Twitter integration can be as simple or complex as you want it to be. The reason is twitter has lots of features and you may want to seamlessly integrate with twitter. Depending upon your needs you will either pick up a module or you will write a small HTML or PHP snippet. Check this page for Drupal and Twitter integration ( Posting , Tweeting, Pulling )
  4. URL Alias and Auto Aliasing is achieved using  PathAuto (link is external) , But what about the old aliases you have created? It will show up as duplicate content on your website and Search engines will hate that.  Use Redirect (link is external) together with PathAuto Module and you will get a good SEO Friendly site J.
When using PathAuto module it is very important that the uniqueness of the URLs is maintained, else it will be seen as duplicate content by search engines. You can add date to avoid this problem.

Drupal Content Related tips and Tricks

  1. Showing similar or related content in the block to improve stickiness
It’s a common feature in CMS to show a block of related content items or similar content. This interests the user as he can read similar entries on your website and stay longer on the website. It will also increase the chances of your website being bookmarked.
There are many modules available , you can see a Comparison of Similar / Relevant content block modules (link is external), But I would recommend you use this simple option of showing relevant content block using views module you can find the article here.
Using Views 2 and Drupal 6 to Create a Related Pages Block (link is external) make sure you read the comments on the page as the solution itself is slightly old.
For drupal 6 sites there is another module available which can do similar function which is Taxonomy Quick Find (link is external). It has more configurations like you can configure each block to only show individual node types (eg, one block for page and a completely separate block for blogs) and Each node type on each block can also have its own limit
  1. Slide show of your content
Generally the homepage of a website would have slide show of the latest items or important nodes / images you want to highlight. This can be achieved in many ways. Usually people may think jquery plugins but the best way to do this in Drupal is to go for views slideshow module.
You could rotate entire nodes, categories, image galleries, etc Its also a great space saver. Places where you had multiple images or multiple items such as RSS feeds or category listings can now be presented in a slideshow >>> Views Slideshow (link is external)
Views Slideshow has many features and has lot of supporting modules too. Read the module page properly. It even has links to external articles which are very good.
  1. How to use images in drupal
A common confusion is how to add the image support to drupal. There are so many modules and snippets,which one would be the best ? What do most people use ?As a newbie you may have these FAQs in mind.One another thing I wonder is should I host my images remotely on Flickr , Picassa or should I keep it local.Check out this article which will help you. Drupal Image support for Nodes. If you are planning to use Flickr then you can check out Drupal and Flickr Integration

  1. Don’t need the body field ? .
As you know each content type be it story , page or new CCK content type has a body field , If you don’t want it , you will have to create a new CCK content type, then Goto administer › Content management > Content types and Edit the type you want, erase the label 'Body'. Using a blank label will remove the field.

  1. Converting  nodes from  one type to another.
Often we create content types and then we realize that its difficult to manage so many content types and wish we had created fewer types. Or simply you want to convert from one node type to another.  Node Convert (link is external)  adds a menu tab "Convert" on the node view page, i.e. node/1/convert, which gives the ability of converting the node from its current node type to another node type. Also it gives the ability of transfering all the custom CCK field values of the current node type to the destination CCK fields, or discard them
  1. Using Drupal forums - The forum module of drupal is very basic and when compared
    to other forums softwares like vbulletin or simple machines it lacks features & functionality . Question is why would you use drupal forums.? I would say
    that if you want a basic mechanism for discussion and don't anticipate a huge
    group of users, then you can go with inbuild forum module as it fast and easy
    to maintain. If you install a third party module like vbDrupal or Simple
    machines integration then may have to wait for upgrades if you are not a
    developer.  Also you are at the mercy of the free support offered by the community if you have any issues with the modules.  Read this post Drupal Forums – Enhance, Integrate and get Inspirations.

  1. Site Search - I personally don’t like Google site search. Drupal search results is much better. You can use Porter stemmer module (link is external) to improve your search effectiveness. This module implements the Porter stemming algorithm to improve English-language searching with the Drupal built-in Search module. The process of stemming reduces each word in the search index to its basic root or stem (e.g. 'blogging' to 'blog') so that variations on a word ('blogs', 'blogger', 'blogging', 'blog') are considered equivalent when searching. This generally results in more relevant search results.  You can also use  views (link is external) + views_fastsearch (link is external) to build "section search" or custom advanced search pages for your drupal website.

  1. Large files (audio) - If you are using audio module in drupal there is a limit to size of audio files which can be uploaded. After much research I have found that the following can be used to increase the filesize limit of audio files.  and also to bulk upload your audios
Uploading large audio files and Bulk uploading

Drupal Theme and Appearance Related Tips and Tricks

  1. Overriding style sheets (CSS) from core or contributed modules to match your site design
Most modules provide defaults for the presentation of its output. This includes the markup itself and an associated style sheet. (see the explanation on the overriding behavior for the markup.) These default styles can be overridden by making changes within your theme.
Overriding core and contributed module style sheets
To override a core or contributed module style sheet, it must be specified in your theme's .info file. For example, system-menus.css is located at "modules/system/system-menus.css". If you place a file with the same name in your theme's folder and add the following entry to the .info file, the original system-menus.css file will be ignored and your version will be loaded in its place.
stylesheets[all][] = system-menus.css
  1. Adding an icon to menu links
Check this page for the snippet to add icons to drupal menu links http://drupal.org/node/144603 (link is external)
Modules which will help you further achieve this functionality
  • menu icons (link is external) menus can be assigned icons
  • taxonomy menu (link is external) automate the creation of menus from taxonomy terms
  • taxonomy image (link is external) attach images to terms
  1. Creating a simple help text block
Your users may need help when they are submitting nodes or editing content on your website. For eg. If they need help with HTML tags, you can create a block which shows up only on edit pages. Create a new block and assign it to appear on only "node/*/edit" and "node/add/*. You can use this trick for showing up any help related text.

  1. Displaying block on Front Page ONLY   
Many a times when you are selling links or banner ads, the advertiser may not want link to appear on multiple pages.So if you just put <front> on block configuration page it may not work especially if your front page is “node” which means it displays all the nodes. The block will appear on other pages also like when you browse Page 2, 3, 4 and so on.Read this for solution Displaying block on Front Page ONLY
  1. Change your administration theme when you are working with new theme, so that even if your new theme has errors you can always access  /admin pages
  2. To embed a view anywhere in your theme's template.php or .tpl.php files you can use theme('view', {arguments})

No comments:

Post a Comment