Friday, February 22, 2013

Listing current user uploaded brightcove videos in drupal

If you want to list current user uploaded video in drupal, use below code.
Drupal brightcove module provides an option to store the Drupal username of the user who uploaded a video. You need to create this field(custom field) in brightcove before using this feature. Click here to understand how to create cutsom field in BC Studio.


Goto drupal brightcove configuration page and add this field name in "Brightcove Drupal User Custom Field" field. Brightcove module automatically update drupal username in brightcove while uploading new video into video cloud. The below function will fetch all the videos which uploaded by the user.


function video_list(){
  global $user;
 
  // Define our parameters
  $params = array();
  $user_field = variable_get('brightcove_user_field', '');
  // Set our search terms
  $terms = array(
    'all' => $user_field .':'. $user->name
  );
  
  // Make our API call 
  $videos = $bc->search('video', $terms, $params);
  // $videos contains all video which uploaded by the current user
  //write your code for display the result
}

Wednesday, January 30, 2013

How to use brightcove video Search in drupal


Brightcove video cloud, a cloud based video hosting and publishing solution. Drupal is one of the most commonly used open source CMS.

To integrates brightcove video cloud into drupal, drupal community provides one module called Brightcove module. . Using this module you can add Brightcove video to your content and access the information from the Video Cloud in your site.
 In brightcove module they are using Brightcove Media API and this APi provides various methods to retrieve properties from brightcove video cloud. But this module is mainly focusing on find method. So here I am trying to explain how to use search method in drupal. Search method is also a simple function to retrieve properties and information from Brightcove.

To call search method we need to pass three arguments - method, terms and params.Using this method we can search custom fields from brightcove. Here I'm explaining how to search custom fields value from brightcove using search method.

Below code shows how to search for a video with "jobs" in the title AND tags.
 
// Define our parameters
$params = array(
    'video_fields' => 'id,name,shortDescription'
);

// Set our search terms
$terms = array(
    'all' => 'display_name:jobs,tag:jobs'
);
  
 // Make our API call 
$videos = $bc->search('video', $terms, $params);

 Below code will explain how to search video with custom fields. 
custom field name is drupal_user and this field is used for storing uploaded user name(Drupal Username) in brightcove.


// Define our parameters
$params = array(
    'video_fields' => 'id,name,shortDescription'
);

// Set our search terms
$terms = array(
    'all' => 'drupal_user:jobs'
);
  
 // Make our API call 
$videos = $bc->search('video', $terms, $params);



Friday, October 5, 2012

How to create Virtual Hosts in Ubuntu

Virtual Hosting is a method for hosting multiple sites/domains in a single server. It helps to reduce the cost and can share the memory and processor cycle. In local host also we can create Virtual host and we can call original domain name(production/live domain) from our development environment(localhost). Here I am providing the steps for creating Virtual host in Linux/Ubuntu workstation.


i.  Assume your code resides at /var/www/yoursite

ii.  You can access your site using http://localhost/yoursite.

iii.  Edit vhosts file in sites-enabled. sudo gedit /etc/apache2/sites-enabled/vhosts.conf.

iv. Add below code in vhosts file

<VirtualHost *:80>
ServerName local.yoursite.com
ServerAlias www.local.yoursite.com
DocumentRoot /var/www/yoursite
</VirtualHost>
v. Open the file /etc/hosts in your editor.
vi. Add below lines of code.
127.0.0.1   local.yoursite.com
vii. Restart your apache server.
sudo /etc/init.d/apache2 restart
viii. Access http://local.yoursite.com to view your site in direct domain.
 

Saturday, September 1, 2012

How to convert milliseconds to date format in PHP

Normally date field is stored in database as timestamps format, the number of seconds since 00:00:00 UTC on January 1, 1970. Some times the date represented as the number of milliseconds.

There is no default function available in PHP to convert this milliseconds representation to human readable format. In PHP date function is used for converting timestamp format to local date/time format.

This following PHP function will convert milliseconds format to local date format

$milliseconds =  1340562600000;
$timestamp = $milliseconds/1000;
echo date("d-m-Y", $timestamp);

output = 25-06-2012

Monday, July 16, 2012

Find factorial using PHP

Function to find the factorial of the given value



function factorial($val){
  if($val == 1){
    return 1;
  }
  else {
     return $val*factorial($val-1);
   }
}



Friday, July 13, 2012

Redirect all users to access the site with 'www' prefix using htaccess file

We can redirect the site url to "www" prefix, whether the user is accessing the site without "www" prefix by adding rewrite url in .htaccess file in root folder.

add following lines in .htaccess file to add www prefix.

 RewriteEngine on

 RewriteCond %{HTTP_HOST} ^yoursitename\.com$ [NC]

 RewriteRule ^(.*)$ http://www.yoursitename.com/$1 [L,R=301] 


Similarly we can remove "www" prefix from the url and redirect to without "www" by adding following lines in .htaccess file


 RewriteEngine on

 RewriteCond %{HTTP_HOST} ^www\.yoursitename\.com$ [NC]
 RewriteRule ^(.*)$ http://yoursitename
.com/$1 [L,R=301] 


Thursday, April 12, 2012

CSS fix for Chrome IE7 and IE8

In some cases we need to add browser specific css properties for the site, like separate css for IE 7 and IE8 to acheive the correct layout. To acheive that we can use different methods - 1. add custome CSS file for each browser and 2. Add custom properties in the main CSS

Here I am specifying how to add separeate css properies for Chrome, IE 7 & IE8 in the main CSS file.

Chrome

Google Chome is the fast growing web browser. Some times the site layout will break and need to alter css property for this particular browser.
To fix CSS issues for Chrome use body:nth-of-type(1) .elementOrClassName{property:value;}.
Eg: body:nth-of-type(1) .sitename{margin:20px;}
HTML
<div class="sitename"></div>

IE8

For IE8 use inline css hack "\0/".
.elementOrClassName{property:value;\0/}
Eg: .sitename{margin:20px;\0/}

IE7

* (star) can be used as the inline hack for ie7
.elementOrClassName{*property:value;}
Eg: .sitename{*margin:20px;}

IE6

_ (underscore) can be using for ie6
.elementOrClassName{_property:value;}
Eg: .sitename{_margin:20px;}

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Maintained by Web Themes