How do I use theme preprocessor functions for my own templates?

For a general overview, you should read up on manipulating variables within preprocess functions. Concerning the naming convention, this is normally pretty simple, but there is a catch for your current example (see below): A preprocess functions signature needs to be [yourModuleName|yourThemeName]_preprocess_[themeFunctionName](&$variables) so implementing one for the page template within a themes template.php file would … Read more

How to insert a block into a node or template in Drupal 7?

D7: <?php $block = module_invoke(‘module_name’, ‘block_view’, ‘block_delta’); print render($block[‘content’]); ?> ‘module_name’ = The machine name of the module (i.e. the module’s folder name). This is true for core modules too, so for instance ‘search’, ‘user’ and ‘comment’ would all work here. ‘block_delta’ = The machine name of the block. You can determine what this is … Read more

What is the drush command to change a theme in Drupal 7?

Take a look at the comment at http://drupal.org/node/530780#comment-2513534 which has the latest commands related to themes (actually, as of 3.0, but they seem to work with Drush 4.x as well). Disable theme: drush -l http://example.com/ pm-disable theme_name Enable theme: drush -l http://example.com/ pm-enable theme_name Change theme: drush -l http://example.com/ vset theme_default theme_name Change admin theme: … Read more

Attaching image files to nodes programmatically in Drupal 7

Here is an example code using which you can use with node_save $filepath = drupal_realpath(‘misc/druplicon.png’); // Create managed File object and associate with Image field. $file = (object) array( ‘uid’ => 1, ‘uri’ => $filepath, ‘filemime’ => file_get_mimetype($filepath), ‘status’ => 1, ); // We save the file to the root of the files directory. $file … Read more

How can I check Drupal log files?

To view entries in Drupal’s own internal log system (the watchdog database table), go to http://example.com/admin/reports/dblog. These can include Drupal-specific errors as well as general PHP or MySQL errors that have been thrown. Use the watchdog() function to add an entry to this log from your own custom module. When Drupal bootstraps it uses the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)