Wednesday, 20 November 2013

Jquery function to auto scroll to the page to any position in Javascript

Please find the below function to make auto scroll of the page based on the parameter provided.

/** Auto Scroll to Top. */
var autoScrollToTop = function (value) { 
 
 //var scrollTopVal = 90; 
 if (typeof value == 'undefined') { 
  var scrollTopVal = 90;
 }
 else if ((value != "") && isNaN(value)) {
  scrollTopVal = $(value).offset().top;
 }
 else if (value > 0 ) {
  scrollTopVal = value;
 }
 //alert(scrollTopVal);
 $('html, body').animate({ scrollTop: scrollTopVal }, 500); // 500 (mili second) or 'slow'
};

// The function can be called as below;
autoScrollToTop() // Type: Blank, (Default:90)-> Scroll to 90px from top.
autoScrollToTop(0) // Type: Zero -> Top scroll to very top
autoScrollToTop(150) // Type: Numeric -> Scroll to Provided Numeric value(150px) from top.
autoScrollToTop('.className'); // Type: 'className' -> Auto calculate the distance from top to that className component
autoScrollToTop('#elementID'); // Type: 'elementID' -> Auto calculate the distance from top to that elementIDcomponent


Wednesday, 30 October 2013

Codeigniter Pagination problem to locate the current page (if using CI default Library), AJAX Pagination Calls

If you are using default CI Pagination library then it would be chances of displaying the current page active although results status is displaying correctly.

In particular, when you are using config/routes.php to rewrite the URLs.

Well, if that case, you can resolve that issue by adding the uri_segment's value while initializing the pagination as below;

PS:  First find which segment of URI carries the page value, then add the segment value (not page value coz once you provide segment value then, it will use it to pull out the page value)
// Locate the uri_segment to locate the current page value.
$pagination['uri_segment'] = 3; 
Also, if you are wondering how to find the uri_segment value, then use below code to print all uri_segments array
$segments = $this->uri->segment_array();
print_r($segments);
Please find the sample pagination code as below;
$pagination = array();
$pagination['start']  = $start+1;
$pagination['limit']  = $limit;
$pagination['per_page'] = $limit;
$pagination['ipage']  = $ipage;
$pagination['total_rows'] = $this->m_yourmodel->function_result_count($where=array()); // only pull the approved ones.
$pagination['anchor_class'] = 'class="loadAjaxPage" '; // This class is added to make a AJAX Call if you want to load the pages via AJAX
$pagination['offset']  = ($start+$limit); // This is just for the View;

$pagination['uri_segment'] = 3; // Locate the uri_segment to locate the current page value.

$this->load->library('pagination');
$this->pagination->initialize($pagination);
a$pagination['page_links'] = $this->pagination->create_links();

To Load the Page from AJAX Call
Also I have added the loadAjaxPage class name on anchor_class pagination variable to load the page from AJAX calls.
// This class is added to make a AJAX Call if you want to load the pages via 
$pagination['anchor_class'] = 'class="loadAjaxPage" ';

Friday, 25 October 2013

How to configure WorldPay Payment System with WooCommerce

To configure WorldPay Payment System with WooCommerce
Please configure the WorldPay setting as per below image.

The Pay Back Response URL should the URL of the website where you want to revert/redirect back once the Payment is Successful or Failure.

Also, on that response page, you can use $_POST / $_REQUEST variables to collect the payment response data and manipulate it as per your needs.

Tuesday, 1 October 2013

How to change the Folder/File permissions from Plesk Control Panel for Windows Server

To change the Folder/File permissions from Plesk Control Panel for Windows Server

For users on Plesk for Windows:
  1. Login to Plesk control panel using the URL  https://webX.3essentials.com:8443 X=10,12,14,16,18 (Refer welcome email for credentials)
  2. Click on the domain name for which you want to change the permission.
  3. Click on the File Manager icon, You will see a few folders like private,httpdocs,httpsdocs These are base folders and if you need to give permissions to any of these as a whole, you need to submit a support request.
  4. Click on the httpdocs folder.You will mostly need to set permission for the files/folders inside the httpdocs folder, which is the root folder of your domain
  5. Decide the file/folder you want to set permission,and towards the right side of that you will see a 'lock' symbol  ,Click on that
  6. You'll see a list of Group or user names (like those listed in the follow bullets) and towards the right side of that you'll see permissions for that user:
    • Administrators
    • SYSTEM
    • Plesk Domain User (number)
    • FPSE_number
    • Plesk IIS User (IUSR_number)
    • Plesk IIS WP User (IWPD_number(number))
  7. This is where you need to set permissions.
    • For php scripts add MODIFY to your IUSR account
    • For asp: add MODIFY to your IWPD account
    • For asp.net: It  will run under your IWPD account by default unless you have impersonation enabled in your web.config (which you should use if using asp.net), in which case it will impersonate the IUSR account - add MODIFY to the appropriate account.
    • For access databases(.mdb files), you might need to give write/modify permission to the file/folder depending on the scripting technology that you're using as given above.
  8. Setting up Access Permissions
    • Allow inheritable permissions from the parent to propagate to this object and all child objects. Include these with entries explicitly defined here --> This check  box will allow you to inherit the permission to child objects from the parent folder.
    • Replace permission entries on all child objects with entries shown here that apply to child objects. -> This will propagate the permission from the current folder to the child folders
  9. Click on  Advanced Options for changing the permissions to allow/deny a user.(For advanced users only)
  10. Click OK to save the change after every action.

Wednesday, 18 September 2013

Show cart contents or total items on Woocommerce (Wordpress)

Show cart contents or total items on Woocommerce (Wordpress)
// To display the cart contents and total in your template use something like:
// To ajaxify your cart viewer so it updates when an item is added (via ajax) use:
global $woocommerce; 

echo '< a class="cart-contents" href="http://www.blogger.com/'.$woocommerce-%3Ecart-%3Eget_cart_url().'" 
title="'. _e('View your shopping cart', 'woothemes').'" >'. sprintf(_n('%d item', '%d items',
$woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count)
.' - '. $woocommerce->cart->get_cart_total().'< /a>
- How to use WooCommerce without a Products Page
- Express Lane Shopping: Improving the WooCommerce add to cart button

Tuesday, 10 September 2013

CSS classes selecter [class*=“span”] [class^="classname"][class$="classname"]

CSS classes selecter [class*=“span”] [class^="classname"][class$="classname"] examples below;
.show-grid [class*="span"] {
    background-color: #eee;
    text-align: center;
    border-radius: 3px;
    min-height: 30px;
    line-height: 30px;
}
It's an attribute wildcard selector. In the sample you've given, it looks for any child element under.show-grid that has a class that CONTAINS span.
So would select the  element in this example:
< div class="show-grid">
     class="span6">Blah blah
< /div>
You can also do searches for 'begins with...'
div[class^="something"] { }
which would work on something like this:-
< div class="something-else-class">< /div>
and 'ends with...'
div[class$="something"] { }
which would work on
< div class="you-are-something">< /div>

Wednesday, 28 August 2013

Javascript function to print the selected Div Tag content

Please find the javascript (no JQuery) function below to print the selected content below;
// To print selected portion of HTML content
function printDivContents(divId) {    
 var divToPrint = document.getElementById(divId);
 var popupWin = window.open('', '_blank', 'width=500,height=500,scrollbars=yes');
 popupWin.document.open();
 popupWin.document.write('< html>< body onload="window.print()">' + divToPrint.innerHTML + '');
 popupWin.document.close();
}