Über uns

Drupal - Consulting und Services seit 2005. Acquia Service Partner seit 2009. Hier erfahren Sie mehr über uns.

Über Drupal

Drupal ist eines der besten Open Source CMS. Mit Version 7 stehen Ihnen neue mächtige Funktionen zur Verfügung.

SEO

Seit der ersten Drupal Version aus dem Jahr 2000, stellt Drupal wichtige Werkzeuge für SEO zur Verfügung.

Distributionen

Spezialisierte Drupal Installationsprofile stellen Ihnen maßgeschneiderte Lösungen für einen definierten Website Typ zur Verfügung.

STARTSEITE

Kleiner Helfer

Um so ein gestyltes Download Element, wie in der Abbildung zu sehen, hier im Drupal Magazin zu erzeugen, müssen wir immer viel zu viel tippen. Insbesondere der Link zur entsprechenden Drupal Projektseite nervt.

Also habe ich ein kleines Modul geschrieben, dass uns diese Arbeit erleichtert. Um die Box mit einem Link zu erzeugen, reicht es jetzt [views#Views herunterladen]zu schreiben. Und da wir auch oft Drupal und mdwp* hier eintippen, habe ich das auch in das Modul integriert.

Es ist ein sehr einfaches Filter Modul. Hier der Code:

function filter_example_filter($op, $delta = 0, $format = -1, $text = '') {
  // The "list" operation provides the module an opportunity to declare both how
  // many filters it defines and a human-readable name for each filter. Note that
  // the returned name should be passed through t() for translation.
  if ($op == 'list') {
    return array(
      0 => t('Substitute "Drupal"'),
      1 => t('Substitute "mdwp*"'),
2 => t('Substitute [modulname/]'),
);
  }

 
  switch ($delta) {

    // First we define the simple string substitution filter.
    case 0:

      switch ($op) {
        // This description is shown in the administrative interface, unlike the
        // filter tips which are shown in the content editing interface.
        case 'description':
          return t('Substitutes the string "Drupal" with a link to drupal.org.');

        // We don't need the "prepare" operation for this filter, but it's required
        // to at least return the input text as-is.
        case 'prepare':
          return $text;

        // The actual filtering is performed here. The supplied text should be
        // returned, once any necessary substitutions have taken place.
        case 'process':
          return str_replace('Drupal', '<a href="http://drupal.org">Drupal</a>', $text);

       
      }
      break;

   
    case 1:

      switch ($op) {
        // This description is shown in the administrative interface, unlike the
        // filter tips which are shown in the content editing interface.
        case 'description':
          return t('Substitutes the string "mdwp*" with a link to mdwp.de.');

        case 'prepare':
          return $text;

        case 'process':
          return str_replace('mdwp*', '<a href="http://mdwp.de">mdwp*</a>', $text);
      }
      break;

case 2:

      switch ($op) {
        // This description is shown in the administrative interface, unlike the
        // filter tips which are shown in the content editing interface.
        case 'description':
          return t('Substitutes the string [modul#title]  with a link to a project on drupal.org.');

        case 'prepare':
          return $text;

        case 'process':

          $text = str_replace('[', '<p class="download"><a href="http://drupal.org/project/', $text);
$text = str_replace('#', '">', $text);
$text = str_replace(']', '</a></p>', $text);
return $text;

      }
      break;


  }
}

Anstelle von 3 Filtern hätte man das auch in einen schreiben können und die str_replace lassen sich sicherlich eleganter und effektiver mit preg_replace schreiben. Aber das tuts auch und da gefilterte Nodes gecached werden, spielt es für die Performance sicherlich keine große Rolle.

Drupal News & Diskussionen

Neueste Kommentare

mdwp*

Drupal - Consulting u. Services
Webdesign, Konzeption, Entwicklung

Hügelstr. 6a
58099 Hagen

E-Mail: post@mdwp.de
Tel.: 02331 3 96 16 91

Drupal Association Organisation Member
Acquia Service Partner