Posts

Showing posts with the label drupal

connect to multiple database from drupal

Drupal has the ability to connect to multiple databases, allowing you to use Drupal’s built in database abstraction layer on more than just Drupal's primary database. Preferably you would add your configuration in the settings.php file for your site, so that all modules can interact with the new database. Drupal 7 In your settings.php: $databases = array(); $databases['default']['default'] = array( // Drupal's default credentials here. // This is where the Drupal core will store it's data. ); $databases['alternate_db']['default'] = array( // Your secondary database's credentials here. // You will be able to explicitly connect to this database from your modules. ); The way to use it in module: // Use the database we set up earlier db_set_active('alternate_db'); // Run some queries, process some data db_query('...............'); //Switch back to the default connection when finished. // other...

Theming Views 2 – The Basics

Image
Views 2 provides a well structured theming environment allowing presentation control for each element of your view. And in my humble opinion, it rocks! Those with no past experience with Views 1 will find Views 2 uses standard PHPTemplate theming techniques. All of your experience theming Drupal can be used with Views. Views 1 themers starting with Views 2 might be a bit confused at first. I was. The single callback in template.php where everything happened is gone, refactored into a consistent framework of template files. All of the freedom that existed in the single function still exists with the added benefit of a well defined structure Overview: Views handles querying the database and organizing the information for display. It creates the output display by converting retrieved data into variables and passing them through a series of templates. Each template handles a different "level" of output creation. The number of templates used to create a view's output depen...

creating and updating node in drupal

Image
The steps for programmatically creating a node are: Create a PHP object representing the node data Save the object using the node_save() function While the mechanics are simple, there is an important responsibility involved. The Drupal work flow does data validation before calling the node_save() function; node_save() does no validation. By calling node_save() directly your code takes the responsibility for providing valid data. Drupal 7 Changes A quick note for those of you familiar with Drupal 6. You'll notice two changes in Drupal 7: Body Field Is No Longer Special In Drupal 6 the body field was special. Specifically, it had a different data structure than other fields and it always existed, even if it wasn't used. With Drupal 7 the body field is a standard field provided by core and is truly optional. Language Language specification is required for the node and some fields. Filter Format The format of the text field filter is now specified by machine name, not...

install and integrate memcached in drupal

Hi Every one, If performance is the issue for your Drupal site then one thing you are missing is memcache. This article explains you step by step process to install and memcache and how memcache helps to boost your drupal website. What is memcache ? Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. Memcached's magic lies in its two-stage hash approach. It behaves as though it were a giant hash table, looking up key = value pairs. Give it a key, and set or get some arbitrary data. When doing a memcached lookup, first the client hashes the key against the whole list of servers. Once it has chosen a server, the client then sends its request, and the server does an internal hash key lookup for the actual item data. For example, if we have clients 1, 2, 3, and servers A, B, C: Client 1 wants to set key "foo" with value "barbaz...