How to add seprate css for IE Browsers in Drupal Theme

It is very normal scenario  that your main css file is not affecting in IE browsers. For that, you will have to create separate css files and add those files in page.tpl.php inside your drupal theme.

Note:- Paste following code inside head tag in page.tpl.php file.
Code for adding css file in page.tpl.php :-

For IE6:-
<!--[if IE 6]>
     <link type="text/css" rel="stylesheet" media="all" href="<?php print $base_url;?>/sites/all/themes/splendapro/css/ie6_splenda.css" />
   <![endif]-->

For IE7:-
<!--[if IE 7]>
     <link type="text/css" rel="stylesheet" media="all" href="<?php print $base_url;?>/sites/all/themes/splendapro/css/ie7_splenda.css" />
   <![endif]-->

For IE8:-
<!--[if IE 8]>
     <link type="text/css" rel="stylesheet" media="all" href="<?php print $base_url;?>/sites/all/themes/splendapro/css/ie8_splenda.css" />
   <![endif]-->

Note:-The code above looks like commented but it is not.So use as it is.
 
For Safari browser:-
<?php    
   if (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== FALSE) {
          ?>
      <link type="text/css" rel="stylesheet" media="all" href="<?php print $base_url;?>/sites/all/themes/splendapro/css/safari.css" />
    <?php
    }
?>


Note:- Yo just need to change the css file path in above codes,and use the rest code as it is.

Add more dynamically in PHP

This is very common feature that you have to integrate add more feature in your application.
It could be use in adding input field or adding any div or anything.

Here I am giving steps to use this feature by simple example. In this example, I an dynamically adding First Name and Last Name in PHP form.

1.Use the following code to create dynamic form in PHP and save this file with .php extension.

File Name - index.php

<?php
$count = 0;
?>
<html>
<head>
<script type = "text/javascript" src = "jquery.js" ></script>
<script type = "text/javascript" src = "add_more.js" ></script>
</head>
<form method = "POST" action = "insert.php"> 
<div id = "count_<?php echo $count; ?>">
    FirstName<input type = "textfield" name = "firstname_<?php echo $count; ?>" value = ""><br><br>
    LastName<input type = "textfield" name = "lastname_<?php echo $count; ?>" value = ""><br><br>
</div>
<input type = "hidden" value ="<?php echo $count; ?>" name = "hidden_val" id = "hidden_val">
<input type = "button" id = "add_more" value = "Add More"><br><br>
<input type = "submit" name = "Submit" Value = "Submit">
</form>
</html>

2. Add JQuery library in your working directory. And create one java-script file in same working directory.
   In above example, I have included both JS files. Paste the following code in your java-script file.

File Name - add_more.js

 $(document).ready(function() {
 
  $("#remove").hide();
  $('#add_more').click(function() {
        return addMore();
    });
});

function addMore(){
  var hidden = parseInt($("#hidden_val").val());
  var countNewVal = hidden+1;

$('#count_'+hidden).append('<div id="count_'+countNewVal+'">FirstName<input type="textfield" value="" name="firstname_'+countNewVal+'"><br><br>LastName<input type = "textfield" name = "lastname_'+countNewVal+'" value = ""><br><br></div>');
$("#hidden_val").val(hidden+1);
}
In java-script file, I am increasing count value by 1 after every click on Add More button, And assigning that value to the hidden_val id. 

Note:- Please do not forget to add the jquery library in your working directory.  



How to enable clean url in Drupal

There are two ways to enable Clean URLs feature in Drupal.
1. You can navigate to Drupal admin and inside Site Configuration, click on Clean URLs.
    Enable radio button and click Save Configuration.

2. This way of enabling Clean URLs is most important. Because sometimes after installing new Drupal instance, By    default Clean URLs feature will not work. To enable it, follow these steps.        
  • Go to the Apache configuration file in following path:-                                                                      C:\wamp\bin\apache\Apache2.2.11\conf  //change the path according to your working directory
  •  Now open httpd.conf file. Search for mod_rewrite.so keyword and enable the same line by removing # in front of that. 
  • Restart Apache server and now again navigate to clean url in Drupal admin, You will see that clean url feature is enable now. You can enable radio button and Save Configuration.