Newsfeeds

Promet Source: How to Stop SPAM with Drupal 8's Recaptcha module

Planet Drupal - 17 December 2018 - 5:43pm
Have you ever tried logging in or registering to a website and you were asked to identify some distorted numbers and letters and type it into the provided box? That is the CAPTCHA system. The CAPTCHA helps to verify whether your site's visitor is an actual human being or a robot. Not a robot like you see in the Terminator movie but an automated software to generate undesired electronic messages (or content). In short, CAPTCHA protects you from SPAM.  
Categories: Drupal

Flocon de toile | Freelance Drupal: Small sites, large sites, micro sites with Drupal 8

Planet Drupal - 17 December 2018 - 5:04pm

Drupal 8 is a tool designed to meet the needs of the most ambitious web projects. We hear a lot about the notions of headless, API first, decoupling, etc. that resolutely allow solid architectures for ambitious projects. But this does not mean that Drupal 8 no longer propels more traditional, and sometimes even much less ambitious sites: simple, small, and even large, websites, but for which we want to benefit from the modularity, flexibility and robustness of Drupal.

Categories: Drupal

Region In Content Template

New Drupal Modules - 17 December 2018 - 3:01pm

If you want to show a block within the content region of your Drupal 8 site, this may be the module for you. Specifically, if you would like to print the secondary menu region mixed in among the fields of your content in your custom full node template, we've got you covered.

Categories: Drupal

Shortcut Menu

New Drupal Modules - 17 December 2018 - 12:58pm

Drupal core shortcuts doesn't provide the ability to nest shortcuts like a traditional menu. This module provide the nesting capability that users are familiar with.

Categories: Drupal

Trisbee Commerce Payments

New Drupal Modules - 17 December 2018 - 12:07pm
Categories: Drupal

PHP PDFTK

New Drupal Modules - 17 December 2018 - 10:48am

This module wraps php-pdftk which is a PDF conversion and form utility based on pdftk.

Brings the power of pdftk to Drupal. Fill forms, split PDFs, add backgrounds or overlays, and more.

Requirements

The pdftk command must be installed on your system.

The php-pdftk library and it's dependencies must be installed in the `sites/all/library` directory.

Categories: Drupal

Steam's 'Top Wishlists' filter ranks recent wishlist numbers for unreleased games

Social/Online Games - Gamasutra - 17 December 2018 - 10:37am

A little-known page on Steam ranks unreleased games according to the number of Wishlists they†™ve garnered so far, though the exact metrics being tracked are still somewhat unclear.  ...

Categories: Game Theory & Design

Gábor Hojtsy: How to automate testing whether your Drupal 8 module is incompatible with Drupal 9?

Planet Drupal - 17 December 2018 - 10:23am

Drupal 9 is planned to be only 18 months away now, wow! It is already being built in Drupal 8 by marking APIs to be removed in Drupal 9 as deprecated and eventually upgrading some dependency version requirements where needed. Once the Drupal 9 git branch will be open, you will be able to test directly against Drupal 9. That should not stop you from assessing the compatibility of your module with Drupal 9 now. To prepare for compatibility with Drupal 9, you need to keep up with deprecated functionality and watch out for upgraded dependencies (when we know which are those exactly). Of these two, automation can go a long way to help you keep up with deprecated APIs.

Categories: Drupal

DrupalCon News: DrupalCon Seattle: Sessions and Strides

Planet Drupal - 17 December 2018 - 10:10am

DrupalCon Seattle is looking different than the DrupalCons of years past.

The overarching goal when planning DrupalCon Seattle 2019 was to expand both outreach and accessibility so that attendees would be representative of the community as a whole. The value of the conference is in the perspectives, energy and diversity of experiences participants share.

DrupalCon began setting goals to overtly increase diversity starting with DrupalCon Baltimore 2017. This continued in the planning of DrupalCon Nashville 2018, and is prioritized for DrupalCon Seattle 2019.

Categories: Drupal

MidCamp - Midwest Drupal Camp: Summits: What to Expect?

Planet Drupal - 17 December 2018 - 9:37am
Summits: What to Expect?

This year MidCamp will be including summits in addition to the regular programming that we have provided in the future. Here are some things we think you should know in order to prepare yourself:

A summit is a one-day topic-intensive meeting where people who share an industry or interest can come together to collaborate, share pain points and solutions, and meet like-minded individuals in a structured, safe environment.

Summits focus a full day unconference around a singular topic, in which different groups of interested parties collaborate, gather information and learn together. This programming is for focused discussion, planning, hacking and learning about the topic. 

We believe in facilitating like an unconference. On the day of, each summit group led by a facilitator will compile an agenda and create breakout groups on various subtopics of the overall summit topic.

Unlike training, attendees are generally still planning and information gathering. There won’t be any required deliverable, like code or documentation. Instead, summits focus on conversation and dialog. During a training, the focus is learning a thing, but summits encourage open idea sharing on a broad range of topics related to the overall theme. 
 

Takeaways from the Midcamp Team

Below are some stories from our team as they reflect back on their first summit.

“I felt like I was in a room full of rock stars. Angie Byron, Sam Boyer, Chris Vanderwater... I forget who else, but there were a fair number of big names. We were there to discuss the panels/blocks initiative. There was considerable brainstorming on various problems that were currently being solved in the initiative.”

- Andrea Soper

“I just attended my first summit at BADCamp this year. It was the front end summit and attendees were polled ahead of time to get an overall sense of what front end topics people were interested in discussing. At the summit, we used that list and then added to it via post-its to organize the topics into larger categories. Then throughout the day, we broke into smaller groups to discuss almost every topic that came up. The facilitators were good about keeping the discussion moving along and ensuring we covered everything. The day was also broken up with some fun group icebreakers and a talk from one of the creators of GatsbyJS.”

- Kevin Thull

Categories: Drupal

See Blizzard deconstruct Overwatch's social systems at GDC 2019!

Social/Online Games - Gamasutra - 17 December 2018 - 9:04am

It's a promising talk for those interested in systems design & curbing disruptive player behavior, as you'll learn how & why Blizzard implemented Overwatch endorsements and "Looking For Group" systems. ...

Categories: Game Theory & Design

Dev Diary #10 - Player Versus Player (Season 1) - by gumi Team

Gamasutra.com Blogs - 17 December 2018 - 8:12am
For this edition of Developer’s Diary, let us proceed into something impressive. Something global players have been waiting for since the launch of THE ALCHEMIST CODE over a year ago -The Player Versus Player (PvP) feature.
Categories: Game Theory & Design

How to turn your mod into an indie game - by Nick Pearce

Gamasutra.com Blogs - 17 December 2018 - 8:10am
So you’ve made a mod, you’ve heard of the incredible success of mod-to-indie transformations like PUBG & Team Fortress 2, and you’re thinking about transforming your mod into a stand-alone game. Here's what I've learned, making The Forgotten City.
Categories: Game Theory & Design

11 BOSS BATTLES OF X-MORPH: DEFENSE, PART 6 - THE CHINESE DRAGON TRAIN - by Piotr Bomak

Gamasutra.com Blogs - 17 December 2018 - 8:09am
The development of X-Morph: Defense took over 5 years. It seems like a very long time, but it was not enough to implement some of the crazier ideas that we came up with. We would like to share the story of a boss battle that fell victim to its own scope.
Categories: Game Theory & Design

CKEditor Advanced Tab

New Drupal Modules - 17 December 2018 - 7:48am

This module integrates the [dialogadvtab](
https://ckeditor.com/cke4/addon/dialogadvtab) CKEditor plugin for Drupal 8.

This plugin provides the Advanced dialog window tab to extend some editor dialog windows.
Thanks to this other plugins do not need to implement the same features for their dialog windows.

Categories: Drupal

5 trends that defined the game industry in 2018

Social/Online Games - Gamasutra - 17 December 2018 - 7:48am

The year 2018 lasted approximately 30 normal years. From studio closures to the Fortnite phenomenon, here are the trends that defined the game industry in the longest year in the history of humankind. ...

Categories: Game Theory & Design

DrupalEasy: DrupalEasy Podcast 213 - Ted Bowman - Layout Builder in Core

Planet Drupal - 17 December 2018 - 6:33am

Direct .mp3 file download.

Ted Bowman, senior software engineer with the Drupal Acceleration Team at Acquia, joins Mike to discuss the game-changing work of the Layout Initiative. Sorry about the poor quality of part of Mike's side of the conversation (as well as the comical overdubbing of other portions of the conversation).

Discussion DrupalEasy News Upcoming Events Sponsors Follow us on Twitter Subscribe

Subscribe to our podcast on iTunes, Google Play or Miro. Listen to our podcast on Stitcher.

If you'd like to leave us a voicemail, call 321-396-2340. Please keep in mind that we might play your voicemail during one of our future podcasts. Feel free to call in with suggestions, rants, questions, or corrections. If you'd rather just send us an email, please use our contact page.

Categories: Drupal

OpenSense Labs: Breaking Down the Concept of Distributed Content Management System

Planet Drupal - 17 December 2018 - 6:10am
Breaking Down the Concept of Distributed Content Management System Akshita Mon, 12/17/2018 - 19:40

Heading a multinational or location agnostic organization with complex content creation and publication needs while also keeping a track of the content can be a difficult task without the right content management system.

The number of bloggers is expected to reach 31.7 million in 2020 in the US alone. 

Imagine the number of blogs on the internet. The huge amount of information flowing online has brought us to the situation where the ever-flowing media content needs to be routinely stored and encoded. Networked storage and exchange of data allow content to be distributed making the task of content management all but impossible to deal, without a content management system.

Content and teams that interact in a distributed system need to be dealt intrinsically different from the ones that interact in a centralized system.

Considering the popularity of Drupal as the enterprise’s CMS, in this blog, we will explore how it can help in providing and managing the modern digital experience as a Distributed Content Management System.

 

Understanding the Concept

A distributed content management system can be difficult to comprehend to different people as it implies a different meaning to a different situation. 

To develop a better understanding of the distributed content management system, let’s understand with an example of a national daily which also publishes in different regional languages. 

The Distributed Management of Content or The Management of Distributed Content

The Distributed Management of Content deals with the workflow involved in the content creation with a decentralized approach. 

The Management of Distributed Content works around dealing with existing content from a variety of sources, involving input (from other websites/sources), output (to other websites) or both. 

By implementing Distributed Management of Content, organizations can eliminate the time and opportunity for error introduced when users enter content in multiple places. Unlike the first concept, the goals for Management of Distributed Content are generally around efficiency and control. 

Setting up An Example of a National Media House

Let’s call this media house - OneIndia News

One India news has 6 regional websites. Similar to many media institutions, the website channels are split into multiple categories (let’s say 5) and each of those categories further houses a number of sub-sections.  

Some of the regional websites may only have 2 to 4 categories depending on the demand, but others may have upwards of 10. 

Each category has an editorial team of its own.

Now the regional websites are handled by a number of different editors for each category and channel. Toss in the requisite assortment of content types and workflow hierarchy - you can see how quickly the web presence gets complex!  

Management of distributed content revolves around efficiency and control.

At this scale, we’re likely dealing with multiple websites of one media organization, all of which have requirements around content. This has now become the perfect use-case for Distributed Content Management!

  Use Case 1: Publishing Workflows For Individual Websites

For the main website of One India News, a central editorial team with defined roles and distributed content production would suffice.

Consideration of a content approval workflow is a critical part of the content strategy for any organization that employs distributed management.

Each news needs to be added and edited by different people. Editing the news on the live site can result in accidental publishing.

Be it living a number of articles at the same time, sending the final copy for the approval of different persons (without living them) or publishing articles on different subdomains. A robust virtual workflow and content staging and publishing without the requiring the editor to log into the target site is needed from the CMS. 

Publishing workflows will be tailored not only to the regional media house but to each channel and team that’s in charge of their regional website. The idea here is to manage the responsibilities across the organization while empowering the editors. 

Content to be published on the homepage of the website will likely require significantly more oversight than in the humor or offbeat channel. 
 

Use Case 2: Sharing Content Out - Centralized Content On A Distributed Web Platform

Copy-and-paste becomes a less efficient option when the content is further distributed to the workflow.

A distributed system must have a Pub-Sub (Publisher-Subscriber) feature to ensure the information is processed quickly across the different systems. The centralized system must allow editing and processing of the data while pushing the request to the subsystems. This needs to be done asynchronously so the results populate really fast, for the editor. 

Use Case 3: Sharing Content In - Decentralized Websites As Points Of Origin

Another interesting use case presents itself when we consider distributed websites as the starting point for content creation. One India, as any media houses maintain a central calendar of events, such as festivals and political events. 

In a well-formed distributed content model, with an appropriate CMS like Drupal, the same metadata that allows visitors to filter events - audience, department, program - can be easily used to syndicate those events to various other websites.  

Unfortunately, the same level of consideration is not always given to everyone outside the subset team with appropriate permissions. 

Content managers who are generally empowered to manage their own content may not have the same access to do so, or, in cases where they do have permission, find themselves needing to enter content into an entirely different website system to get it published to their site. But why should this be the case?  

By extending the same technologies that allow websites to receive events from a central calendar, in Drupal we can enable content managers to publish events to the calendar from within the same website they usually manage. (The same content approval and publishing workflow considerations apply, of course.)
 

Difference between Centralized and Distributed Content Management
 

Centralized Content Management

Distributed Content Management 

  • All content funneled through one group

  • Small individual workgroups responsible for respective areas

  • Central rules and procedures to ensure rules are followed 

  • The responsibility of individual groups to oversee content quality

  • One person authority - who is responsible for the rules and implementation

  • Each group may have one or more lead approvers. Workgroups leads handle process and rules

  • Advantage - Resulting process control without confusion

  • Advantage - Responsibility and the workload are distributed

  • Disadvantage - May result in a bottleneck

  • Disadvantage - Individual groups can interpret rules differently


Use Case 4: Multichannel Brand Content

Single-source content syndication also provides an opportunity for media companies to promote their brand across multiple mediums. Many companies choose to employ standalone, all-in-one news providers such as Reuters, rather than integrating a category for each of the news providers. 

This makes a tremendous amount of sense - these organization systems when merged with the own CMS can provide a number of compelling results such as quicker results and faster news publishing. 

By programmatically receiving the content from a content repository the organization can eliminate the risk of delayed news and perpetual loss of audience. 


Use Case 5: Content Delivery To Validated Audiences

In an attempt to decentralize content over the years, media organizations now allow users to add stories to the website. 

How they access, validate, identify the users is another key consideration for the company’s distributed content management strategy. 

A common approach is to segregate guest editor content into different regional “portals” - websites that require the editor to create accounts and login to see the information for their country or part of the world.  

To overcome the challenge of validating these accounts, companies often integrate with an Identity Provider (IdP) such as SAML 2.0 Single Sign On easy configuration & active support, in your Drupal website. 

At the far end of the Distributed Content Management spectrum are systems that need to publish consistent, controlled content to websites with no possibility for discrepancies across multiple sites.  

Drupal allows Distributed Content Management strategy to be applied to large volumes of content to facilitate efficient workflow. Specifically, the system allows different content and editors to be part of the same system without much replication. 

Finally, the modular design of the Drupal architecture allows both stand-alone and distributed realizations so that the system can be deployed in a variety of applications. Connect with us, drop a mail at hello@opensenselabs.com or tweet us @OpenSenseLabs

blog banner blog image Content Management System Distributed Management of Content Content sharing Decentralized Websites Drupal CMS Content Creation Content Marketing Distributed content management Blog Type Articles Is it a good read ? On
Categories: Drupal

OpenSense Labs: Important OOP Concepts For Drupal Developers To Create Custom Modules

Planet Drupal - 17 December 2018 - 5:38am
Important OOP Concepts For Drupal Developers To Create Custom Modules Vasundhra Mon, 12/17/2018 - 19:08

Modifying existing code might be all fun and games for a developer, but what about the time when you have to venture out to unknown shores and create your own custom modules? 

Scary, right? 

But you shouldn’t fear because Drupal 8 is here.

Drupal 8 uses a PHP framework called Symphony which relies heavily on Object-oriented programming.

It has been granting its users with benefits like code reuse and encapsulation, and these benefits allow users to maintain and structure code in a better way possible. 


Phew! 

However, this might leave you with a farrago of questions - What do I need to know in Drupal 8 to start developing? What is OOP? Why is it used in Drupal 8 to make modules? How does it create the custom modules? 

Thus, here is how you can do it all that might help make the OOP principle of PHP a little less daunting. 

Start With Prerequisites to Create Custom Modules

We all know that Object Oriented Programming has provided us with the power to create our desired objects and construct methods to handle them. And with the usage of various OOP principles and design patterns, Drupal 8 has brought about a much easier path in terms of development.  

Drupal 8 serves as a great introduction to PHP. Here are some of the design patterns which are important to understand to solve the basic object-oriented design problem. 

PHP Namespace (introduced in version 5.3)

In PHP you can’t have two classes that deal with the same name (they have to be unique). Therefore, PHP namespace allows you to dodge this issue by presenting a similar code into neat little packages, or even to determine ownership.

Drupal 8 consists of a number of files that declare the namespace in order to remain compatible with PHP 5.3. Therefore, with the help of two standards in Drupal, PHP interfaces and traits are easily namespaced.

Use statement

Classes and interfaces with a (\) backslash inside their fully qualified name should not use it inside the core. If it differs from the current file, then it can be solved by using the “use” statement on the top. For example

namespace Drupal\mymodule\Tests\Foo; use Drupal\simpletest\WebTestBase; /** * Tests that the foo bars. */ class BarTest extends WebTestBase {


And, for the file which does not declare a namespace has to specify with the use statement at the top of the file 
For the classes that are without backslash, they must be fully qualified when used in the namespace file.

Also, while you are importing a class with “use”, do not use the backslash. 

Aliasing the class 

PHP has allowed the classes to be aliased when they are being imported into a namespace. It is done to avoid the collision. But suppose the collision still happens, you can alias the classes by prefixing the next higher portion of the namespace.

use Foo\Bar\Baz as BarBaz; use Stuff\Thing\Baz as ThingBaz; /** * Tests stuff for the whichever. */ function test() { $a = new BarBaz(); // This will be Foo\Bar\Baz $b = new ThingBaz(); // This will be Stuff\Thing\Baz } Dependency Injections

Dependency Injections is that software design pattern that would allow you to remove hard-coded dependencies and also make it possible to change them either on runtime or at compile time.

Drupal 8 introduced the concept of services (object managed by service container) in order to decouple reusable functionalities. It creates the services pluggable and replaceable by registering them with the help of a service container.

These services are used to perform operations that include accessing of the database or sending up of an e-mail. Therefore, to let the code simply access the database (without worrying about whether the database is MySQL or SQLite), usage of core provided service via the service container is done.

These core services are defined in CoreServiceProvider.php and core.services.yml. Somewhat like:

... language_manager: class: Drupal\Core\Language\LanguageManager arguments: ['@language.default'] ... path.alias_manager: class: Drupal\Core\Path\AliasManager arguments: ['@path.crud', '@path.alias_whitelist', '@language_manager'] ... string_translation: class: Drupal\Core\StringTranslation\TranslationManager ... breadcrumb: class: Drupal\Core\Breadcrumb\BreadcrumbManager arguments: ['@module_handler'] ...


Each service depends on the other service. Like in the example above path.alias_manager is dependent on the path. crud, path.alias_whitelist and language_manager services specified in the arguments list.

Dependency injection is the preferred procedure for accessing and using services in Drupal 8. Services are transferred as an argument to the container or injected via setter methods.

Symfony 

Symfony is a PHP framework that Drupal borrows from in order to reduce codes duplication across various PHP projects. Much of the code that Drupal 8 uses to handle routing, sessions, and service container. These components are flexible and universal solutions. They are the stable ones and solves most the problems that aren’t good practice, to reinvent the wheel. Symfony follows the standards that adhere to PSR-5 and PSR-7

Annotations

Annotations are the comments in your code that contain meta information. The main advantage of annotations is that they improve performance due to the less memory usage and is placed in the same files as the class is. For example

/** * Provides a 'Custom' Block * * @Block( * id = "custom_block", * admin_label = "Custom block", * ) */


Drupal 8 uses PHP annotations for plugin discovery and to present additional context/meta-data for the codes that have to be executed. These are the read using Doctrine annotation parser (offers to implement custom annotation functionality for PHP classes.) and then they are turned into information that Drupal can use for better understanding on what your code is actually doing. 

Plugins 

Plugins are considered as a small piece of functionalities that can be swapped. Drupal consists of different plugins with different types. The CMS platform provides a set of guidelines and reusable code components that allows the developer to expose pluggable components within their code and manage these components with the user interface. Plugins have three basic elements namely.

Plugin type: It is a central controlling class that would define how the plugin of this type will be discovered and instantiated.

Plugin Discovery: It is the process of finding plugins within the code base that is qualified for the usage.

Plugin Factory: It is responsible for instantiating specific plugins.

Not to Forget the OOP Coding Standards 

If the end user is aware of key OOP principle and design pattern, then it becomes even more easy for them to use it with Drupal. For instance, different services become available when default container initializes while bootstrapping Drupal. In short, you have the power to build your own class, then define it as a service and make it available in the container. 

Drupal 8  has a set of coding standards just for object-oriented code and adheres to common PHP coding conventions. 

Thus, some of the common PHP conventions for OOP that Drupal follows for best practices would include:

  • Declaring a class in OOP. It is important that there should always be one interface or trait per file. The classes are autoloaded based on PSR-4 namespacing convention, and in the core, the tree under PSR-4 starts as core/lib/. For the modules that contain contrib, custom and those in the core, the PSR-4 tree starts under modulename/src. It should also be noted that it is only possible to define a class in a module if the class does not contain any superclass. 
  • Next in this coding standards would be whitespace or indentation method. Both of them leave an empty line between the start of the class definition and property definition. Just like this:
class GarfieldTheCat implements FelineInterface { // Leave an empty line here. public function meow() { ... ... ...

 For an empty space between property definition and method definition:

... ... ... protected $lasagnaEaten = 0; // Leave an empty line here. public function meow() { return t('Meow!'); }

And then for the space between the end of method and end of the class definition:

class GarfieldTheCat implements FelineInterface { ... ... ... public function eatLasagna($amount) { $this->lasagnaEaten += $amount; } // Leave an empty line here. }
  • Without basic naming conventions, coding standard for OOP is a void. These naming conventions (set of rules) would help you to choose the character sequence to be used for the identifier that denotes the variables, functions, types and other entities.  
  • There might be chances where you would also wish to extend your code. Thus the use of separate interface definition would help you by contributing highly in terms of flexibility and would also neatly centralizes the document, making it easier to read.  A class that has to be extended must always provide an interface that other class can implement rather than forming them to extend the base class.
  • Also, it is important for all the methods and properties of classes to specify the visibility (private, protected or public). The use of public properties is strongly discouraged. It allows the entry of unwanted side effects and exposes implementation specific details, which in turn makes swapping out of class (for another implementation) much more hard. 
  • Now comes the “Type Hinting” in PHP. It is basically used to specify the expected data type of an argument in a function declaration.  Although type hinting is optional, it is recommended for debugging.If an object of the incorrect type is passed, an error is shown. If the method’s parameter expects a certain type of interface, it is important to specify it. This would guarantee that you are checking for a type and also maintaining a fluid code.
  • Next is instantiation. It is basically the creation of a real instance or a single realization of an abstraction/template such as the class of object. Drupal coding standards look down upon directly creating classes. Rather it is better to create a function to instantiate the object and return it. It is because:
  1. The function which is written can be reused to return different objects with the same interface as it is needed. 
  2. You are not allowed to chain construct in PHP, but you are allowed to chain return object from the function. 
  • Last but not the least - Chaining.  Chaining is that blessing for you which allows you to immediately call a function on a return object. This is also known as “fluent interface”
// Unchained version $result = db_query("SELECT title FROM {node} WHERE nid = :nid", array(':nid' => 42)); $title = $result->fetchField(); // Chained version $title = db_query("SELECT title FROM {node} WHERE nid = :nid", array(':nid' => 42))->fetchField();

A method would return $this, and then would be chainable in a case where there is no other logical return value.

In cases that have a fluid interface of the classes, and code span of more than one line, the method calls should attend 2 spaces

$query = db_select('node') ->condition('type', 'article') ->condition('status', 1) ->execute(); Routing in Drupal 8 is Equally Important 

Drupal 8 routing system works with the Symfony HTTP kernel. The routing path has replaced hook_menu() in Drupal 7. Though in Drupal 8 heavy use of Symphony 2 components handle the routing part. Drupal 8 also uses YAML format. All the information about routes of a module is kept in the file MODULE_NAME.routing.yml. 

The routing system is responsible for matching paths to the controller and then you are allowed to those relations in routes. The additional information can also be passed to controllers in the router. 

Each route has to be described separately from one another with the involvement of these characteristics :

  • Name for identifying the routes 
  • Path beginning with a slash
  • A route’s processor
  • Condition managing the access to the route
example.my_page: path: '/mypage/page' defaults: _controller: '\Drupal\example\Controller\ExampleController::myPage' _title: 'My first page in Drupal8' requirements: _permission: 'access content'

Example.my_page is the route in the .routing.yml file. The route is the Symfony component which maps the HTTP request to set the configuration variable. Under path, we specify the path where route should be registered. This acts as the URL to route 

Creating “Controller Class”

It is important to build the ModuleController.php according to the PSR-4 naming standard. You just have to create a folder along with a file name with the following content. 

<?php /** * @file * @author Rakesh James * Contains \Drupal\example\Controller\ExampleController. * Please place this file under your example(module_root_folder)/src/Controller/ */ namespace Drupal\example\Controller; /** * Provides route responses for the Example module. */ class ExampleController { /** * Returns a simple page. * * @return array * A simple renderable array. */ public function myPage() { $element = array( '#markup' => 'Hello world!', ); return $element; } } ?>

A controller is a type of PHP function that you create. It takes the information from the HTTP request and creates or responds to an HTTP response.

Creating the “.module file”

In Drupal 8 hook_menu() is used to only define items. If you have a hook_menu() then make sure that route and path in example.module should match with example.routing.yml.

In the case of items and route example, .module should be on the same path.

<?php /** * @File * Example custom module for Drupal 8. * @author Rakesh */ /** * Implementing hook_menu(). */ function example_menu() { // The paths given here need to match the ones in example.routing.yml exactly. $items['/mypage/page'] = array( 'title' => 'First page', 'description' => 'This is a example page.', // The name of the route from example.routing.yml 'route' => 'example.my_page', ); return $items; } Conclusion

So here it is. Now, you know the concepts of OOP to create a custom module. Yes, it is important to know OOP, design patterns, Twig, and modern PHP trends for creating the modules, and Drupal makes this task even more easy for you. Isn’t it?

If you’re looking for more good resources and reference material, head over to OpenSense labs, where we provide services that develop complex web applications with relative ease. Whether it is the development of a new custom module or optimization of your new website, everything is handled and tailored according to your needs. 

So contact us at hello@opensenselabs.com for more information and reference on the same. 

blog banner blog image Drupal Drupal 8 Drupal Modules Object Oriented Programming Symfony PHP PHP Namespace Dependency Injections Annotations Plugins Chaining Routing Coding Standards design patterns Blog Type Tech Is it a good read ? On
Categories: Drupal

A Wintry Adventure For Your Holiday Game

Gnome Stew - 17 December 2018 - 5:00am

In the past, I’ve written holiday articles about sinister Santas, and evil elves. This year I present a roughed out tongue in cheek Holiday adventure ready to be adapted to a system of choice or stolen for your own game.

Setup: A dark god is spawning an avatar on the material plane. The PCs find out and it’s up to them to stop the strange being from  furthering its patron’s influence. They will encounter resistance of several types and the longer it takes them to reach the final showdown with the avatar, the more difficult it will be to defeat it. Keep some sort of counter to indicate how long it takes to reach the final scene.

Scene 1:  A new red star flickers malignantly in the sky in late afternoon and a cold wind blows the first flakes of snow. It is obviously an ill omen. With skill checks or visiting a sage, PCs can discover the following:

  • The star and storm are symbols of the arrival of a new power
  • The new power can be found under the star
  • There are expensive herbs that can be burned to ward off the power and it’s minions ( All enemies in the adventure count as minions. PCs will have to gather or purchase these herbs if they want them. Gathering takes more time, purchasing more money.)

Scene 2:  As the PCs travel towards the star, the storm increases in power. It makes checks to track based on the star more difficult and failed checks add time to the counter. Before long they encounter a herd of maddened sheep. Some are simply maddened animals, others have been twisted by the dark power giving them extra limbs or allowing them to walk on two legs or bite for damage. Play these up as being each twisted in strange and unique ways. PCs will also see the remains of several eaten people littering the ground, mostly bones and scraps of cloth. While they are being harassed by the beasts, the PCs will hear cries for help from nearby. A shepherd is up in a tree and surrounded by a cluster of the monsters. The PCs can either drive off or kill the monsters attacking them and move on, leaving the NPC to their fate, or take extra time to save them. If saved, he asks the PCs why they happened to be in range to help and will accompany them if allowed to. He knows he will most likely die but considers their cause important and owes them his life anyway.

Scene 3: The storm increases in power again. Now navigating is more difficult again and sight range is limited, making ranged attacks more difficult. The PCs encounter flying demons who attempt to slow their progress with unholy song. These demons fly in the storm without hindrance and sing in an attempt to slow the PCs. Failing saves causes mesmerization for a short time. PCs can attempt to snap each other out of the effect with simple actions, or can attack the demons to stop them. If all the PCs are ever mesmerized at the same time, add some time to the counter and fast forward to when the next PC comes out of the effect. If the shepherd is with the PCs he will not attack the demons (aside from throwing stones he doesn’t have any way to do so) but will instead sing prayers to ward off the effects of their singing. This will grant save bonuses to all PCs. If other PCs join in singing they will grant the same bonus (these do not stack) and grant THEMSELVES a bigger bonus. You may wish to grant xp bonuses to players who actually sing while not describing their actions (without being disruptive).

Scene 4: The storm grows stronger and colder and starts to cause damage or roll penalties to the PCs in addition to the navigation and ranged attack penalties, unless they have warm gear or cold resistance. The star leads to a barn. Inside is a variety of livestock including a horse and her wide eyed newborn mule, a mutilated family of farmers and a large demonic entity. Some of the livestock cowers, others are mad as with the sheep from the earlier scene. While the demonic entity is a challenging foe (and the PCs will have to defeat it and any maddened creatures) it’s not actually the new evil power. Instead the new power is the baby mule. If the PCs defeat the obvious threat and aren’t thorough, they may miss the more subtle one. If the shepherd is with them and survives the fight, he may miss a save via fiat and stay and tend to the remaining docile animals.

Conclusion: There could be a couple outcomes here. Either the PCs miss the mule, in which case it may come back to be a threat later, or they deal with it in one way or another. This could be as simple as killing it, or taking it on to convert it, etc… Sky’s the limit here. If the mule is stopped, the god behind it will be angered and most certainly will send other agents to deal with the PCs later. It’s lose-lose which as a GM I love. Means there’s always more hooks to pursue.

The evil mule is of course the scion of the evil mules that occasionally turn up in my games. (See? Told you it would be relevant.) They’re fun because they’re as good as invisible, make your players paranoid as hell, and are great for anything from a one shot to a world threatening evil. They’re also just a little bit silly. Enjoy!

Categories: Game Theory & Design

Pages

Subscribe to As If Productions aggregator