Showing posts with label Web developement. Show all posts
Showing posts with label Web developement. Show all posts

Thursday, March 26, 2020

Drupal 8 Media Library with SVG upload

Uploading the media content and maintaining together with reusability was one of the challenges in earlier versions of drupal. Media Library has been included in the Drupal core. It has a better user experience including multiple media types that can be customized based on development requirements.

Media Library is a media management tool that enables you to find media that exists in your site and to add new media items. It allows you to search, sort, and create media items with a customizable interface. It can be used to add media items to an entity reference field or embed media into your content via a text editor.

To use the media library luxury, Throughout the site we should use the media field. It will help us to collect the media elements as a single point and will be provisioned for us to reuse using the media library.

Media type management will be maintaining the list of media types being supported by the media field. We can add the new media type through the user interface.

If you have appropriate permissions, this area allows you to add media items to the media library (it does not appear if you don't have permission).
By default media type has Audio, Document, Images, Remote video, and Video. In each type,
you can choose the source of files that can be accepted.
Adding SVG upload to Core Media Library
In the contribution community, there is a module called SVG Image field, that will help us to
enable the SVG to upload throughout the drupal content type.

Contribution module -
To enable the SVG format upload in the media library, we need to add a media type in structure.

To use the SVG upload in the content type, please follow the below steps

Add content type with media fields (To get the privilege of media library we should use
"Media" as field type)
Select a reference type as appropriate on next field configuration screen (I have opted for "image" and "SVG Image upload")

Monday, February 17, 2020

Drupal Content Workflow

In CMS world maintaining the content workflow is very important. When the content editor is
updating the content to the page, it always requires review and approval by the content manager.
This workflow will define the way, how the content will be published to the end-user on the site.

Drupal 8 has a core module to support content authorization workflow. But it doesn’t have the
ability to provide the interface to customize the own workflow depending on different organizations.
That will be achieved by contribution module called Workflow

This will help you establish the transition state between different content types and roles.
But the known disadvantage on this module, will not able to edit the
published content (Current published state content)

Tuesday, February 14, 2017

Adding custom property in Azure Broken Message object.

The below code is sample piece of code to add custom property in azure broken message object

Get the custom property value

Tuesday, January 3, 2017

Move service bus data to DeadLetter Queue in Azure

In Micorsoft azure, Service bus is one of the most powerful concept in azure cloud computing. Service bus must be constant size called 64KB.

Below i have listed the options to move the data's to DeadLetter Queue manually.
  1. Set "Default Message Time to Live" in seconds and Check the checkbox move expired messages to DeadLetter Queue
  2. We could move the message of the queue using broken message object. Here is below example.

Saturday, March 5, 2016

Binary file as attachment to an email using C#

The below code is example of adding binary files into mail as attachment. Each binary data's are write as file and attaching them into email using MailMessage object.

Tuesday, February 2, 2016

Posting packets from Azure Storage to Service Bus using C#

Microsoft Azure is one of the leading cloud computing environment. Using the below script we are posting raw packets from storage to Service Bus.

Wednesday, January 6, 2016

Rest API Connection in C# - Using RESTSHARP Library

Rest Client connection using C#. In this post, I have explained the very simple solution using RestSharp Library. In RestSharp library, we have RestClient and RestRequest classes. RestClient will help us to establish the connection using API URL, RestRequest object will act as the intermediate between RestClient and API HOST. Using RestRequest, we will define the header and Request Method.

Thursday, October 15, 2015

Creating content type tpl file in drupal 7

In Drupal 7, Page.tpl.php will be the default template file for whole site. In top of this, we can customize our template for different content type, individual nodes and front pages. Even we can customize the block template and views templates.

In this blog post, i am going to give you small snippet of code for creating template file depends on content type.

To create a template file for content type, First step we need to define in template.php file on hook_preprocess_page method.

After included in template.php we need to copy the page.tpl.php. Paste in same folder, rename it according to you content type.

For example:- My content type name is reviews. My file name should be page--reviews.tpl.php

In this file, you can customize your design.

Tuesday, September 22, 2015

Get node content using node_view and node_load in drupal 7

Drupal 7 has vast functions to manipulate node and its content. Here i have gave you the piece of code to get node content using node id.

How to use DOMDocument in PHP?

DOMDocument is PHP library, which will be used to read, write and manipulate XML and HTML Documents. DOM (Document Object Model) is kind of API to validate the content of XML/ HTML. DOM support different namespaces as well.
The above code is demonstrating about DOMDocument usage with sample example. The example will fetch all H2 tags from the content and will form as separate list view.

To Discard White Spaces in content

Saturday, April 5, 2014

How to use SCP command in windows

SCP command is one of the most powerful command in linux to transfer files in secure way. It can be use for windows.

Here the link to download link for windows.

After you download the file into you local machine. Please go to command prompt and go to location of pscp.exe. From there you need to execute the following commands to download and upload a file.

Please use below command to download file to local from server location.

Please use below command to upload file from local to server location.

Saturday, March 22, 2014

How to setup virtual host in apache2 on ubuntu OS

Virtual host is one of the beautiful option, which is provided by web servers. I have already shared the snacks about XAMPP virtual host creating process. I believe that snacks was tasty and delightful for your coding life.

Here, i am sharing another tasty snacks about Apache2 server virtual host, which is default server of most of linux OS. In order to create virtual host in your linux machine with apache2 server. First you have to place your project folder under root directory (/var/www/).

Create virtual host file in below location with tags

Step 1 : Go to cd /etc/apache2/sites-available/

Step 2 : cp default

Step 3 : Open your file with following command

sudo gedit

Paste the below code into file.

<VirtualHost *:80>

    DocumentRoot /var/www/project-directory/

    ErrorLog /var/log/apache2/
    CustomLog /var/log/apache2/ common

Save and close the file.

Step 4 : Enable the site for local server

sudo a2ensite

Step 5 : Finally add to hosts file.

sudo gedit /etc/hosts

Add below line into hosts file.

Now you can go to browser and type

Thursday, January 9, 2014

Call content type form in custom module with Drupal 7

Here we have realtime syntax to call content type form in drupal 7. It will allow you to call add form of particular content type.

To use this code, please add some custom module with menu hook. For menu hook, Have the callback function with below code. You will get the form to submit your values.

Thursday, December 26, 2013

Enable default token values in drupal 7

To enable the default token to be display in the drupal site. We have to install separate module to do the same. This module will allow the content type field to enable and replace with particular token.

You download the module here.

Steps to install

  1. Download the module from this location and extract it.
  2. Extract folder should be placed in /sites/all/modules folder.
  3. Then, Login as administrator in site.
  4. In admin menu, Please click on module menu.
  5. In the list modules, You will able to see the "Field default token".
  6. Please check the checkbox, which is row of same module.
  7. Then, scroll down and click "Save Configurations".
Now, you module will start to work on the same. Please give some default token in text field of content type and check.

Friday, May 10, 2013

Data Encapsulation in PHP

Data Encapsulation is "Encapsulation is a way of storing an object or data as a property within another object, so that the outer object has full control over what how the internal data or object can be accessed."


Wednesday, May 8, 2013

QR Code generation in php

QR code generating in PHP, that can be used to generate QR Code images using Google Chart API. It was build using Google Chart API Web server to request the generation of a PNG image that represents the QR code graphic for a given information snippet. Currently the class can request the generation of QR codes for information snippets of the following types: bookmark, text, SMS message, phone number, contact information, e-mail message, geo-location, WIFI access, i-appli metadata, or abitrary content-type. The generated QR code image can be returned as a string, served for download, or returned as a URL string.



Wednesday, April 24, 2013

Soap using PHP CURL

SOAP Stands SIMPLE OBJECT ACCESS PROTOCOL. Soap is most powerful and secure web service architecture. Soap will have two way communication between different request and responses.
It is more secure compare with REST. It has own set of properties to implement the structure of protocol.

The below code is for SOAP connection using PHP CURL.



Tuesday, April 16, 2013

How to pass date in querystring on jquery

The post is about jquery multiple date handled in querystring in ajax method. Here, we have used array to send the date through querystring. This code will reduce our work weight-age. Just need to form a array with unlimited index with unlimited dates.

Wednesday, April 10, 2013

Image resizing in PHP

The post is about image resize using php methods. This will help us to make the image as thumb size on run time. For this method, we need to pass six parameters file, photo_dir (Image directory), thumbs_dir (New image directory), square_size (Optional, by default we mentioned 140px), img_height (Optional, by default we mentioned 140px), img_width (Optional, by default we mentioned 128px).

Tuesday, April 9, 2013

Create a block using custom module in drupal 7

In this post, we will discuss about creating block using custom module in drupal 7. The main benefit of build a block using custom module is connectable module. This code will act as separate connectable component.

In Drupal 6, there is only one hook used for all block operations but now in Drupal 7 there are different functions for different operations of the blocks. This are the hook method provided by drupal 7 for build a block.


Here we will discuss through different steps.

Step : 1
We need to create a directory in this path "sites/all/modules". i.e you need to create a new module folder inside drupal directory. Directory name must under-stable and meaningful related to your module purpose. I will named as "customblockmodule" for module directory.

We should have this two files inside directory.
2. customblockmodule.module

Step : 2
Now we have to write a content for file.
Here we have mentioned name,description,core and package. Core  will have the drupal version for this module and package will define the area of module to be placed in module section.

Step : 3
In this module file, First we have to mention about info method

hook_block_info()  : This is used to tell Drupal about the new block or blocks that we will create. Drupal will display the block in the block list in the admin.

An implementation of hook_block_info() takes no arguments and is expected to return an associative array.
This defines a block named “custom_bk_module” that has two properties:

Info: This provides a description about the block. The text is used on block list in admin.
Cache: This tells Drupal how to cache the data from this block. In above example, I mentioned DRUPAL_NO_CACHE which tells Drupal not to cache the block.

hook_block_view() : Will demonstrate about view of the block. It will hold the content of the block. When page requesting to view a block, this method will get called.