Thursday, December 26, 2013

Create relationships within users

https://drupal.org/project/user_relationships
https://drupal.org/files/project-images/Selection_035.jpeg
This module is abig one which you can use to create relationship betwwne them

remember

you need to set permissions in oreder to make it functional

add relationship types form admin

admin/config/people/relationships/add

manage

admin/config/people/relationships

then assign permissions 

and first assign permission to view other people profiles. View user profiles under user so that users can send request to each other.







Simple and good module to adds Terms of Use and a [x] I agree check box to the registration page.


https://drupal.org/files/images/terms_of_use_0.jpg

Terms of Use

https://drupal.org/project/terms_of_use

This module adds Terms of Use and a [x] I agree check box to the registration page.

The Multiselect module defines a widget to be used with CCK fields

Multiselect Screenshot

This modules will add a widget named  Multiselect when you add a list field 

https://drupal.org/project/multiselect

Tuesday, December 24, 2013

Save node of Content Type Programatically

We can save a node of any content type programatically in Drupal It Rocks!!

 $node = new stdClass(); 

// Set content type
$node->type = 'product';
 
// Prepare defaults
node_object_prepare($node);

$node->language = LANGUAGE_NONE;
 
// Define language (currently language neutral)

 
// Basic content
$node->title = 'Save Content Type Node Programatically!!';
$node->body[$node->language][0]['value'] = 'Body text';

         //CCK or Added fields
$node->field_product_email[$node->language][0]['value'] = 'save@gmail.com';
 
// Save node
node_save($node);

Saturday, December 21, 2013

Play Video in Drupal (FlowPlayer)

Install

https://drupal.org/project/flowplayer

Add a field to your content named suppose named field_upload_videos assing some aloowed extension to it 

And then add below code to your Tpl File

<?php
  $video = '<a href="'.$base_path.'/sites/default/files/videos/'.$node->field_upload_videos[und][0][filename].'" id="player" class="flowplayer"></a>';
  flowplayer_add('#player', array(
    'clip' => array(
      'autoPlay' => FALSE, // Turn autoplay off
      //'linkUrl' => '/sites/default/files/videos/truduo.mp4', // When clicked on
    ),
  ));
print $video;
?>


You are done Enjoy!!.

Monday, December 16, 2013

Load Profile2 fields

global $user;

$profile = profile2_by_uid_load($user->uid, 'main');  

//Get exact field names by printing the array.

print "<pre>"; print_r($profile); print "</pre>"; // to know yourm all fields name

//Example to print profile fields 

print $profile->field_business_name['und'][0]['value'];

print $profile->field_first_name['und'][0]['value'];

print $profile->field_business_address['und'][0]['value'];

print $profile->field_street_address['und'][0]['value'];

print $profile->field_address_line_2['und'][0]['value'];

print $profile->field_country['und'][0]['iso2'];

print $profile->field_state_province_region['und'][0]['value']];

print $profile->field_city['und'][0]['value']];

print $profile->field_postal_zip_code['und'][0]['value']];

print $profile->field_phone['und'][0]['value'];

print $profile->field_fax_number['und'][0]['value'];

Save Profile 2 fields manually

global $user;

if(in_array('business membership', $user->roles)) {
  $profile = profile2_by_uid_load($user->uid, 'business_membership');
}
else { 
  $profile = profile2_by_uid_load($user->uid, 'main'); 
}
if(isset($_REQUEST['saveprofile'])) {
  if($_FILES["field_your_profile_photo"]["name"]) {
$filename=uniqid().$_FILES["field_your_profile_photo"]["name"];
$_FILES["field_your_profile_photo"]["type"];
$_FILES["field_your_profile_photo"]["size"];
$_FILES["field_your_profile_photo"]["tmp_name"];
 move_uploaded_file($_FILES["field_your_profile_photo"]["tmp_name"],$_SERVER['DOCUMENT_ROOT']."/goodstreet/sites/default/files/product/" .$filename);
//print $profile->field_business_name['und'][0]['value'];
$image_path = 'public://product/'. $filename;
$image_info = image_get_info($image_path);
   //print_r($image_info); exit();
// create file object
$file = new StdClass();
$file->uid = $uid;
$file->uri = $image_path;
$file->filemime = $image_info['mime_type'];
$file->status = 0; // Yes! Set status to 0 in order to save temporary file.
$file->filesize = $image_info['file_size'];
print $file->filename=$filename;
file_save($file);
$profile->field_your_profile_photo = array(
'und' => array(
0 => array(
'fid' => $file->fid,
'filename' => $file->filename,
'filemime' => $file->filemime,
'uid' => $uid,
'uri' => $file->uri,
'status' => 1
)
)
);
}
$profile->field_business_name['und'][0]['value']=$_REQUEST['field_business_name'];
//$profile->field_your_profile_photo['und'][0]['uri']='public://product/'. $_FILES["field_your_profile_photo"]["name"];
//$profile->field_your_profile_photo['und'][0]['filename']=$_FILES["field_your_profile_photo"]["name"];
$profile->field_business_address['und'][0]['value']=$_REQUEST['field_business_address'];
$profile->field_street_address['und'][0]['value']=$_REQUEST['field_street_address'];
$profile->field_address_line_2['und'][0]['value']=$_REQUEST['field_address_line_2'];
$profile->field_country['und'][0]['value']=$_REQUEST['field_country'];
$profile->field_state_province_region['und'][0]['value']=$_REQUEST['field_state_province_region'];
$profile->field_city['und'][0]['value']=$_REQUEST['field_city'];
$profile->field_postal_zip_code['und'][0]['value']=$_REQUEST['field_postal_zip_code'];
$profile->field_phone['und'][0]['value']=$_REQUEST['field_phone'];
$profile->field_fax_number['und'][0]['value']=$_REQUEST['field_fax_number'];
profile2_save($profile);
//user_save($existingUser, $edit);
//echo "<pre>"; print_r($user); echo "</pre>";
//print $user->init;
drupal_goto('profile-business_membership');
}