drupal

Cache Expire: Drupal 7 module to flush the cache

Cache Expire is a Drupal 7 module to automatically flush the cache when node or a comment is published or updated, 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 and it self integrate with Cloudflare Cache Clear and with APC patched for APCu . Here the code: <?php /** * @file * * Expires caches automatically when certain Drupal actions are taken. */ /** * Implements hook_menu(). */ function cache_expire_menu() { $items['admin/config/system/cache_expire'] = array( 'title' => 'Cache Expire', 'description' => 'Configuration for Cache Expire.', 'page callback' => 'drupal_get_form', 'page arguments' => array('...

Bash script to backup a Drupal site with an SQLite database

Script to backup via ftp a Drupal site that uses a database SQLite and to then archive it. backup_site.sh: #!/bin/bash # License: GPL # # Author: Mentor <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the...

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 Here there is the code: <?php function flush_cache_cron() { try { $core = array('cache', 'cache_block', 'cache_filter', 'cache_form', 'cache_menu', 'cache_page', 'cache_path', 'cache_views', 'cache_views_data'); foreach($core as $table) { cache_clear_all('*', $table, TRUE); } } catch (Exception $e) { return $e; } return NULL; } function flush_cache_cron_cron() { // Interval defaults to 10800s = 3h. $interval = flush_cache_cron_interval(); // Set interval to 0 to...

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['unsuscribe...

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-...

Pages

Subscribe to RSS - drupal