Friday, July 22, 2011

Drupal 6 Set different custom message on node creation/update/delete

User the following module
Custom Submit Messages
http://drupal.org/project/csm

Thursday, July 21, 2011

Image gallery with 2 caurasol

User http://galleria.aino.se/

This will fulfill all needs.

Friday, July 15, 2011

D6 converts URLs (http, ftp, email, ...) into hyperlinks.

$text field will contain the raw data which we need to convert into links.

$urlfilter_length = 72;
$text = $node_details->field_selling_external_prop_link[0]['value'];
$text = ' ' . $text . ' ';
$text = preg_replace_callback("!(

|

  • ||[ \n\r\t\(])((http://|https://|ftp://|mailto:|smb://|afp://|file://|gopher://|news://|ssl://|sslv2://|sslv3://|tls://|tcp://|udp://)([a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+*~#&=/;-]))([.,?]?)(?=(

    |
  • ||[ \n\r\t\)]))!i", 'urlfilter_replace1', $text);
    $text = preg_replace("!(

    |

  • ||[ \n\r\t\(])([A-Za-z0-9._-]+@[A-Za-z0-9._+-]+\.[A-Za-z]{2,4})([.,?]?)(?=(

    |
  • ||[ \n\r\t\)]))!i", '\1\2\3', $text);
    $text = preg_replace_callback("!(

    |

  • |[ \n\r\t\(])(www\.[a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+~#\&=/;-])([.,?]?)(?=(

    |
  • ||[ \n\r\t\)]))!i", 'urlfilter_replace2', $text);
    $text = substr($text, 1, -1);

    $text will contain the converted values.

    Define below 3 function
    function urlfilter_replace1($match) {
    $match[2] = decode_entities($match[2]);
    $caption = check_plain(urlfilter_trim($match[2]));
    $match[2] = check_url($match[2]);
    return $match[1] . ''. $caption .''. $match[5];
    }

    function urlfilter_replace2($match) {
    $match[2] = decode_entities($match[2]);
    $caption = check_plain(urlfilter_trim($match[2]));
    $match[2] = check_plain($match[2]);
    return $match[1] . ''. $caption .''. $match[3];
    }

    function urlfilter_trim($text) {
    $urlfilter_length = 72;
    return (strlen($text) > $urlfilter_length) ? substr($text, 0, $urlfilter_length) .'...' : $text;
    }

    Friday, July 8, 2011

    Drupal 6 - Display a GMAP for a Location CCK field custom

    My cck location filed is $node_details->field_map_location;
    $lid = $node_details->field_map_location['0']['lid'];

    if (is_numeric($lid)) {
    $loc = location_load_location($lid);
    $markertypes = variable_get('gmap_node_markers', array());
    $markers = array();
    $count = 0;
    if (location_has_coordinates($loc)) {
    $count++;
    $markername = isset($markertypes[$node_details->type]) ? $markertypes[$node_details->type] : 'drupal';
    if (module_exists('gmap_taxonomy')) {
    $t = db_result(db_query('SELECT marker FROM {gmap_taxonomy_node} WHERE vid = %d', $node->vid));
    if (!empty($t)) {
    $markername = $t;
    }
    }

    $markertitle = $node_details->title;
    if (!empty($loc['name'])) {
    $markertitle = $loc['name'];
    }

    $markers[] = array(
    'latitude' => $loc['latitude'],
    'longitude' => $loc['longitude'],
    'markername' => $markername,
    'offset' => $count-1,
    'opts' => array('title' => $markertitle),
    );
    }

    if (!empty($markers)) {
    $macro = variable_get('gmap_location_block_macro_'. $node_details->type, '');
    if (empty($macro)) {
    $macro = variable_get('gmap_location_block_macro', '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]');
    }
    $map = gmap_parse_macro($macro);

    $map['width'] = '100%';
    $map['height'] = '300px';
    $map['latitude'] = $node_details->location['latitude'];
    $map['longitude'] = $node_details->location['longitude'];
    $map['markers'] = $markers;
    }
    }
    theme('gmap', array('#settings' => $map));
    This will return the gmap with location marker.