Get all href links from a html content in PHP


, , ,

TO get all href links from a html content in PHP using DOMDocument.

Here is the simple code snippet.

$body = 'This is my PHP blog <a href="">My PHP Blog</a>';
$dom = new DOMDocument;

$links = $dom->getElementsByTagName('a');
$url = '';
foreach ($links as $link){
    $url = $link->getAttribute('href');
    echo 'URL=>' . $url . '<br>';

Most Popular Hostnames Serving jQuery Across Web


jQuery is great. It’s cross-browser, easy to learn, and makes adding interactivity to your website a breeze. It also comes with plenty of plugins to do almost whatever you need it to do.

So there are lot of benefits from loading  jQuery from popular hostnames or sites (For Eg. Google Hosted Libraries).

Here are the most popular sites across web:

Sites/Hostnames Percentage of sites 18.30% 1.40% 0.30% 0.20% 0.20% 0.10% 0.10% 0.10% 0.10% 0.10%

How to add a block in Drupal and how to configuring a block in Drupal



Blocks are the boxes of content that can be displayed in regions (such as footer or sidebar) on your page. Depending on your themes regions you may have the ability to include blocks in your right, left, middle or any other configurable region of your theme. Many of the modules like ecommerce, polls come with predefined blocks that you can place in any region of your theme. You can create your own custom blocks with any html editor and place these contents in a block. Each custom block has a title, a description, and a body.

Blocks are configured per theme.If you change the theme or enable multiple themes, you will need to configure blocks per theme. Blocks can be enabled or disabled by clicking on Administration > Site Building > Blocks.

Adding a new block in Drupal : 
1. From the Blocks overview page (Administration > Site Building > Blocks), click the “Add Block” tab.
2. Insert a Block description (*required), which will be displayed on the block overview page.
3. Insert a Title for the block.
4. Insert the body content for the block. Be sure to confirm you are using the correct input format for your block.
5. (optional) Set User, Role, and Page specific visibility settings.
6. When you click save, the block is created but not placed in a region by default. You will need to drag and drop it into a region in order for it to show up on the site.

Configuring a block in Drupal :
1. Go to the Blocks overview page (Administration > Site Building > Blocks) to configure the blocks on your site.
2. This page allows you to drag-and-drop blocks into different regions as well as reorder the blocks within a region.
3. Next to each block you can click “Configure” to change the specific block settings:
            * Block title: Allows you to override the default title for the block
            * User, Role, and Page specific visibility: Adjust visibility for block based on user, role or page.
            * Additional settings may also be available, depending on the particular block.

Reference :

Syntax Highlighting in Drupal WordPress post and comments


, ,

If you want to highlight the code/syntax when making yor comments/post in Drupal and WordPress, just wrap it with the following tag.
[sourcecode language=php]
// Your Code Here

The above piece of code will be highlighted with PHP code format.

The language parameter controls how the code is syntax highlighted. The following languages are supported:
– actionscript3
– bash
– coldfusion
– cpp
– csharp
– css
– delphi
– erlang
– fsharp
– diff
– groovy
– html
– javascript
– java
– javafx
– matlab (keywords only)
– objc
– perl
– php
– text
– powershell
– python
– r
– ruby
– scala
– sql
– vb
– xml

Reference: – Posting Source Code

jQuery & Cookies – How to get/set/delete cookies in jQuery


, ,

To get/set/delete cookies in jQuery, for this you can use jQuery Cookie plugin

Here is how to use jQuery Cookie plugin in your code:

// Setting a cookie

// Creating cookie with all availabl options
$.cookie('myCookie1', 'myValue1', { expires: 7, path: '/', 
domain: '', secure: true });

// Get a cookie

// Delete a cookie
$.cookie('myCookie', null);

How to get tables statistics / tables status in MySQL


, ,

MySQL tables statistics / MySQL tables status 

To get the MySQL table status and to get more information about table (size, engine, no. of rows etc.), following is the very useful command.

SHOW TABLE STATUS [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]
//If you have selected a database then run the following command:

MySQL returns information about all the tables in the selected database. For more info about what MySQL returns,

If you want to see information about a particular table in a particular database then you run the command as follows:

SHOW TABLE STATUS FROM <database name> LIKE '<table name>'

Popular Drupal Modules / Popular Modules In Drupal


, , ,

Drupal Modules
The most popular Drupal modules

Here you will find a list of the most popular Drupal modules, a short description of what they do, a download link plus how to install instructions.
Source Link :

Add External Link To Menu In Drupal



Following are the steps to add an external link to menu in Drupal:

1. In the navigation menu click Administer -> Site Building -> Menus
2. Choose the menu you would like to add the external link to
3. At the top click Add Item
4. Under Path enter the url of the site you would like to link to.
5. Under Menu link title enter the name that is to be shown on the menu.
6. You may enter a description for the menu item
7. Choose it’s parent
8. Under weight you can set where the menu item will appear in the menu. A smaller number will make it appear higher than a bigger number.
9. Click Save