Tech Blog

Drush: Drupal auf der Kommandozeile

29.11.2011
 von Lukas Fischer
 | 0 Kommentare

Als Entwickler liebt man automatisierte Arbeitsabläufe. Vieles in Drupal lässt sich über die die Administrationsfläche einstellen. Das ist gut, wenn man aber immer und immer wieder den gleichen Ablauf abklicken muss, wird das langweilig. Mit Drush kann man typische Abläufe über die Kommandozeile ausführen.

In der täglichen Arbeit nutzen wir Drush. Die beliebtesten Drush Commands:

drush --help
drush cache-clear
drush pm-download PROJEKTNAME
drush site-install --help
drush upc
drush updatedb
drush rsync
drush sql-sync
drush site-upgrade
drush test-run

Creating a Date Filter between two CCK fields in Views

03.12.2010
 von Alexandr
 | 0 Kommentare

By default Views module doesn't allow to create a filter between two dates that are stored in CCK fields. It only allows to use “in between” statement in filter declaration only either between two constant values or two relative dates with such patterns as “now”, “now+10” etc.

However in real world projects we often need such filters and here is a short example on how to implement such functionality.

Using of CCK filefield widget in a Drupal custom form to send mailattachement

30.11.2010
 von Igor
 | 0 Kommentare

1. Create a CCK field using the type 'File' and the widget 'File Upload' (we will use 'field_file')
2. Create a custom module for the form processing

<?php

// Include of content_field_form() implementation
module_load_include('inc''content''includes/content.node_form');

/**
 * Implementation of hook_menu()
 */

function example_menu() {
  
$items = array();
   
  
$items['form'] = array(
    
'title' => 'Test form',
    
'page callback' => '_page_testform',
    
'access arguments' => array('access content'),
    
'type' => MENU_CALLBACK,
  );
     
  return 
$items;
}
?>

How To Alter Drupal RSS Feeds generated by Views?

26.11.2010
 von Lukas Fischer
 | 0 Kommentare

Sometimes you want to customize the link of an RSS-item outputed by Views 2 within Drupal 6. There are different approaches. I found the following solution handy and easy to use:

<?php
function yourmodule_nodeapi(&$node$op$a3 NULL$a4 NULL) {
  if (
$op == 'rss item') {
      if (
$node->type == 'yourcontenttype') {
      return array(array(
          
'key' => 'link',
          
'value' => 'custom link',
        ));
      break;
    }
  }
}
?>

Additional reference:
http://www.othermachines.com/blog/lara/drupal-tips-modifying-rss-feeds-c...

Drupal: Writing Triggers for Dummies

31.08.2010
 von Lukas Fischer
 | 0 Kommentare

Unfortunately triggers for Drupal are underdocumated and have a lack of examples. This example should provide you help about how to write your custom triggers in your custom modules.

There are 3 steps needed to bring your triggers to life:

1. Write YOURMODULE_hook_info();

<?php
  
function triggertest_hook_info() {
    return array(
      
'triggertest' => array(
        
'triggertest' => array(
          
'insert' => array(
            
'runs when' => t('After saving a new community tag to the database'),
          )
        ),
      ),
    );
  }
?>

Intranet Link to Lotus Notes

03.02.2010
 von Pascal
 | 0 Kommentare

If you want to add a menu entry with a link to a lotus notes application then the error message "The path 'notes://path' is either invalid or you do not have access to it." will show up.

The problem is that Drupal does not allow the Protocol "notes" by default.

The filter module will check whether the protocol is allowed or not in the function filter_xss_bad_protocol.

<?php
variable_get
('filter_allowed_protocols', array('http''https''ftp''news''nntp''telnet'
'mailto''irc''ssh''sftp''webcal''rtsp')));
?>

Drupal cheat sheet

02.07.2009
 von Pascal
 | 0 Kommentare

Links
http://api.drupal.org/
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....

Snippets

Manually set path auto paths - in nodeapi op=update, insert

<?php
if(module_exists('pathauto')) {
          
_pathauto_include();
          
$origPath 'node/' $node->nid;
          
$terms taxonomy_node_get_terms_by_vocabulary($node1);
          
$term array_shift($terms);
          
$title str_replace('ä''ae'$node->title);
          
$title str_replace('ü''ue'$title);?>

Community Manager und Webdesigner gesucht

26.06.2009
 von Lukas Fischer
 | 0 Kommentare

Create a Facebook Connect Button without XFBML

17.06.2009
 von Pascal
 | 0 Kommentare

Use this piece of code for an html button if you don't want to use the XFBML fb:login-button tag.

<?php
function fbconnect_render_button() {
  
$button '
&lt;a href="#"
onclick="FB.Connect.requireSession(facebook_onlogin_ready); return false;" &gt;
 &lt;img id="fb_login_image" 
src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_white_medium_long.gif" 
height="15" alt="Connect"/&gt;
 &lt;/a&gt;'
;
  return 
$button;
}
?>

Erstes Drupal Media Camp - ein Erfolg

11.05.2009
 von Lukas Fischer
 | 0 Kommentare
Inhalt abgleichen