PHP: Removing BOM(Binary Order Mark) from given string

The Binary OrderMark(BOM) is the hidden secret code used for securing the data transfer via REST services. Commonly this BOM details available starting of each string(Commonly exist in first 3 characters). But will saving in Database or processing we no need this code. So we can strip from actual code.

Drupal 7: CURL HTTP request with example(drupal_http_request())

The CURL is the PHP functionality for access external website contents. Using CURL request we can get content data, content or files from any other service providing websites. In Drupal 7 the function drupal_http_request(), will help to achieve CURL request for us.

PHP: Get/Strip particular element from HTML

The below is the sample code for strip a particular HTML element from given string HTML. Using this function we can able to get particular div, span, p, body, article,.. any HTML wrapped element by its class or id. This function accepts 4 parameters, HTML string to get particular Tag, Strip tag name, Identifier name Class or Id and Identifier Class name or Id name.

Bidirectional Relationship Support in JSON

Ever tried to create a JSON data structure that includes entities that have a bidirectional relationship (i.e., circular reference)? If you have, you’ve likely seen a JavaScript error along the lines of “Uncaught TypeError: Converting circular structure to JSON”. Or if you’re a Java developer who uses Jackson library, you may have encountered “Could not write JSON: Infinite recursion (StackOverflowError) with root cause java.lang.StackOverflowError”. This article provides a robust working approach to creating JSON structures that include a bidirectional relationship without resulting in these errors.

Storage in Ionic 2

Storage in ionic 2 can be used to store data key/value pairs. We can also store JSON Objects. This Storage can work using may storage engines, here it will choose the best based on the platform. If the application runs in native platfrom it will use SQLite where as if it is in browser it use IndexedDB. Follow the steps to use Storage,

Drupal 7: Creating custom Permissions hook_permission() with Example

Permissions control access in Drupal system. We can able to specify the permissions based on User Roles. We can programmatically able to create custom permissions by implementing the hook_permission in Drupal 7. The below is the syntax and example of how to use custom permissions. Once permissions are defined the need to clear cache. So, that permission available on admin/people/permissions page.

Document and window click event not works in iPhone and iPad as expected

$(document).click(function (e) {}); or $(window).click(function (e) {}); will work perfectly on IE, Firefox and Chrome. But it won't work in iPhone and iPad Safari except some elements. Since by default "DIVs" are not "clickable" elements we have to makes iOS treat it as clickable. The problem is iPhones dont raise click events. They raise "touch" events. A small work around is to make the element clickable using CSS. So you need to add

Drupal 7: PopUp By Ctools Automodal Module

  • Ctools Automodal will help you to create popup in your site. It is an easiest way to create a popup without any burden. To Create a popup form please follow the below instruction:-

  • Download and install the ctools Automodal(module) in your drupal instance.

    • Description : By using this module You can create your own custom form in popup.

Drupal 7: Programatically place a Commerce Orders with sample code

In Drupal 7 using the core functions of commerce, we can place orders programmatically. Using the function "commerce_product_line_item_new()" and "commerce_line_item_save()" we can add item to cart. The function "commerce_order_save()" will place all line items into order. The below is the sample code which demonstrates.

Drupal 7: Check given user Cart have items or not

We will add the product to the cart to checkout. The below is the code which used to check current user cart have the product or not. The function "commerce_line_items_quantity()" will returns the total quantity and "commerce_line_items_total()" will return cart total. These functions are taking the order line item array. This code will return an array of product that user have been added to his/her cart.

Drupal 7: Programatically Delete a Commerece order

The function commerce_cart_order_load() help to load the current user cart details. Using the cart order object details we can able to unset or empty the commerce cart of that user. The function commerce_cart_order_empty() help to achieve this. The below sample code demonstrate how to delete cart of a user.

Drupal 7: Programatically Loading commerece cart item of a user with samplecode

In Drupal commerce, cart items are handled as Entity. The cart items are referenced to the particular user id. Using user id we can able to load cart details that are currently added by the user. The function "commerce_cart_order_load()" takes user id as argument to load the cart details. The below example shows how to load cart details of the current user.

Drupal 7: Programatically update commerec Line Item with example

In programmatically we can able to alter commerce line items. The line items are kept as an entity in Drupal commerce system. Using the function "commerce_line_item_load()" we load line item as the object and able to access line item properties. The function commerce_line_item_save() will help to update the line item.