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.

Top Ten Free Professional Drupal Themes

Drupal has an amazing and clean code. Support of social networking, multimedia, SSL, event calenders, document management, blogging, forums, internationalization, user management and permission features, the ease of developing, ease of external integration, complex web sites, and the quality of add-ons for enhancing functionality. Yes Drupal is for the Geeks :)

Drupal has a power, stability and performance but not a good looking, it's hard to find a nice free themes for Drupal. Good looking is one of Drupal limitations, but this days lots web designer start to try out Drupal because the excellent usability improvements from Drupal.

Here's we choose a free Drupal themes for you:

Marinelli

Features:

  • Flexible 3 column system with 8 extra collapsible regions and a "top slide-box". You can move content on the right or in the middle from theme settings
  • Optional built-in megadropdown menu per Primary links: Just activate it in the theme settings page
  • Integrated rotating banners system based on jquery cycle: upload banners from theme settings and decide where to rotate them. Each banner con also point to an url to highlight content
  • Progressive enhancement with modernizr for css3 features
  • Better headings mangement. Now you can use headings even for primary links or megamenu (usefull for screenreaders)
  • Better css organization to improve theme customization
  • Semantic xhtml and attention to accessibility. With the proper theme settings you can accomplish WCAG2 AAA

Live demo.

Danland

Features:

  • 1, 2 or 3 column layout
  • Tableless design for SEO
  • More than 17 collapsible block regions
  • Superfish drop-down menu (2, 3 or more nested levels) and the shadow is enabled by default
  • Built-in image slideshow (the frontpage wide image banner)
  • Built-in IE transparent PNG fix
  • Custom front page
  • Wide image banner 950x355px. You can replace with your own photo for custom look
  • XHTML 1.0 and CSS 2.1 validated
  • User picture in profile, comments and post
  • Primary links and secondary links
  • Supports custom logo and favicon
  • Support features like site name, slogan, mission.
  • Custom login and logout
  • Heading H1 optimization for SEO
  • Support for local.css
  • CiviCRM friendly
  • Complete online documentation

Live demo.

Corporate Clean

Features:

  • (new) Responsive layout (7.x-2.x)
  • Color module integration
  • "Alignment" Color Scheme
  • Simple and clean design
  • Drupal standards compliant
  • (new) 12 Regions: Navigation, Search area, Highlighted, Content, First sidebar, Banner, Footer first, Footer second, Footer third, Footer, Footer bottom right, Help
  • (new) 1, 2 and 3-column layout support - Read more about columns layout support
  • (new) Superfish module Support - Learn how to implement Superfish menus
  • (new) Linked Superfish menu background/colors with core Color module
  • Multi-level drop-down menus (Multilingual menu support)
  • Jquery Slideshow based on the jquery cycle plugin:

Live demo.

BlueMasters

Features:

  • Custom frontpage with 4 block regions
  • Footer with 4 regions
  • A total of 12 regions
  • Implementation of a JS Slideshow
  • Extra banner region in front page ready to replace Example JS Slideshow (only in 7.x)
  • Multilevel CSS drop down menus (only in 7.x)

Live demo.

Corolla

Features:

  • 6 preset color schemes
  • Custom color options
  • Built in support for the Superfish module
  • Configurable layout - lots of options
  • Responsive Mobile support - Smartphone, Tablet, iPad, iPhone, Android devices etc
  • Font selection - includes Google fonts
  • Font size setting
  • Heading styles
  • Rounded corner settings
  • Box shadow and background texture options
  • Image position settings
  • Menu bullets option
  • Breadcrumb settings
  • Search results display settings
  • Optional horizontal login block setting
  • 18 regions including a 3 and 4 column panel

Live demo.

Acquia Marina

Features:

  • All the incredible features of Fusion, including a point-and-click layout, selectable block styles and icons, fluid width, configurable sidebars, typography settings, and more!
  • Bi-directional right to left (RTL) theming

Live demo.

Sky

Features:

  • 4 preset color schemes
  • Custom color options
  • Configurable layout - lots of options
  • Mobile support (smartphone, tablet, iPad, iPhone etc)
  • Font selection (includes 252 Google fonts!)
  • Font size setting
  • Heading styles
  • Rounded corner settings
  • Box shadow and background texture options
  • Image position settings
  • Menu bullets option
  • Breadcrumb settings
  • Search results display settings
  • Optional horizontal login block setting
  • 17 regions including a 4 column footer

Live demo.

Business

Features:

  • Simple, Minimal and Clean Design
  • Fixed Width (920px)
  • 1-column and 2-columns layout
  • Color module integration
  • Implementation of JS Slideshow (Customizable)
  • Multi-level drop-down menus (Multilingual menu)
  • HTML5 & super clean markup
  • A total of 12 regions
  • Drupal standards compliant
  • Custom front-page with 4 block regions
  • Configurable layout : Sidebar can be Right or Left
  • Use of Google Font and Nice Typography
  • Supported standard theme features: site logo, site name, site slogan, user pictures, favicon
  • Detailed CSS rules for Typography, Forms Elements, Node Teaser, Comments, etc.

Live demo.

Zero Point

Features:

  • 1, 2, or 3 column layout with adaptive width based on "The Jello Mold Piefecta Layout";
  • 17+1 collapsible block regions;
  • 7 colour styles;
  • built-in IE transparent PNG fix;
  • jQuery CSS image preload (optional);
  • Fixed / Variable width sidebars (optional);
  • Round corners for page elements and primary menu (optional);
  • Block icons (optional);
  • Page icons (optional);
  • SuckerFish Drop-down primary links menu (optional);
  • Primary links menu position (center, left, right);
  • Helpful body classes (unique classes for each page, term, website section, browser, etc.);
  • Full breadcrumb;
  • Works perfect in Multilingual installations.

Live demo.

Andromeda

Features:

  • 1-column and 2-columns layout
  • Drop down menu
  • Support for slideshow and highlight (tagline, mission, ...etc) region
  • Blog page support
  • Easy-grid system
  • Awesome support ;)

Live demo.

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.

Creating responsive Drupal theme (Simplified)

There are various ways to create a responsive Drupal theme, one of them is using template_preprocess_html() function in template.php.

First create template.php if your theme do not already have it. Than add below codes:

/**
* Preprocess html
*/
function themename_preprocess_html(&$vars) {

  drupal_add_css(path_to_theme() . '/css/smartphone.css', array('group' => CSS_THEME, 'media' => 'only screen and (min-width : 240px) and (max-width : 480px)', 'preprocess' => FALSE));

  $meta_viewport = array(
   '#type' => 'html_tag',
   '#tag' => 'meta',
   '#attributes' => array(
     'name' => 'viewport',
     'content' => 'width=device-width, initial-scale=1'
   )
  );

  drupal_add_html_head($meta_viewport, 'viewport');
}

It is clear if the minimum screen size of 240px and 480px maximum it will use smartphone.css, so please create smartphone.css in css folder and you can add your css code there.

Besides using template.php, you can also add the css via theme's info file like below

stylesheets[screen and (min-width: 240px) and (max-width: 480px)][] = css/smartphone.css
stylesheets[screen and (max-width: 320)][] = css/320.css

And do not forget to add meta viewport via template.php or Android devices will not recognize our responsive layout.

Clear your Drupal cache, once you make above changes.