netnode IT services GmbH
Mythenstrasse 7
6003 Luzern
041 450 10 66
Kontaktformular
Newsletter
Blog
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
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.
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;
}?>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...
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'),
)
),
),
);
}
?>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')));
?>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($node, 1);
$term = array_shift($terms);
$title = str_replace('ä', 'ae', $node->title);
$title = str_replace('ü', 'ue', $title);?>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 = '
<a href="#"
onclick="FB.Connect.requireSession(facebook_onlogin_ready); return false;" >
<img id="fb_login_image"
src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_white_medium_long.gif"
height="15" alt="Connect"/>
</a>';
return $button;
}
?>