Drupal

Revisions in Drupal 8.

Revisions in Drupal 8 comes as a part of core. Every time when you edit or create a content in Drupal 8 you will be provided with an option to create a of that content or page. This is helpful for the process of revert back to the older content.

CMI in Drupal 8 - Configuration Management Initiative

Configuration Management Initiative (CMI) in drupal seperates “content” from "configurations". It uses yml files to store the configuration datas And it provides way for deploying configurations over the sites which includes development, staging and production. Configuration Management Initiative (CMI) comes in drupal 8 as a part of core. In short Configuration Management Initiative (CMI) in Drupal 8 solved a many big issues that a drupal 7 developer experiences. In a fresh Drupal 8 instance navigate to..

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.

Drupal 7: Creating custom pages, forms using hook_menu()

The hook_menu() is the menu router for the Drupal system. In this hook we can able to specify the possible URL paths to our Drupal system. This function implementation must return the associative array of URL paths and their respective callbacks. The below is the syntax and usage example of this hook. Once you have implemented hook needs to flush the cache to detect system.

Drupal 7: Writing your custom table hook_schema() with Example

In Drupal hook_schema() help to create the Tables in Drupal system. This schema is defined in MODULE_NAME.install file. This hook invokes during the Module install. Similarly, during module uninstall tables defined in hook_schema() automatically get deleted. The below is the syntax and example of implementing hook_schema().

Drupal 7: Commerce Order Status update programmatically

In Drupal, commerce Orders are acted as a separate entity. The order has different status during each stage on purchasing. These status updates are taken place during the order checkout process. It possible us to update order status programmatically from one state to others.

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: Show Erros on Developing or WSOD

In Drupal while developing it not showing the errors instead of it will be showing us a White screen. This screen is known as White Screen Of Death(WSOD). During development, we need to debug the errors, for this purpose we want to show errors. To show errors instead or white screen we need to add below lines in "settings.php".

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.

Drupal 7: Programatically Create Pagination with Example

The function theme() will help to create pagination programmatically in Drupal. While passing the argument "pager" to a theme() with the additional parameter for construct pager will return the pager. The below syntax and example demonstrate how to implement pager in Drupal 7.