Tuesday, January 29, 2013

How to autopost content from my site to facebook

How to autopost content from any site to facebook page.
first of all do these steps.....

1. Create a facebook page. i.e-facebook.com/abc.

2. After that create a apps in facebook which post our node to facebook page. www.developer.facebook.com. And create an apps. ie:- test and configure it looks like that...



3. After that we also configure it


4. Then save it.

5. Install fbautopost module and enable it. Install from http://drupal.org/project/fb_autopost
and configure it goto-mysite.com/admin/structure/fb
and goto stream post tab and create  Facebook's Graph Explorer token and fill text box save it.

6. And create content any and enable post on facebook and give its page name and save it. That post it on facebook page .if no any mistake.

After that enjoy it.

Tuesday, January 22, 2013

How to create Mega Photo gallery in Drupal 7

If you want to create mega Photo gallery in drupal 7 looks like below....

then follow some simple steps ..

1. First off all create a content type Gallery.

2. And add a image field configure it Number of value : Unlimited

3. Save it and add some content in Gallery content type.

4.  Add this line to default theme`s template.php

function bartik_process_page(&$variables) {
drupal_add_js(drupal_get_path('theme', 'bartik') . '/js/jquery.mousewheel-3.0.6.pack.js');
drupal_add_js(drupal_get_path('theme', 'bartik') . '/js/fancybox/jquery.fancybox.pack.js');
drupal_add_css(drupal_get_path('theme', 'bartik') . '/js/fancybox/jquery.fancybox.css');
$fancybox = "jQuery(document).ready(function() {
    jQuery('.fancybox').fancybox();
});";
drupal_add_js($fancybox, 'inline');
}

If this function already present in templete.php, then only add this line in between this function.


drupal_add_js(drupal_get_path('theme', 'bartik') . '/js/jquery.mousewheel-3.0.6.pack.js');
drupal_add_js(drupal_get_path('theme', 'bartik') . '/js/fancybox/jquery.fancybox.pack.js');
drupal_add_css(drupal_get_path('theme', 'bartik') . '/js/fancybox/jquery.fancybox.css');
$fancybox = "jQuery(document).ready(function() {
    jQuery('.fancybox').fancybox();
});";
drupal_add_js($fancybox, 'inline');


5. After that add custom template in template folder.Just like node--gallery.tpl.php
In this file that code are....


<div id="node-<?php print $node->nid; ?>" class="node-gallery">
<?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2  style="text-align:center;" <?php print $title_attributes; ?>>
      <?php print $title; ?>
    </h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>
    <?php
        $imgcount = count($node->field_image['und']);
        for ($i = 0; $i < $imgcount; $i++) {
        $image_uri = $node->field_image['und'][$i]['uri'];
            // url
            $masthead_raw = image_style_url('gallery', $image_uri);
    ?>
      <a href="<?php print file_create_url($node->field_image['und'][$i]['uri']); ?>" rel="group-<?php print $node->nid; ?>" class="fancybox">
        <img class="image<?php print ($i + 1);?>" src="<?php print $masthead_raw; ?>" />
      </a>
    <?php } ?>
</div>


6. Add a view its name gallery.


After that look my gallery its looks like...



Sunday, January 20, 2013

Database Data Fetching using Db_query Codee

<?php 
global $user; 
$userid=$user->uid; 

$result = db_query('SELECT n.mett_score FROM {training_score} n WHERE n.uid = :uid', array(':uid' => $userid)); 

foreach ($result as $record) { 
echo 'Your Score is:'; print_r($record->mett_score); 
// or Aply This Code  
echo '<br/>' .'You Score Is:' .$record->mett_score; 
} 
?>