Embed a view inside a node in Drupal 7

We can embed a view created by Views module inside a node in Drupal 7 with just some short code. Here is the code:

<?php
    $view = views_get_view('your_view_name');
    $view->set_display('your_view_display_name');
    $output = $view->preview();
    // now print the view.
    if ($view->result) {
        print views_embed_view('your_view_name', $display_id = 'your_view_display_name');
    }
?>

Just put that in your node.tpl.php, and don't forget to change the views name and display name with yours.

Just switch to using Disqus

Previously I was using Blogger default commenting system, and recently I decided to switch using Disqus. I did this in order to have more organized comments, and it seems Disqus protection from spammers are also much better.

Previously I remove all of the comments, a lot of comments are just spam, so this is a perfect moment to put up new platform for this blog commenting system.

No significant change in the loading speed of this blog, and I think this is the best solution I have now.

Creating custom user login page in Drupal 7

Maybe sometimes we want a custom style for our Drupal login page, different with the existing default login page in Drupal 7, whether it's for a personal project or client requests.

Here is the simplest way to create a custom login page in Drupal 7.

First open the template.php and add the following code:

function yourthemename_theme() {
  $items = array();
  // create custom user-login.tpl.php
  $items['user_login'] = array(
  'render element' => 'form',
  'path' => drupal_get_path('theme', 'yourthemename') . '/templates',
  'template' => 'user-login',
  'preprocess functions' => array(
  'yourthemename_preprocess_user_login'
  ),
 );
return $items;
}

create a new folder "templates" and than creating user-login.tpl.php file and place it inside.

Open the user-login.tpl.php file and paste the following code:

<?php 
  print drupal_render($form['name']);
  print drupal_render($form['pass']);
  print drupal_render($form['form_build_id']);
  print drupal_render($form['form_id']);
  print drupal_render($form['actions']);
?>

add the wrapper such as div, span, etc. to test it. Don't forget to clear your Drupal cache.