Drupal Modules
more_horiz
close

on 09th March 2014 / by prasanna.tv
@font-your-face module helps us to manage web fonts in all popular browsers and it provides the user interface for applying web fonts. If you want to know "How to configure a @font-your-face module in drupal 7" then continue reading Download @font-your-face module from the link: http://drupal.org/project/fontyourface Enable Modules: (admin >> modules) Enable @font-your-face module Enable Submodules @font-your-face UI, Font Squirrel API, Fontdeck, Fonts.com, Google Fonts API, Local Fonts, Typekit API Add Permission for administrator (Admin >> people >> permissions) For enabling fonts Appearance >> @font-your-face >> browse all fonts >> browse fonts or google fonts ) Enable fonts from this list For enabling fonts for CSS selectors (Appearance >> @font-your-face) Select font for CSS selectors Click on " Save applied CSS selectors " for saving the fonts For enabling fonts By font (Appearance >> @font-your-face) Select font for corresponding css Click on " Save applied fonts " for saving the fonts For enabling fonts for theme (Appearance >> @font-your-face) Simply copy and paste the text below into your theme.info file. We would love to hear your feedback on this article and Drupal in general through our comments form below. Drupal Drupal Modules Drupal 7 Drupal Configuration Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 10th September 2013 / by webmaster
We have created and released a new module Boost Captcha to allow static page caching of pages with forms with captcha without running into the captcha session timeout errors. By helping boost cache more pages the module will allow for better performance without compromising on spam protection. The module loads the captcha in the form through an additional AHAH request once the user starts filling in the form. So if the user does not fill in the form the captcha will not be reloaded thus avoiding the additional bootstrap. The additional bootstrap will only be used when users fill the form. This is as opposed to the option of completely not caching the page at all. Typically when pages are statically cached for very long periods of time (longer than 24 hrs) the captcha session for the generated captcha in the form will expire and causing the form submission to result in a "CAPTCHA session reuse attack detected" error. Although the module is named boost captcha which is where we have run into this problem the most, the module should work well with any static page caching scenarios where the pages are to be cached for very long periods of time. You can read more about the working of the module at the Boost Captcha module page. Do try out the module and let us know via the Drupal issue queue if there are issues - https://drupal.org/project/issues/boost_captcha Drupal Free Software Drupal Modules Drupal Performance Boost Drupal Contributions Drupalgive Captcha Spam Prevention Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 10th September 2013 / by webmaster
We had recently worked with a client of ours to help port the Drupal 6 version of the Moneris Payment Gateway module for Drupal to Drupal 7. Moneris is a popular payment gateway in Canada. The upgraded module has been submitted in an issue under the Moneris issue queue - https://drupal.org/node/1276770. Once it is tested and verified by the community the maintainer will be pushing the code to the repository. The upgraded module currently does not support recurring subscriptions. If there are users who are looking to get recurring payment support enabled for Moneris in Drupal 7 we will be happy to help with the development and maintenance of the same. We would require that you allow us to contribute these changes back to Drupal.org :) Drupal Drupal 6 Drupal Modules Drupal Upgrade Drupal 7 Drupal Contributions Drupalgive Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 10th June 2013 / by thomas.john
In this article we will be explaining how an anonymous user can switch the theme of a Drupal site. This is the continuation of my previous article How to create Theme Switcher module for Drupal 7 Part 1? If you want to know how to create a theme switcher module for Drupal 7 then read on to know more. In this article we will look at how we can display the buttons to switch the themes on the site which includes a button to select a random theme. Now lets begin our module file named as fdt_theme_switcher.module. We are using the hook hook_page_build(), which will be used to call the other functions like fdt_theme_switcher_generate() which will return the theme switcher form as a string. We will also be adding a js file in the function. /** * Implements hook_page_build(). */ function fdt_theme_switcher_page_build(&$page) { //if(!user_access('administer')){ if(user_is_anonymous()){ $page['page_top']['theme_switcher'] = array( '#markup' => fdt_theme_switcher_generate()); drupal_add_js(drupal_get_path('module', 'fdt_theme_switcher').'/js/themeSwitcher.js'); } } /** * themeSwitcher.js */ (function ($) { Drupal.theme_switcher = Drupal.theme_switcher || {}; Drupal.behaviors.theme_switcher = { attach: function () { $('select#edit-theme').change(function() { $(this).closest("form").submit(); }); } }; })(jQuery);The function fdt_theme_switcher_generate() returns the value of the current theme and displays the theme switcher form. function fdt_theme_switcher_generate() { global $current_theme; $fdtpath="http://www.freedrupalthemes.net/customize-theme?n=$current_theme"; $output=""; $output.="<div id='top-bar'>"; $output.='<h2>Customize this theme</h2>'; $output.="<div id='top-bar-sub'>"; $output.=/*"Select a theme".*/drupal_render(drupal_get_form('fdt_theme_switcher_themeswitcher_form')); $output.="</div>"; $output.="</div>"; return $output; }Now lets call the form fdt_themeswitcher_form. In this form there are three buttons Next -> To goto next theme Previous -> To goto previous theme Random -> To display a random theme See the form array structure below function fdt_theme_switcher_themeswitcher_form($form, &$form_state) { global $current_theme; $options = fdt_theme_switcher_options(); $form['themeswitcher']['actions']['previous_theme'] = array( '#type' => 'submit', '#value' => t('Previous'), '#id' => 'previous_theme', '#submit' => array('fdt_theme_switcher_themeswitcher_form_previous_theme'), '#limit_validation_errors' => array(), ); $form['themeswitcher']['actions']['random_theme'] = array( '#type' => 'submit', '#value' => t('Random'), '#id' => 'random_theme', '#submit' => array('fdt_theme_switcher_themeswitcher_form_random_theme'), '#limit_validation_errors' => array(), ); $form['themeswitcher']['actions']['next_theme'] = array( '#type' => 'submit', '#value' => t('Next'), '#id' => 'next_theme', '#submit' => array('fdt_theme_switcher_themeswitcher_form_next_theme'), '#limit_validation_errors' => array(), ); return $form; }We will store the current theme name in a variable $current_theme and then pass it as a global variable. To display all the theme names in a select box we will use the function fdt_theme_switcher_options() and the value is stored in $options. See the code below function fdt_theme_switcher_options() { $options = array(); $themes = list_themes(); foreach ($themes as $name => $theme) { if ($theme->status) { $options[$name] = $theme->info['name']; } } return $options; }Next comes the form submit function. In the submit function, the values passed are the themename and baseurl as a global variable. We will store the theme name to variable $themeurl in format t/<theme_name>. Now the function return will call drupal_goto() with the corresponding theme name and enable it. See the submit function for each buttons For the option to select the random theme we will write a query to call a random theme name from the system table and pass this value as $themeurl. /* Function Called to display Random theme */ function fdt_theme_switcher_themeswitcher_form_random_theme($form, &$form_state) { global $base_url,$current_theme; $themes = list_themes(); $result = db_query("SELECT name FROM {system} WHERE type='theme' AND status=1 ORDER BY RAND() LIMIT 1"); foreach ($result as $record) { $build=$record->name; } $themeurl="t/".$build; $options = array( //'fragment' => '', 'query' => '', 'absolute' => TRUE, 'alias' => FALSE, 'prefix' => 'goto', 'external' => FALSE ); drupal_goto($themeurl,$options); }To get the value of the next theme we will try to write a query to select all the themes in descending order. Then we proceed to retrieve the position of each theme and store the corresponding theme name to that location. We will check each theme with the current theme and if it is found we will be able to get the next theme postion and subsequently the theme name from that position. Finally we pass this value as themeurl to the drupal_goto function. /* Function Called to display Next theme */ function fdt_theme_switcher_themeswitcher_form_next_theme($form, &$form_state) { global $base_url,$current_theme; $count_elements=0; $themes = list_themes(); $num_themes = count($themes); $result = db_query("SELECT name FROM {system} WHERE type='theme' AND status=1 ORDER BY name DESC"); foreach ($result as $record) { $count_elements = $count_elements+1; $build[$count_elements]=$record->name; if($build[$count_elements]==$current_theme){ if($count_elements!=1){ $themeurl="t/".$build[$count_elements-1]; $options = array( //'fragment' => '', 'query' => '', 'absolute' => TRUE, 'alias' => FALSE, 'prefix' => 'goto', 'external' => FALSE ); drupal_goto($themeurl,$options); } } } }For the 'Next' theme button, we will write a query to select all the themes in the ascending order and the process is repeated as previously. /* Function Called to display Previous theme */ function fdt_theme_switcher_themeswitcher_form_previous_theme($form, &$form_state) { global $base_url,$current_theme; $themes = list_themes(); $num_themes = count($themes); $theme_count= $num_themes; $count_elements = $num_themes - 1; $result = db_query("SELECT name FROM {system} WHERE type='theme' AND status=1 ORDER BY name ASC"); foreach ($result as $record) { $count_elements = $count_elements-1; $build[$count_elements]=$record->name; if($build[$count_elements]==$current_theme){ if($count_elements+1!=$theme_count-1){ $themeurl="t/".$build[$count_elements+1]; $options = array( //'fragment' => '', 'query' => '', 'absolute' => TRUE, 'alias' => FALSE, 'prefix' => 'goto', 'external' => FALSE ); drupal_goto($themeurl,$options); } } } }You can also refer the first part of this article at How to create Theme Switcher module for Drupal 7 Part 1? to see how we have used following hooks to view inner pages of the themes. hook_url_inbound_alter() -> Will strip the "t/<theme_name>" from the urls internally hook_url_outbound_alter() -> Rewriteall urls in the site to include the t/<theme_name> Feel free to send me your feedback using the comment form below. Web Development Drupal Drupal Themes Drupal Modules Drupal 7 Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 03rd June 2013 / by uttam.kotekar
Drupal modules can be defined as a collective set of functions that can be used to create certain features. There are two sets of Drupal modules - 'Contributed modules' and 'custom modules'. Contributed modules are modules that are contributed by Drupal users for general use whereas modules which we create to achieve certain functions are called 'custom' modules. If you want to know how to create a module on your own in Drupal 7, you may read on. To create a custom module in drupal 7, we require two files : .info(meta-data describing the module) .module(the module PHP code) file. The '.info' file contains the information describing the module you have created. In the '.module' file you can write any hooks or related PHP code. The steps to create a custom module in Drupal 7 are given below. Say, our module's name is Hello. Step 1: Create a folder called "hello" in sites/all/modules/custom. Step 2: Inside this folder, create a hello.info file. Make sure that the file name: and folder name is the same. Write the code below inside the hello.info file name = hello // Name of the module // The description for the module which will appear in module listing page. description = Custom Hello module package = hello core = 7.x This will creates a meta-data describing the module Step 3: Create another file called hello.module in hello directory. Inside the hello.module write the below code <?php // $Id: hello.module /** * @file * Custom functions for this site. */ In this file we can implement one or more hooks. Now you need go to /admin/build/modules where you will find your hello module. You need to enable the module and finally your custom module has been created. Hope this helps. Drupal Drupal Modules Drupal 7 Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 16th May 2013 / by nidhi.sen
One of our Drupal clients wanted us to display the different categories (taxonomy terms in Drupal speak) in their Drupal site as a tag cloud. If you are facing the same scenario in your Drupal site then read on to know how to create a tag cloud using the Drupal Cumulus module in your Drupal site. When we say 'tag cloud', we mean a visual display of different words(mainly categories) used in a web site. The tags(term given for such words/text) can be displayed in different fonts and colors depending on their importance in the Drupal site. These tags are normally hyperlinked and may be redirected to pages which they normally represent. First we need to download and install the Drupal Cumulus module . Then in the block configuration page (YOUR_SITE_URL/admin/structure/block), there will be an option to add a Cumulus block ('Add cumulus block' link will appear in the 'Blocks' page). Click on the 'Add cumulus block' and you will be redirected to 'YOUR_SITE_URL/admin/structure/block/add-cumulus-block' page where you can add a new cumulus block. For example, you need to enter the 'Block title', 'Vocabulary IDs to be included' etc. I have attached a screenshot on how it will appear after entering all the details. Please don't forget to add the block to any region listed in the dropdown box under 'Region settings'. The region specifies where the block will be displayed in your page(for example, left sidebar, right sidebar etc). You can also mention the pages in which the block needs to be displayed under the 'Visibility settings' options. We would love to hear your feedback on this article or any Drupal topic of your choice. Please use the comments form below. Web Development Drupal Drupal Modules Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 14th May 2013 / by jijimol.john
One of our Drupal clients who had been using the Drupal Ubercart module had requested us to change the status of the order after a user completes the Ubercart checkout completion process. If you are facing the same situation with Ubercart in your Drupal site and would like to know how to change the order status programmatically then read on to find out the solution. Our client's Drupal website could change the status of order after completing checkout . After successfully submitting a recurring product order payment, the status of the order is set to 'completed'. However in the same site, a user can purchase alacart items too. The client wanted us to implement a feature where when the user purchased alacart items with the recurring product then the order status should be set to 'payment_received' which otherwise was set to display 'completed'. Here is how we changed the order status programmatically. This code has to be added in the checkout complete function /** * ubercart checkout complete function */ function hook_uc_checkout_complete($order, $account) { //get recurring product from cart contents $recurring_products = uc_recurring_product_get_recurring_products_in_order($order); //get all product from cart $cart_contents = uc_cart_get_contents(); //get alacart items from cart contents // filter alacart items from cart contents. if (!empty($recurring_products)) { foreach ($cart_contents as $cart_key => $cart_value) { foreach ($recurring_products as $recur_key => $recur_value) { if ($cart_value->model !=$recur_value['model'] ) { // this array contain alacart items $purchased_alacart[$cart_key] = $cart_value; } } } } //assign status value. if (empty($purchased_alacart)) { $status = "completed"; } else { $status = "payment_received"; } // update the status to the order uc_order_update_status($order_id , $status); // if you want anything add to order comments uc_order_comment_save($order->order_id, $user->uid,$message, 'order', $status); } Web Development Drupal PHP Drupal 6 Drupal Modules Ubercart Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 13th May 2013 / by chithra.k
On a recent Drupal project we had developed, we had to use the Drupal date module to display the date in a popup in a custom form. However we noticed that a date description was appearing on the form. If you are facing the same situation in your Drupal site then read on to know how to remove the default date format option added by the date module. We used the following code to display the pop-up date in our custom form. <?php $form['from_date'] = array( '#type' => 'date_popup', '#date_format' => 'Y-m-d', '#title' => t('Date:'), '#date_label_position' => '', '#description' => '', '#size' => 10, '#required' => 'true', ); ?>When we added the above code to the form, the date pop-up appeared but with an additional date format option.(Refer the screen shot).While using a pop-up, we don't need the format, right?. So here is how we got rid of the text. We have two solutions for this, one which is 'tricky' and the other which is 'proper'. The easy way The easiest way is to hide the class using CSS. However we won't recommend this as this is not the correct way to do this. The genuine Drupal way(Strictly our opinion). The correct way is to alter the element information using hook_element_info_alter. For eg: /** * implements hook_element_info_alter() * */ function hook_element_info_alter(&$type) { if (isset($type['date_popup'])) { $type['date_popup']['#process'][] = 'mymodule_date_popup_process_alter'; } } /** * function to remove the description from date_popup * */ function mymodule_date_popup_process_alter(&$element, &$form_state, $context) { unset($element['date']['#description']); return $element; }Inside the hook_info_alter, we have called a custom function, if the element type is a date_popup. Inside the custom function, we had simply removed the description from the date element by unsetting it. Hope this works for you too. Drupal Drupal Modules Drupal 7 Leave a reply Your email address will not be published. Required fields are marker * vicky456 (not verified) access_time 23 May 2019 - 08:25 In my drupal modules I was unable to create the default date as it was showing many errors. But when I did as per the instruction that is hared here it works. Default date option is very simple to create in the drupal sites Add new comment
more_horiz
close

on 30th November 2012 / by chithra.k
One of our clients requested us to come up with a Drupal based web application to generate a PDF file from an HTML template. The client's site which runs on Drupal 7 allows users to create envelopes based on the custom designs submitted by the user through that Drupal website. The online envelope editor uses an HTML template during the edit phase of the envelope and generates a PDF file of the sample template when the edit process is completed. If you are looking to know how to generate a PDF file from an HTML template using dompdf then read on. To bring out the Drupal application we decided to use the dompdf library. The dompdf library is an HTML to PDF converter written in PHP. It is capable of reading external style sheets, inline style tags and the style attributes of individual HTML elements and includes support for most presentational HTML attributes. Follow the steps below to setup the functionality in your Drupal site. First download the Drupal Print module along with the dompdf library. (The print module can be used to print a pdf file but to generate a pdf from a field of a node you need to use the dompdf library) Simply download and place the Print module insites/all/modules directory of your Drupal site. There is no need to enable the module Now place the uncompressed dompdf library insidesites/all/modules/print/lib Now place the following code in one of your custom modulesrequire_once("sites/all/modules/print/lib/dompdf/dompdf_config.inc.php"); $html = 'content' // you may add your content here $dompdf = new DOMPDF; $dompdf->load_html($html); $dompdf->render(); // This does not save the pdf field and instead it opens a dialog box asking whether you have to save the pdf or not $dompdf->stream("sample.pdf"); If you want to save the pdf somewhere safe in your Drupal site use the code belowrequire_once("dompdf_config.inc.php"); require_once("sites/all/modules/print/lib/dompdf/dompdf_config.inc.php"); $html = 'content' // you may add your content here $dompdf = new DOMPDF; $dompdf->load_html($html); $dompdf->render(); $pdfoutput = $dompdf->output(); // Checks whether there is an output folder inside sites/default/files if (!is_dir('public://output')) { mkdir("public://output", 0777); // Creates a folder and changes its permissions} $filename = 'sites/default/files/output/' . 'sample.pdf' $fp = fopen($filename, "w+"); fwrite($fp, $pdfoutput); // Writes the pdf output to a file fclose($fp); Now you should be able to genrates PDF files easily from any HTML template files in your Drupal site. Are you looking for a way to build a similar high quality web application using Drupal? We are Drupal experts and we can provide a wide range of Drupal module development services to get you started with your application. Get in touch with us to know more. Drupal Drupal Modules Drupal 7 Leave a reply Your email address will not be published. Required fields are marker * Devon Warren (not verified) access_time 23 May 2019 - 08:25 This was very helpful, thank you! Did you figure out how to get rid of the headers already sent error on the next page though? I am running this code on a function called as the page callback of a menu hook. Anonymous (not verified) access_time 23 May 2019 - 08:25 replace: $html = 'content' // you may add your content here for: $html = 'content'; // you may add your content here Also to get the code working on a standard node page: require_once("sites/all/modules/print/lib/dompdf/dompdf_config.inc.php"); $html = 'content'; // you may add your content here $dompdf = new DOMPDF; $dompdf->load_html($html); $dompdf->render(); // From captcha-module: // If output buffering is on: discard current content and // disable further buffering if (ob_get_level()) { ob_end_clean(); } drupal_add_http_header('Content-Type', 'application/pdf'); // This does not save the pdf field and instead it opens a dialog box asking whether you have to save the pdf or not $dompdf->stream("sample.pdf"); exit(); Barnad Bhat (not verified) access_time 23 May 2019 - 08:25 This was very helpful, thank you! Did you figure out how to get rid of the headers already sent error on the next page though? I am running this code on a function called as the page callback of a menu hook. dan french (not verified) access_time 23 May 2019 - 08:25 I am french and i don't speak English very much. I use your code and i have "fatal error in DOMPDF not found". I have a module and the submit execute your code after installation of "print and dompdf library. Thanks for your help Kushal I S (not verified) access_time 23 May 2019 - 08:25 Thanks Chithra the above code is worked for me. Add new comment
close

on 30th November 2012 / by kiran.kumar
One of our clients required us to create a Drupal based web application to generate QR code from text in their Drupal site. If you are looking for a way to generate QR code from any text in your Drupal site then read on to find out more . The QR code which is an abbreviation for Quick Response Code was developed in Japan in the early 90’s as a 2d matrix bar code and it has gained rapid popularity since it could be used on any kind of print media to deliver machine readable encoded information. Follow the steps below to enable your site to generate QR code. Firstly we need to get hold of the QR code library Copy and paste the uncompressed library file to sites/all/libraries/phpqrcode/ in your Drupal site. With that settled we are going to write the code for generating the QR code for any given piece of text. You could place the following code in the node preprocess function in the template.php file of one of the themes. //defining the base path of your Drupal installation global $base_url; function theme_name_preprocess_node(&$vars) { // First we need to create the path for the img which will be generated as a png file. // This will be automatically created using the code below $qrpath = variable_get('file_public_path', conf_path() . '/files') . "/images/" . $vars['nid'] . '-C-qr.png'; // This is the data to be added to the QR code. $text = "Some text"; // If the path is available we proceed to generate the form if (!file_exists($qrpath)) { $qrpath = theme_name_qrcode($text , $qrpath); } // This will print the path to the image in a theme $vars['qrimgpath'] = $qrpath; } function theme_name_qrcode($text , $qrpath) { // Including the qrcode library and generating the code include("sites/all/libraries/phpqrcode/qrlib.php"); QRcode::png($text, $qrpath); return $qrpath; } Hope that helps Are you looking for a way to build a similar high quality web application using Drupal? We are Drupal experts and we can provide a wide range of Drupal module development services to get you started with your application. Get in touch with us to know more. Web Development Drupal Modules Drupal 7 Leave a reply Your email address will not be published. Required fields are marker *