drupal

Boost'cache lifetime ignored in Drupal 7: how to solve the problem

Sometime in Drupal 7 the Boost 's cache is flushed during the cron without respecting the Boost maximum cache lifetime setting, this happens when the cron is running and there is an attempt to re-run it, something goes wrong and the Boos'ts cache is flushed. To solve this problem i made that the Boost's hook_cron is executed for last using the function hook_module_implements_alter : function...

Publication Date Update: module for Drupal 7 to add last update date to a node

Publication Date Update is a simple module for Drupal 7 that adds the "last update" date to a node, to be installed it needs the module Publication Date , because it works with the published_at variable. Publication Date Update is simply this function: function publication_date_update_preprocess_node(&$vars) { $time_unit = 86400; // number of seconds in 1 day => 24 hours * 60 minutes * 60 seconds $threshold = 10; // --- Create revision data // Check if node was revised if (($vars['status']) && $vars['changed'] && (round(($vars['changed'] - $vars['published_at']) / $time_unit) > $threshold)){ $vars['submitted'] = t('Published: !publishtime | Updated: !updatetime | Author: !username', array( '!publishtime' => format_date($vars['published_at'],'custom','d M Y...

Flush Cache Cron: module for Drupal 7 to flush the cache

Flush Cache Cron is a module for Drupal 7 to manually flush the cache and for set the cache flushing during the cron, this module only flushes the cache without rebuilding the system bootstrap. The module empties the tables: cache cache_block cache_filter cache_form cache_menu cache_page cache_path cache_views cache_views_data

Boost Expire for Drupal 7: a revision of the module

This is a revision of Boost Expire for Drupal 7 thanks to which the Boost's cache is flushed only when a node or a comments goes from unpublished to published or viceversa and when editing a node or a comment that is already published. Here there is the code: <?php /** * @file * * Expires Boost caches automatically when certain Drupal actions are taken. */ /** * Implements hook_menu(). */ function boost_expire_menu() { $items['admin/config/system/boost_expire'] = array( 'title' => 'Boost Expire', 'description' => 'Configuration for Boost Expire.', 'page callback' => 'drupal_get_form', 'page arguments' => array('boost_expire_admin_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Implements...

Easy subscription for Drupal 7: a revision of the module

This is a little revision of Easy subscription for Drupal 7 thanks to which the notifications are sent only when the node is published and in the outgoing email are now present the title, a small preview of the contents and the link of the new node. Here there is the code: <?php /** * @file * This is an easy subscription module */ /** * DB management. */ function easy_subscription_form($form, &$form_state) { $form = array(); // Add a title to help baffled users $form['description'] = array( '#type' => 'item', '#title' => t(''Subscribe to receive updates''), ); $form['email'] = array( '#type' => 'textfield', '#title' => t('email'), '#size' => 20, '#required' => TRUE, '#validate' => array('filter_form_validate' => array('email_validation')), ); $form['...

Drupal 7: how to get the body of a node

If in Drupal 7 we have to use the content of the body of a node as variable then we can get it through php, everything is really simple, we only have to give attention if the site uses only one language or if it is a multilanguage site. If the site use only one language we can get the body of a node in this way: $body = $node->body['und'][0]['value']; If the site is a multilanguage site we can...

Drupal 7: how to get absolute path url or path alias url of a node

In Drupal 7 we can access to a node through its absolute path url or through its path alias. In some case it is really useful get these urls and as usually in drupal we can do this in a lot of ways, here there are some examples. Code to get absolute url: global $base_url; $nodeurl = $base_url . '/' . current_path(); $nodeurl = url('node/'. $node->nid); Code to get path alias url: $nodeurl =...

Drupal 7: how to detect when a node or a comment is changed from unpublished to published or vice versa

In Drupal 7 we don't have a simple way to detect when a node or a comment switches from published to unpublished or vice versa but we can detect these actions with some php code. Node publishing: isset($node->original->status) && $node->original->status == 0 && $node->status == 1 Node unpublishing: isset($node->original->status) && $node->original-...

Drupal 7: how to enable\disable comment of old nodes

In Drupal 7 we can set the comments in three ways: Hidden: No comments are allowed, and past comments are hidden. Closed: No comments are allowed, but any past comments remain visible. Open: Any future content of this type is open to new comments. We can change in any moment the default comments' settings for any content type but the new choice will be valid only for the new nodes and not for the...

Drupal 7: how to block the spam

A big problem for the owners of a web site is the spam by the bots. Me too in this little website that i made with Drupal 7 i had this problem and is for this reason that until some month ago i was usually moderate each single comment approving or deleting it and banning its ip but for me this was a boring operation. Really annoyed by the spam comment bots i decided to solve the problem and after...

Pages

Subscribe to RSS - drupal