Blogz

Recent Blogz

Top 10 Most Common Spring Framework Mistakes

Spring is arguably one of the most popular Java frameworks, and also a mighty beast to tame. While its basic concepts are fairly easy to grasp, becoming a strong Spring developer requires some time and effort. In this article we’ll cover some of the more common mistakes in Spring, specifically oriented towards web applications and Spring Boot.

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.

Drupal 7: Programmatically updating rules with example

Rules are used for trigger any action based on some condition pass. The contribute module Rule is used to achieve this features. We can able to programatically create and update rule action and conditons. The function rules_config_load() helps to load rule object by its name. The rule object will return attributes of particular rule. Using the object of rule we can able to edit its values.

Drupal 7: Commerce convert decimal to currency

In Drupal commerce will help to convert any numbers into a proper currency format. The function commerce_currency_format() helps to convert decimal numbers to particular country formatted currency. This function will accept a decimal number and country currency code for change given number into currency.

Drupal 7: Database Aggregate functions (SUM, MIN, MAX, COUNT, AVG,..)

The MySQL database query supports aggregate functions to retrieve values from the database. In our custom query, we can able to add aggregate queries. The function addExpression() takes object of database query to aggregate results in db_select(). The below example will demonstrate the usage of aggregate functions.

Drupal 7: Database query with MySQL Date functions

The MySQL is the database which stores any type of data in Database. Using the MySQL we can able to store date-related fields. The MySQL will support Date functions to retrieve and format database date field values. In Drupal also we can able to add date functions in our queries with help of where() function in the database object. The below is the syntax and example of usage of the where() function.

Drupal 7: Making Drupal block is no-cachable:

Drupal system makes blocks is cachable to speed render. The block cache is stored in Drupal core database block_cache table. By altering or change information of block as non-cachable. This is achieved by passing cache as "DRUPAL_NO_CACHE" in hook_block_info() for custom block and hook_block_info_alter() in existing block.