Author: AddWeb Solution

How To Create Plugin In OctoberCMS Development Service

Plugin in OctoberCMS

As a name suggest “Plugin” is a software add-on (i.e. Set of code to achieve some specific functionality) that is installed
onto a program, enabling it to perform additional features.

In OctoberCMS Plugins are the foundation for adding new features to the CMS by extending it.

Purpose:

  1. To enable third-party developers to create abilities which extend an application
  2. To support easily adding new features
  3. To reduce the size of an application
  4. To separate source code from an application

To create new plugin for OctoberCMS you must have to follow below steps:

  • Registration
  • Directory Structure
  • Registration file
  • Supported methods
  • Basic plugin information
  • Routing and initialization
  • Navigation menus
  • Version History
  • Plugin version file
  • Extending with events

Registration:

The registration process allows plugins to declare their features such as components or back-end menus and pages.
Some examples of what a plugin can do:

  • Define components.
  • Define user permissions.
  • Add settings pages, menu items, lists and forms.
  • Create database table structures and seed data.
  • Alter functionality of the core or other plugins.
  • Provide classes, backend controllers, views, assets, and other files.

Directory structure: Plugins reside in the /plugins subdirectory of the application directory. An example of a plugin
directory structure:

plugins/ acme/ <=== Author name blog/ <=== Plugin name classes/ components/ controllers/ models/ updates/ … Plugin.php <=== Plugin registration file

Registration file: The Plugin.php file, called the Plugin registration file, is an initialization script that declares a plugin’s
core functions and information. Registration files can provide the following:

  • Information about the plugin, its name, and author.
  • Registration methods for extending the CMS.

Registration scripts should use the plugin namespace. The registration script should define a class with the name Plugin
that extends the \System\Classes\PluginBase class. The only required method of the plugin registration class is plug-in details.
An example Plugin registration file:

namespace Acme\Blog;   class Plugin extends \System\Classes\PluginBase { public function pluginDetails() { return [ ‘name’ => ‘Blog Plugin’, ‘description’ => ‘Provides some really cool blog features.’, ‘author’ => ‘ACME Corporation’, ‘icon’ => ‘icon-leaf’ ]; }   public function registerComponents() { return [ ‘Acme\Blog\Components\Post’ => ‘blogPost’ ]; } }

Supported methods: OctoberCMS provides list of available methods which you can define/use in your plugin

Method Name Description
pluginDetails() Returns information about the plugin.
register() Register method, called when the plugin is first registered.
boot() boot method, called right before the request route.
registerMarkupTags() Registers additional markup tags that can be used in the CMS.
registerComponents() Registers any front-end components used by this plugin.
registerNavigation() Registers back-end navigation menu items for this plugin.
registerPermissions() Registers any back-end permissions used by this plugin.
registerSettings() Registers any back-end configuration links used by this plugin.
registerFormWidgets() Registers any back-end form widgets supplied by this plugin.
registerReportWidgets() Registers any back-end report widgets, including the dashboard widgets.
registerListColumnTypes() Registers any custom list column types supplied by this plugin.
registerMailTemplates() Registers any mail view templates supplied by this plugin.
registerSchedule() registers scheduled tasks that are executed on a regular basis.

Basic plugin information: The pluginDetails is a required method of the plugin registration class.
It should return an array containing the following keys:

Key Description
name the plugin name, required.
description the plugin description, required.
author the plugin author name, required.
icon A name of the plugin icon. The full list of available icons can be found in the UI documentation. Any icon names provided by this font are valid, for example icon-glass, icon-music.
iconSvg An SVG icon to be used in place of the standard icon, optional. The SVG icon should be a rectangle and can support colors.
homepage A link to the author’s website address, optional.

Routing and initialization: Plugin registration files can contain two methods boot and register. With these methods,
you can do anything you like, like register routes or attach handlers to events.

  • register: It is called immediately when the plugin is registered.
  • boot: It is called right before a request is routed.

So if your actions rely on another plugin, you should use the boot method. For example, inside the boot method you
can extend models:

public function boot() { User::extend(function($model) { $model->hasOne[‘author’] = [‘Acme\Blog\Models\Author’]; }); }

Plugins can also supply a file named routes.php that contain custom routing logic, as defined in the router service.
For example:

Route::group([‘prefix’ => ‘api_acme_blog’], function() {   Route::get(‘cleanup_posts’, function(){ return Posts::cleanUp(); });   });

Navigation menus: Plugins can extend the back-end navigation menus by overriding the registerNavigation method
of the Plugin registration class. This section shows you how to add menu items to the back-end navigation area.

An example of registering a top-level navigation menu item with two sub-menu items:

public function registerNavigation() { return [ ‘blog’ => [ ‘label’ => ‘Blog’, ‘url’ => Backend::url(‘acme/blog/posts’), ‘icon’ => ‘icon-pencil’, ‘permissions’ => [‘acme.blog.*’], ‘order’ => 500,   ‘sideMenu’ => [ ‘posts’ => [ ‘label’ => ‘Posts’, ‘icon’ => ‘icon-copy’, ‘url’ => Backend::url(‘acme/blog/posts’), ‘permissions’ => [‘acme.blog.access_posts’] ], ‘categories’ => [ ‘label’ => ‘Categories’, ‘icon’ => ‘icon-copy’, ‘url’ => Backend::url(‘acme/blog/categories’), ‘permissions’ => [‘acme.blog.access_categories’] ] ] ] ]; }

When you register the back-end navigation you can use localization strings for the label values. Back-end navigation canalso be controlled by the permissions values and correspond to defined back-end user permissions.

Version History: It is good practice for plugins to maintain a change log that documents any changes or improvements inthe code. In addition to writing notes about changes, this process has the useful ability to execute migration and seed files in their correct order.

The change log is stored in a YAML file called version.yaml inside the /updates directory of a plugin, which co-exists
with migration and seed files.

This example displays a typical plugin updates directory structure :

plugins/ author/ myplugin/ updates/ <=== Updates directory version.yaml <=== Plugin version file create_tables.php <=== Database scripts seed_the_database.php <=== Migration file create_another_table.php <=== Migration file

Plugin version file:

1.0.1: First version
1.0.2: Second version
1.0.3: Third version
1.1.0: !!! Important update
1.1.1:

  • Update with a migration and seed
  • Create_tables.php
  • seed_the_database.php

 

As you can see above, there should be a key that represents the version number followed by the update message,
which is either a string or an array containing the update message.
Read More:- https://goo.gl/HKSrj6

Understand The Implementation of REST API In Laravel 5

In this blog, we are going to demonstrate the understanding to implement REST API in Laravel 5. Starting with some quick introduction part;
  • Rest API is backend implementing also it is a simple basic HTTP authentication to store data for different users of the application.
  • We will use the middleware to provide the authentication for the rest call.
  • The middleware will authorize the user at every request without storing in session or using token.
Implement REST API:
composer create-project restAPP –prefer-dist
  • This terminal command to we create the new application and that name is restAPP.
  • Then after we create the model for basic authentication and we are using the email for login parameter.
  • Complete the project creation after we have created the controller and model, using artisan command.
    php artisan make:model Todo
<?php 
namespace App;
 
use Illuminate\Database\Eloquent\Model;
use App\User;
 
 
class Todo extends Model {
 protected $fillable = ['title','isDone'];
    public function user(){
 
        return $this->belongsTo('App\User');
 
    }
 
}
In the model we have to add the reference to the user model and method to retrieve it.
    php artisan make:controller TodoController
<?php
namespace App\Http\Controllers;
 
use App\Http\Controllers\Controller;
use App\Todo;
use Auth;
use Request;
 
class TodoController extends Controller {
 
   /**
    * Display a listing of the resource.
    *
    * @return Response
    */
   public function index() {
 
         $todos = Todo::where('user_id','=',Auth::user()->id)->get();
     return $todos;
   }
 
   /**
    * Store a newly created resource in storage.
    *
    * @return Response
    */
   public function store() {
      $todo = new Todo(Request::all());
      $todo->user_id = Auth::user()->id;
      $todo->save();
      return $todo;
   }
 
 
}
In controller, we have to add a basic method to create and retrieve data from the logged users.
It’s all complete then we have to create a middleware to for authentication for possible to access data only if the user passes in the HTTP request his email and password. Let’s create middleware.
    php artisan make:middleware simpleAuthMiddleware
<?php namespace App\Http\Middleware;
 
use Closure;
 
class SimpleAuthMiddleware
{
 
   /**
    * Handle an incoming request.
    *
    * @param  \Illuminate\Http\Request $request
    * @param  \Closure $next
    * @return mixed
    */
   public function handle($request, Closure $next)
   {
      return Auth::onceBasic('username') ?: $next($request);
   }
 
}
After creating middleware we have to register in “ kernel.php “ file and give the key for easily use this middleware.
‘simpleauth’ => ‘App\Http\Middleware\SimpleAuthMiddleware’, After register this middleware we have to create the route path for Todo Controller and middleware
Route::get('api/todo', ['uses' => 'TodoController@index','middleware'=>'simpleauth']);
Route::post('api/todo', ['uses' => 'TodoController@store','middleware'=>'simpleauth']);
If you try with the postman on every request of email and password will be prompted. You will also pass this info on URL or HTTP header.

Hope this helped you to get most out of the system. Feel free to share your reviews or need assistance for Hire Laravel Developer then get in touch with us. Pick the best answer for your requirements.

How to Start Testing Journey

“QA is not only about finding mistakes, it’s about Quality”.

As it proved your first impression is your last impression & as specially for tester’s there are so many stones as bugs in your testing ways. To help you to start your testing journey with some quick & interesting points review the below mentioned basic points to startup.

  • First Check Cases for blank fields or use the alternate blank fields.
  • Check the Whole site for spelling mistakes.
  • Tool tips text should be meaningful
  • Default page sorting should be provided.
  • In any form, one radio button must be marked by default.
  • All numeric values should be formatted properly.
  • For all fields, there should be a placeholder text or example value.
  • The validation message should not contain any data like no/ not. It should be in a positive way.
  • The data or field can’t be overlapped in any resolution.
  • Check  time & proper validation i.e image size 8 MB, supporting document i.e .pdf .zip, .csv, display properly while uploading time. An image should not be blur & if an image is not loaded or displayed then, it should show the alt text.
  • All error messages should be displayed in same CSS style (e.g. using red color) and General confirmation messages should be displayed using CSS style other than error messages style (e.g. using green color).
  • Dropdown fields should have first entry as text like ‘Please Select’.
  • Delete/update functionality for any record on the page should ask for confirmation.
  • Check all input fields for special characters.
  • Check broken links throughout the application/software.
  • Check broken Images throughout the application/software.
  • Check Date & font- family consistency throughout the site.
  • Check All button & links with having functionality & same consistency for CSS throughout the site.
  • Amount values should be displayed with correct currency symbols.
  • Reset button functionality should set default values for all fields.
  • Check Add & edit contents with added details, it should be the same.
  • Application crash or unavailable pages should be redirected to a custom error page.
  • The links which are provided in email for verification must be linked(proper URL) & clickable on every provider and have an expiry time.
  • Perform browser compatibility test site in the different browser (i.e google chrome, Mozilla, Safari, i.e.) Perform OS compatibility Test application with different

    OS like mac and windows.

  • Dummy/test content must be removed from the site after testing.

Hope this blog helps you to get the basic way to start up your testing journey. You can also refer our types of testing blog and Share your views and feedback.

Features & Use Of Display Modes In Drupal 8

Display modes are one of the core functionalities of Drupal 8. They are easy to create and provides great flexibility in terms of theming at entity viewing and editing level. Display modes are available for content, comment, contact messages, custom blocks, taxonomy terms, users. They are also available to views adding more power to views.

Display modes are located at Admin -> Structure -> Display modes -> View mode.

Two types of display modes are available: “view modes” and “form modes.”  Both these are an example of configuration entities.

View modes allow site builder to request a field to be rendered in a certain way. For example, we can have an article that has doctors field has entity reference. An article full mode display, we can request few details of doctor to be displayed. We can create a new display mode (“Doctor details”) to do so. On Doctor’s full view, we can include a brief summary of articles associated with them.  (In detail: https://goo.gl/9J2oms)

To create View mode 

Navigate to Admin -> Structure -> Display modes -> View mode

  1. Click on “Add view mode” to add new view mode

  2. Created view mode is available on content types. Navigate to manage display of the content type and enable view mode.

    Manage display console test.png

Once enabled, this mode can be used on referenced field.

Once view modes are enabled, we can theme it as per requirements. To get template suggestions, you need to turn on debug property from services.yml.

You can find theme suggestion in inspect element.

Display modes can also be used based on conditions and we can switch mode based on conditions.

function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
  // For nodes, change the view mode when it is teaser.
  if ($entity->getEntityTypeId() == 'node' && $view_mode == 'teaser') {
    $view_mode = 'my_custom_view_mode';
  }
}
Hope this helped you to understand Display Modes in Drupal 8, Feel free to drop us a line for any Drupal 8 related work/queries/tasks, or Need any assistance regarding Drupal 8 Web design & Development.
Always ready to help 🙂

Ingenious Ways To Create Audio Player With Ionic

Audio-ionic

Nowadays many applications are having another source of medium to show the information to the users other than text. For example, video and audio. In this article let’s focus on having an audio player in your ionic application. An audio player for Ionic works with HTML5 audio or native audio using Cordova Media plugin. It creates an interface to the Cordova-media plugin including a service that controls Media playback and directives to define the look and feel of the player.

Install dependencies for having audio player

  • Install this module using bower
$ bower install ionic-audio
  • Cordova media plugin
$ ionic plugin add cordova-plugin-media

Note: If your project does not have any platform then, you must add one and make a build if you want to test it on your device. Keep in mind that the plugin which we have installed above depends on a Cordova plugin so the module won’t run locally with ionic serve. However, you can still run the project locally to tune the UI before deploying to the device.

Include Js file in Index.html

 <script type="text/javascript" src="lib/ion-audio/dist/ion-audio.js"></script>

Inject the dependency in your app’s module

 angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ionic-audio'])

Inject this code in view file player UI using directives

 <ion-view view-title="Music Player">   
<ion-content>
    <ion-audio-track track="track">
<div class="list list-inset">
           <div class="item item-thumbnail-left">
                <img src="{{track.art}}">
                <h2>{{track.title}}</h2>
                <p>{{track.artist}}</p>
              <ion-audio-controls>
               <a class="button button-icon icon"          
             ion-audio-play> 
          </a>
                <ion-spinner icon="ripple"></ion-spinner>
              </ion-audio-controls>
           </div>
              <div class="item">
                <ion-audio-progress-bar 
track="track" display-time>
</ion-audio-progress-bar>            
   </div>
</div>
    <ion-audio-track>
      </ion-content>
 </ion-view> 

Here, track=”track” is a UI directive

Ion-audio-track

This is directive which gets us the track information about this audio.Using below mentioned JSON object, you can add the information about the track in an audio player. The interface of the player is defined in ion-audio-track body directive.

$scope.track = {
    url: 'http://www.xyz.com/simple_song.mp3',
    artist: 'abc',
    title: 'xyz',
    art: 'image/album.png'
}

Here, $scope.track.url is the path for audio if you want to play the local song in your android/ios device, just put that audio file in js folder and give the according to a path to that file in the code. Sample example,

 $scope.track = {
        url:'/android_asset/www/assets/mp3/simple_song.mp3',
        artist: 'abc',
        title: 'xyz',
        art: '/android_asset/www/assets/image/album.png'
  }

Use as a global progress bar

If an ion-audio-progress-bar is placed inside the scope of ion-audio-track, it will automatically work and will progress automatically according to the audio goes on. Add a display-info to show the current playing track. Add a display-time to show timing in the track list.

<ion-audio-progress-bar display-time display-info></ion-audio-progress-bar>

Media Manager

Inject MediaManager in your controller if you need to access the currently playing track. For example, in order to stop playback before transitioning to another view any other action:

.controller('MusicCtrl', ['$scope', 'MediaManager', function($scope, MediaManager) {

$state.$on('$ionicView.beforeLeave', function() {
        MediaManager.stop();
    });

Hope you had the quick solution for your purpose, feel free to Hire our Hybrid App Development service, provider.

How To Disable WordPress Automatic Update Email Notification

How to Disable WordPress automatic update email notification
As we all know WordPress, by default sends an email notification to the user that WordPress site is updated. Some time user has multiple WordPress sites so they get notification from each site.

Now, let me guide you to how you can disable update email notification. We have two methods to disable WordPress update email notification:
Method 1: Disable update email notification by code

In this method you need to add below code into your current theme’s functions.php file or you can create a custom plugin for it. Below code adds a filter to disable email notification after automatic core update.
add_filter( 'auto_core_update_send_email', 'stop_auto_update_email_notification' );
function stop_auto_update_email_notification( $send, $type, $core_update, $result ) {
    if ( ! empty( $type ) && $type == 'success' ) {
        return false;
    }
    return true;
}
Method 2: Disable update email notification by plugin
 
This is the most simpler way that does not require any code. You need to add Disable Core Update Email plugin.
Once downloaded, activate it and good to use. There are no settings of the plugin, you activate it and it simply disables email notification.
Hope this will ease your tasks and save time. Feel free to share any feedback, Hire WordPress Developer to fulfill your requirements we always ready to help you 🙂

How To Implement Multiselect Tag Input In Ionic App Development

Implement Multiselect Tag Input

Ionic tagging is most beautiful textbox (component) in the application. Basically, this component is used for filtering the data. In E-commerce application where the user needs to filter data from a large number of categories, we can use this. Some of the examples are Flipkart, Amazon, Snapdeal etc.

The Tagging component looks like autocomplete textbox but the major difference is that we can’t  select multiple tags in autocomplete textbox. Here, we can select multiple types. The ideal example is the mailbox where we need to send an email to more than one person at that time we can use this.

Ionic (Hybrid App Development) is providing such facility that we can integrate one simple plugin in the application for fulfilling the tagging feature need. The name of the plugin is ui-select2. There is one more plugin using which gives similar functionality named Tag Input.

Installation Methods: Below are the two methods for installing above mentioned plugins.

Npm
    $ npm install ui-select
    $ npm install ng-tags-input --save
bower

    $ bower install angular-ui-select 
    $ bower install ng-tag-input --save 

Installation ui-select

Let’s start with first plugin ui-select: After the installation of plugin, please import js files using below mentioned code in index.html

<script src="lib/select2/select2.js"></script>
<script src="lib/angular-ui-select2/src/select2.js"></script>
<link rel="stylesheet" type="text/css" href="lib/select2/select2.css">

Now take a field in your view (.html) file.

<input type="hidden" ui-select2="select2Options" ng-model="listData.list_of_string">

Review the attribute

ui-select2="select2Options"

It will empower you to get the multiple values in your text field instead of comma separated list you will have tagging kind of look and feel. Once accessed using model value in the controller you will get an array instead of comma separated string value. The look and feel of input tags are because of CSS you have imported in the index.html file. You can always override that CSS by using your own scss in your application to match it with your application theme. You can also create new tags as well while entering non-existing data in the field and just hit enter or GO button from the device.

Js File in controller

Now, as we got all the required libraries with us we need to start coding and for that first, we need to add the dependency in the controller file using below mentioned code.

angular.module('myModule', ['ui.select']);

You can always use strings of tags or bind an array to your tags. But we suggest you to go with Tags as it will give you the power of setting ids to each element of the array so that you can later refer it easily.

$scope.list_of_string_data= {
       0:'Amsterdam',
       1:'Washington',
       3:'Sydney',
       4:'Beijing',
       5:'Cairo'
};

 $scope.select2Options = {
        'multiple': true,
        'simple_tags': true,
        'tags':$scope.list_of_string_data
 };
Here, We will create object store in tag in input tags.
Installation ui-tag-input (“tag input”) Now let’s talk about another plugin ui-tag-input
After the installation of plugin, please import js files using below-mentioned code in index.html
<script src="angular.js"></script>
<script src="ng-tags-input.js"></script>
<link rel="stylesheet" type="text/css" href="ng-tags-input.css">
 Now take a field in your view (.html) file.
<tags-input ng-model="tags">
        <auto-complete source="loadTags($query)"></auto-complete>
 <p>Model: {{tags}}</p>
</tags-input>

The Plugin is rich enough to provide its own directive for tagging facility.Js File in controllerNow, as we got all the required libraries with us we need to start coding and for that first, we need to add the dependency in the controller file using below mentionedcode.
angular.module('myModule', ['ngTagsInput'])

app.controller('MainCtrl', function($scope) {
  $scope.tags = [
    { text: 'abc' },
    { text: 'xyz' },
    { text: 'pqr' }
  ];
});
Here, we will create default tag in an input field and tags would be ‘abc’,’XYZ’,’PQR’.
We can access this information through model associated with the field in view inside the controller file. This plugin also provides data in array format like the former one.
Hope this article has helped you to get the tagging feature in your application.