Customizing the user login page is very simple, and uses the following concepts:
Use preprocess to set variables
register you template file in hook_theme
create templates and render your variables
Step 1:
/**
* Implements hook_theme().
*/
function hook_theme() {
$items = array();
$items['user_login'] = array(
'render element' => 'form',
'path' => PATH . '/templates',
'template' => 'user-login',
'preprocess functions' => array(
'hook_preprocess_user_login'
),
);
return $items;
}
Step 2:
function hook_preprocess_user_login(&$variables) {
$variables['render_text'] = 'You can add extra text and message';
}
Step 3:
Create you template file in your template folder
user-login.tpl.php
<div class="login-wrapper">
<h2><?php print t('SIGN IN'); ?></h2>
<?php
// split the username and password from the submit button so we can put in links above
print drupal_render($form['name']);
print drupal_render($form['pass']);
?>
<div class="login-links">
<?php print l(t('FORGOT YOUR PASSWORD?'), 'user/password', array('attributes' => array('class' => 'login-link'))); ?>
</div>
<?php
print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);
print drupal_render($form['actions']);
?>
</div><!--//login-wrapper-->
Step 4:
Clear drupal cache
Web Development Information [PHP, DRUPAL, MYSQL, MAGENTO, JQUERY, JAVASCRIPT, CSS, HTML5]
Wednesday, May 27, 2015
Wednesday, April 15, 2015
Add custom file extension in PHP application
We can add custom file extension in Apache PHP application. We can add our custom file extension instead of .php
For example, index.xyz instead of index.php
Open httpd.conf located in apache/conf folder
Find " <IfModule mime_module> "
Add " AddType application/x-httpd-php .xyz "
Restart your apache server
For example, index.xyz instead of index.php
Open httpd.conf located in apache/conf folder
Find " <IfModule mime_module> "
Add " AddType application/x-httpd-php .xyz "
Restart your apache server
Thursday, March 5, 2015
Status messages not removing with Commerce Ajax Cart
Use ajax_command_remove() command to remove the existing error messages while submit ajax add to cart button
$commands[] = ajax_command_remove('div.messages');
$commands[] = ajax_command_after('#main-content', theme('status_messages'));
$commands[] = ajax_command_remove('div.messages');
$commands[] = ajax_command_after('#main-content', theme('status_messages'));
Friday, January 30, 2015
Create an commerce order programmatically
The following steps to describe about to create an commerce order programmatically in Drupal
global $user;
$product_id = 100;
$quantity = 1;
$order = commerce_order_new($user->uid, 'cart');
commerce_order_save($order);
$line_item = commerce_product_line_item_new($product, $quantity, $order->order_id);
commerce_line_item_save($line_item);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_wrapper->commerce_line_items[] = $line_item;
commerce_order_save($order);
global $user;
$product_id = 100;
$quantity = 1;
$order = commerce_order_new($user->uid, 'cart');
commerce_order_save($order);
$line_item = commerce_product_line_item_new($product, $quantity, $order->order_id);
commerce_line_item_save($line_item);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_wrapper->commerce_line_items[] = $line_item;
commerce_order_save($order);
Thursday, December 4, 2014
Implement Jquery infinite scroll plugin
Plugin Source: https://github.com/paulirish/infinite-scroll/
Automatic Scroll:
$('selector').infinitescroll(options);
Manual Scroll:
$('#scroll-container').infinitescroll(options);
$('#scroll-container').infinitescroll('unbind');
$('.view_more').click(function() {
$('#scroll-container').infinitescroll('retrieve');
return false;
});
Note:
You may have to add the manual trigger behavior if you are working with masonry or isotope in order to make it work. Just include manual-trigger.js after infinitescroll and pass the behavior by passing behavior: 'twitter' when calling the plugin.
Automatic Scroll:
$('selector').infinitescroll(options);
Manual Scroll:
$('#scroll-container').infinitescroll(options);
$('#scroll-container').infinitescroll('unbind');
$('.view_more').click(function() {
$('#scroll-container').infinitescroll('retrieve');
return false;
});
Note:
You may have to add the manual trigger behavior if you are working with masonry or isotope in order to make it work. Just include manual-trigger.js after infinitescroll and pass the behavior by passing behavior: 'twitter' when calling the plugin.
Subscribe to:
Posts (Atom)