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.
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
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.
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 yoursitename.com
Step 3 : Open your file with following command
sudo gedit yoursitename.com
Paste the below code into yoursitename.com file. <VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/project-directory/ ServerName yoursitename.com ServerAlias www.yoursitename.com ErrorLog /var/log/apache2/yoursitename.com-error_log CustomLog /var/log/apache2/yoursitename.com-access_log common </VirtualHost>
Save and close the file.
Step 4 : Enable the site for local server
sudo a2ensite yoursitename.com
Step 5 : Finally add to hosts file.
sudo gedit /etc/hosts
Add below line into hosts file. 127.0.0.1 yoursitename.com
Now you can go to browser and type http://yoursitename.com.
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.
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."
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.
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.
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.
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).
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.
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.
Step : 2
Now we have to write a content for customblockmodule.info 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.
Android push notification using php script. This code will act as web service for the android developers make the app to send push notifications. Before using this code, You have to create a project in google console and get the API key for authentication. Also you have send the Device Token of each mobile.
You can also get device token in with your mobile client side function. So, we you trying to execute the push notification through web service. Should be pass two parameters API Key and Device Token.
MySQL Events are tasks that run according to a schedule. Therefore, we sometimes refer to them as scheduled events. When you create an event, you are creating a named database object containing one or more SQL statements to be executed at one or more regular intervals, beginning and ending at a specific date and time. Conceptually, this is similar to the idea of the Unix crontab (also known as a “cron job”) or the Windows Task Scheduler.
Scheduled tasks of this type are also sometimes known as “temporal triggers”, implying that these are objects that are triggered by the passage of time. While this is essentially correct, we prefer to use the term events to avoid confusion with triggers of the type discussed in Section 19.3, “Using Triggers”. Events should more specifically not be confused with “temporary triggers”. Whereas a trigger is a database object whose statements are executed in response to a specific type of event that occurs on a given table, a (scheduled) event is an object whose statements are executed in response to the passage of a specified time interval.
The below queries will explain you, how to get select, create and drop a event with interval bases.
Create a Table
To enable a event setting
Create a event to delete a table for every 1 hour
We can also select the event list using below query