Drupalberlin.de Treffunktseite erweitert

Events happening in the community are now at Drupal community events on www.drupal.org.
spade's picture

Wir haben heute gmap und das BVG-Widget in die Site integriert:
http://drupalberlin.de/content/c-base

Da das noch nicht optimal erscheint, bitte ich hiermit um Tipps, wie das optimiert werden könnte.

Zurzeit ist dies mit einem Inhaltstyp Ort realisiert und die BVG-Widget als Block mit fester Anschrift, der nur bei diesem Node ausgegben wird. Besser wäre es, wenn das BVG-Widget die Adresse vom Node erhält und so für verschiedene Locations funktionieren würde.

Eine Frage wäre auch, wie bei der Ortsangabe die PLZ vor dem Ort ausgegeben werden kann.

Comments

Siehste ;)

yannickoo's picture

Soo funktioniert doch gut, allerdings habt ihr jetzt doch den iFrame benutzt :P

Die Url ist ja immer »http://www.bvg.de/index.php/de/widgets/fahrinfo/1/400/1/ZIEL« Und Ziel könnte man ja mit PHP auslesen. Das wäre dann die Adresse der Node Location.

Yannick

Hier ist die zu

erik seifert's picture

Hier ist die zu überschreibende Funktion

<?php
function theme_location_de($location = array(), $hide = array()) {
 
$output = '';
  if (
count($location)) {
   
$output .= "\n";
   
$output .= '<div class="location vcard"><div class="adr">'."\n";
    if (!empty(
$location['name']) && !in_array('name', $hide)) {
     
$output .= '<div class="fn">'. $location['name'] .'</div>';
    }

    if (!empty(
$location['street']) && !in_array('street', $hide)) {
     
$output .= '<div class="street-address">'. $location['street'];
      if (!empty(
$location['additional']) && !in_array('street', $hide)) {
       
$output .= ' '. $location['additional'];
      }
     
$output .='</div>';
    }

    if ((!empty(
$location['city']) && !in_array('city', $hide)) ||
        (!empty(
$location['postal_codet']) && !in_array('postal_code', $hide))) {

     
$city_postal = array();

      if (!empty(
$location['postal_code']) && !in_array('postal_code', $hide)) {
       
$city_postal[] = '<span class="postal-code">'. $location['postal_code'] .'</span>';
      }

      if (!empty(
$location['city']) && !in_array('city', $hide)) {
       
$city_postal[] = '<span class="locality">'. $location['city'] .'</span>';
      }

     
$output .= '<div>'. implode(' ', $city_postal) .'</div>';
    }

    if (!
in_array('country', $hide)) {
     
$output .= '<div class="country-name">'. t('Germany') .'</div>';
    }

    if (isset(
$location['latitude']) && isset($location['longitude'])) {
     
$output .=  '<div class="geo"><abbr class="latitude" title="'. $location['latitude'] .'" /><abbr class="longitude" title="'. $location['latitude'] .'" /></div>';
    }

   
$output .= '</div></div>';

  }
  return
$output;
}
?>

Hier die Theme Funktion (angepasst):

<?php
function themenamehere_location_de($location = array(), $hide = array()) {
 
$output = '';
  if (
count($location)) {
   
$output .= "\n";
   
$output .= '<div class="location vcard"><div class="adr">'."\n";
    if (!empty(
$location['name']) && !in_array('name', $hide)) {
     
$output .= '<div class="fn">'. $location['name'] .'</div>';
    }

    if (!empty(
$location['street']) && !in_array('street', $hide)) {
     
$output .= '<div class="street-address">'. $location['street'];
      if (!empty(
$location['additional']) && !in_array('street', $hide)) {
       
$output .= ' '. $location['additional'];
      }
     
$output .='</div>';
    }

    if ((!empty(
$location['city']) && !in_array('city', $hide)) ||
        (!empty(
$location['postal_codet']) && !in_array('postal_code', $hide))) {

     
$city_postal = array();


      if (!empty(
$location['city']) && !in_array('city', $hide)) {
       
$city_postal[] = '<span class="locality">'. $location['city'] .'</span>';
      }

      if (!empty(
$location['postal_code']) && !in_array('postal_code', $hide)) {
       
$city_postal[] = '<span class="postal-code">'. $location['postal_code'] .'</span>';
      }

     
$output .= '<div>'. implode(' ', $city_postal) .'</div>';
    }

    if (!
in_array('country', $hide)) {
     
$output .= '<div class="country-name">'. t('Germany') .'</div>';
    }

    if (isset(
$location['latitude']) && isset($location['longitude'])) {
     
$output .=  '<div class="geo"><abbr class="latitude" title="'. $location['latitude'] .'" /><abbr class="longitude" title="'. $location['latitude'] .'" /></div>';
    }

   
$output .= '</div></div>';

  }
  return
$output;
}
?>

Erik Seifert

Das ging ja schnell ;)

yannickoo's picture

Also mit $node->$location['street'] würde sich das doch dann auslesen lassen oder?

Ich selber wüsste jetzt nicht - wenn es sich wie in diesem Fall - wenn es sich um einen Block handelt, wie man dann die $node Dinger auslesen kann.

Weißt du da was Erik :P

Die Blöcke (Node Map / BVG Widget) könnte man ja via PHP noch in die node-ort.tpl.php einfügen ;)

Wer nicht weiß wie → http://community.contractwebdevelopment.com/drupal-block-in-node

Also einfacher Fall wäre das

erik seifert's picture

Also einfacher Fall wäre das direkt mit der Theme funktion anzubinden.

Hier die angepasste Funktion . Das wichtige ist die vorletzte Zeile. Aber kleiner Tipp. Sollte nur mit Berlin und Umland funzen ;- )

<?php
function themenamehere_location_de($location = array(), $hide = array()) {
 
$output = '';
  if (
count($location)) {
   
$output .= "\n";
   
$output .= '<div class="location vcard"><div class="adr">'."\n";
    if (!empty(
$location['name']) && !in_array('name', $hide)) {
     
$output .= '<div class="fn">'. $location['name'] .'</div>';
    }

    if (!empty(
$location['street']) && !in_array('street', $hide)) {
     
$output .= '<div class="street-address">'. $location['street'];
      if (!empty(
$location['additional']) && !in_array('street', $hide)) {
       
$output .= ' '. $location['additional'];
      }
     
$output .='</div>';
    }

    if ((!empty(
$location['city']) && !in_array('city', $hide)) ||
        (!empty(
$location['postal_codet']) && !in_array('postal_code', $hide))) {

     
$city_postal = array();


      if (!empty(
$location['city']) && !in_array('city', $hide)) {
       
$city_postal[] = '<span class="locality">'. $location['city'] .'</span>';
      }

      if (!empty(
$location['postal_code']) && !in_array('postal_code', $hide)) {
       
$city_postal[] = '<span class="postal-code">'. $location['postal_code'] .'</span>';
      }

     
$output .= '<div>'. implode(' ', $city_postal) .'</div>';
    }

    if (!
in_array('country', $hide)) {
     
$output .= '<div class="country-name">'. t('Germany') .'</div>';
    }

    if (isset(
$location['latitude']) && isset($location['longitude'])) {
     
$output .=  '<div class="geo"><abbr class="latitude" title="'. $location['latitude'] .'" /><abbr class="longitude" title="'. $location['latitude'] .'" /></div>';
    }
   
   
//Hier der BVG Block
   
$output . = '<div class="bvg-fahrinfo"><iframe frameborder="0" style="width:300px;height:196px;border:0;" src="http://www.bvg.de/index.php/de/widgets/fahrinfo/1/300/1/'.urlencode($location['street']).'"></iframe></div>';

   
$output .= '</div></div>';

  }
  return
$output;
}
?>

Erik Seifert

Der Vorteil ist, das dieses

erik seifert's picture

Der Vorteil ist, das dieses für mehre Location funzt + Der Block nicht auftaucht wenn keine Adresse.


Erik Seifert

Kuhl, danke. TODO @spade

yannickoo's picture

Kuhl, danke.

TODO @spade »

<?php
function themenamehere_location_de($location = array(), $hide = array()) {
 
$output = '';
  if (
count($location)) {
   
$output .= "\n";
   
$output .= '<div class="location vcard"><div class="adr">'."\n";
    if (!empty(
$location['name']) && !in_array('name', $hide)) {
     
$output .= '<div class="fn">'. $location['name'] .'</div>';
    }

    if (!empty(
$location['street']) && !in_array('street', $hide)) {
     
$output .= '<div class="street-address">'. $location['street'];
      if (!empty(
$location['additional']) && !in_array('street', $hide)) {
       
$output .= ' '. $location['additional'];
      }
     
$output .='</div>';
    }

    if ((!empty(
$location['city']) && !in_array('city', $hide)) ||
        (!empty(
$location['postal_codet']) && !in_array('postal_code', $hide))) {

     
$city_postal = array();


      if (!empty(
$location['city']) && !in_array('city', $hide)) {
       
$city_postal[] = '<span class="locality">'. $location['city'] .'</span>';
      }

      if (!empty(
$location['postal_code']) && !in_array('postal_code', $hide)) {
       
$city_postal[] = '<span class="postal-code">'. $location['postal_code'] .'</span>';
      }

     
$output .= '<div>'. implode(' ', $city_postal) .'</div>';
    }

    if (!
in_array('country', $hide)) {
     
$output .= '<div class="country-name">'. t('Germany') .'</div>';
    }

    if (isset(
$location['latitude']) && isset($location['longitude'])) {
     
$output .=  '<div class="geo"><abbr class="latitude" title="'. $location['latitude'] .'" /><abbr class="longitude" title="'. $location['latitude'] .'" /></div>';
    }
  
   
//Hier der BVG Block
   
$output . = '<div class="bvg-fahrinfo"><iframe frameborder="0" style="width:300px;height:196px;border:0;" src="http://www.bvg.de/index.php/de/widgets/fahrinfo/1/300/1/'.urlencode($location['street']).'"></iframe></div>';

   
$output .= '</div></div>';

  }
  return
$output;
}
?>

einfügen und den Block heausnehmen.

Danke an dich Erik!

Euch noch 'n schönes Wochenende ;)

Sieht gut aus ...

spade's picture

Danke für die schnelle Antwort.

Das sieht ja beeindruckend aus. Wir werden das nächstes Mal zusammen integrieren, damit alle etwas davon haben.

Herzlichen Gruß

Frank

»Eine Frage wäre auch, wie

yannickoo's picture

»Eine Frage wäre auch, wie bei der Ortsangabe die PLZ vor dem Ort ausgegeben werden kann.«

Können wir ja aus dem Theme Funktion entnehmen ;)

Berlin

Group organizers

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: