Entities are one of the most important concepts introduced in Drupal 7. It is clear now that, it got further expanded in Drupal 8.
Sometimes requirements may arise that want you to embed/add fields for an entity within a another form, possibly custom form you created in your module. With this article I am trying to show you how to achieve it. I will show it by embedding fields for a page node within a custom form. To keep things simple, the custom form do nothing other than just showing a text input field and allows to add/edit a page node. Continue Reading
While programming for Drupal, it is a very common scenario to get the language code for a given entity. A bad practice being followed by many programmers is hard-coding the value
'und' directly as language code. Some programmers will take
'language' property of the entity object, this only works for entity of type node and entities that have property named ‘language’ as entity key for language. Continue Reading
While working on Drupal coding, sometimes you may want to get the default files directory path. Here it is said as ‘default’ intentionally, as you can configure a Drupal installation to have default directory as public or private. For most of the sites it will public files directory.
Use following code snippet to get default files directory path.
drupal_realpath(file_default_scheme() . '://');
Or, if you want to get public or private files directory path specifically. Then you can use this to get public directory.
Or, for private directory path.
When you implement
hook_theme() in Drupal, there is provision to specify the file which should be loaded for the theme functions and preprocess functions to be found. So, we can simplify module file by moving out theme function and preprocess function of our theme entries to separate file. This also has added benefit of reducing module loading. On each bootstrapping Drupal will load every .module file those are of enabled modules. So we should consider moving out code from .module file and also giving modular structure. Continue Reading
While working on Drupal, we may need to get taxonomy term name from its id. In Drupal 7, the easiest way would be to call taxonomy_term_load().
taxonomy_term_load() will return taxonomy term object containing all term properties.
Sometimes, we may need more efficient method of getting term name without the heaviness of other properties of that term. And there is no such function in Drupal 7.
I was trying to enable gd for php in Ubuntu 11.04. As usual it should be typing in terminal:
sudo apt-get install php5-gd
Unfortunately it does not worked and gd was not enabled
Typing the command ‘php -a’ I was getting:
“PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20090626+lfs/gd.so’ – /usr/lib/php5/20090626+lfs/gd.so: undefined symbol: gdImageCreateFromJpeg in Unknown on line 0″ Continue Reading
Once initialised, we can register script and/or CSS style links or raw scripts and/or CSS styles with resource loader object. Then finally we can render everything in correct order in our web page to deliver to client side browser. Continue Reading
For one of my program I was in need to use thread pooling. I tried two of available, then wrote one myself. Rather than waiting for threads by calling join() I implemented checking in a while loop for finishing of threads. The code is given below: Continue Reading
Until now Malayalam community were using a customised free version of old Keyman to type anywhere in a Windows system. Me too was using it in all places except Malayalam Wikimedia projects, on Malayalam Wikimedia projects I use our Narayam which is a built in Malayalam typing solution integrated to Wikis. People were always complaining about Keyman that is does not work on Windows Vista and 7 systems. And even I had started to develop a solution to replace Keyman based solution, I stopped further developments soon after I fully changed my platform to Ubuntu. Continue Reading
Added support for Oriya to Narayam extension. Currently added schemes for Oriya are transliteration and InScript. Subhashish Panigrahi helped to fix the issues in transliteration scheme. I think more issues may come later, as they want more tuning on it. Oriya translator at translatewiki can use this schemes to help their contributions.
Since its creation to just before Oriya Wikipedia was less active. Shiju Alex is helping to build a community there. After Oriya typing feature active, I hope, more Oriya people will show their interest in the project, as the one major barrier has bee solved.