Add CSS files and JavaScript files at the bottom of a page in Drupal 7

template_preprocess_html() in template.php file. Preprocess variables for html.tpl.php
 

function themename_preprocess_html(&$variables) {

  // Add external file
  drupal_add_css('https://fonts.googleapis.com/css?family=Roboto:400,300,500,700',array('type' => 'external'));

  // Add Javascript file at the bottom of a page
  drupal_add_js('/sites/all/themes/purple/js/bootstrap.min.js', array('type' => 'file', 'scope' => 'footer', 'weight' => 10));

}

 

How to render menu programatically in Drupal 7?

In template.php file you can add the below code:

$menu = menu_tree_output(menu_tree_all_data('main-menu', null, 1));
$variables['menu'] = drupal_render($menu);

Page.tpl.php (render the main menu tree in the page.tpl.php like this.)
<?php print $menu; ?>

menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL)
[https://api.drupal.org/api/drupal/includes!menu.inc/function/menu_tree_all_data/7]
 

Installation PHP, Apache, MySQL, PhpMyAdmin On Ubuntu

sudo apt-get update
sudo apt-get upgrade (optional)

MySQL
=====
sudo apt-get install mysql-server mysql-client

Apache
=====
sudo apt-get install apache2

PHP
===
sudo apt-get install php5 libapache2-mod-php5 php5-mysql

Restart Apache
===========
/etc/init.d/apache2 restart

PHPMyAdmin
==========
sudo apt-get install phpmyadmin

I don’t like to use Apache’s default http folder /var/www so I need to update the apache2.conf file:
sudo gedit /etc/apache2/apache2.conf

Clean URLs with Apache 2 on Ubuntu

Open terminal: Ctrl+Alt+T

1)  sudo a2enmod rewrite
2) sudo apache2ctl -M   (and seeing if rewrite_module is on the list.)
3) sudo gedit /etc/apache2/sites-available/default
4) change text "AllowOverride None" to "AllowOverride All"
5) sudo /etc/init.d/apache2 reload

 

If you are running Ubuntu 14.04+:
sudo gedit /etc/apache2/apache2.conf
Otherwise:
sudo gedit /etc/apache2/sites-available/default

Refer: https://www.drupal.org/node/134439

Building Multistep forms using the Drupal 7 CTools object cache

http://drupalcontrib.org/api/drupal/contributions!ctools!includes!object-cache.inc/7The non-volatile object cache is used to store an object while it is being edited, so we don't have to save until we're fully finished. The cache should be "washed" on a periodic basis, meaning to remove ancient items from the cache, but otherwise the information in this cache must stay stable, as it contains unsaved modifications.

Building Multistep forms using the Drupal 7 CTools object cache

multi_step.info 
 name = MultiStep  
 description = Custom Multistep form module.  
 core = 7.x  
 dependencies[] = ctools  

500 – Internal server error from IIS on Windows server

Open a web.config file in root folder & add this line  <httpErrors errorMode="Detailed" />

Ex:
 <system.webServer>
 ..................................... 
// comment below lines
 <!--<httpErrors>-->
      <!--<remove statusCode="404" subStatusCode="-1" />-->
      <!--<error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />-->
 <!--</httpErrors>-->
........................................

 // Add this line 
 <httpErrors errorMode="Detailed" />
</system.webServer>

Drupal 7 - Using Ctools modal popup node view with comments

<?php
/**
 *  Implements of hook_menu() 
*/
function hook_menu() {
  $items = array();
  $items['pop/%ctools_js/%'] = array(
    'page arguments' => array(1, 2),
    'page callback' => 'pop_modal_page',
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

function pop_modal_page($js = NULL, $nid) {
  if ($js) {
    ctools_include('modal');
    ctools_include('ajax');
  } else return 'Your browser does not support javascript';

Drupal 7 Cron Jobs in GoDaddy

Cron Job Manager Command:

wget -O - -q -t 1 "http://<your-domain>.com/cron.php?cron_key=<your-key>"

 

Drupal 7 Run Elysia cron on every Minute using crontab

* * * * * wget -O - -q -t 1 http://your-site-name/sites/all/modules/contrib/elysia_cron/cron.php?cron_key=

[Minute] [hour] [Day_of_the_Month] [Month_of_the_Year] [Day_of_the_Week] [command]

Edit/List Jobs in Crontab
# crontab -e
# crontab -l
# crontab -u -l
# crontab -u (username) -l

Refer: How to Install Crontab in CentOS/RHEL 7/6/5
http://tecadmin.net/install-crontab-in-linux
http://tecadmin.net/crontab-in-linux-with-20-examples-of-cron-schedule/

Login attempts when more than 5 attempts failed - [Resolved]

TIPS FOR CLEAR DRUPAL FLOOD TABLE

Drupal 7 avoids brute force targeting the accounts. When more than five efforts failed, it does so by denying the login efforts. In the flood table, the quantity of unsuccessful logins is reported. With the procedure below, you can either wait to login again or tidy the flood table up.

When you have forgotten your password, create a new password and refresh the database.

In Drupal database, execute the following request:

DELETE FROM `flood`;