When Drupal 7 was released in 2011, it came with an improved implementation of AJAX functionality. Good-bye “AHAH” and hello “AJAX Framework”. But four years later, some of the improvements that came along with the Drupal AJAX Framework go widely unused or unknown.
Introducing AJAX commands. The set of functions you should already be using, which allow AJAX callbacks to do much more then return rendered HTML.
This session will highlight and outline the Drupal AJAX command functions offered by the AJAX framework in both Drupal 7 and Drupal 8. In this session we will cover the following:
- The Drupal AJAX command functions.
- What functionality AJAX command functions provide.
- When and how to use the AJAX command functions.
- How to create custom AJAX commands.
Este documento resume las principales novedades del universo JavaScript en Drupal 8. Introduce las nuevas APIs como Drupal.behaviors y Drupal.theme, y explica cómo añadir JavaScript a módulos y temas mediante librerías declaradas en ficheros YAML. También ofrece consejos sobre buenas prácticas de desarrollo como usar el modo estricto y crear plugins y bibliotecas propias.
After unnecessary complexity has been reduced from the problem being solved, the scope of the solution to the problem is governed by the complexity of the problem. Complexity is needed to handle and process complexity. Systems acquire or accrete unnecessary complexity over time as originally unforeseen exceptions or changes are incorporated. It may be possible to reduce complexity by collapsing/compressing/combining/consolidating elements and by removing non-value-adding, duplicate, redundant activities. When unnecessary or accreted complexity in the problem being solved has been removed, you are left with necessary complexity that must be incorporated into the solution. Simple problems do not have complex solutions. Complex problems do not have simple solutions. The complexity factor of the proposed solution must match the complexity factor of the problem being resolved. Many system implementation and operational failures arise because of failure to understand and address the core complexity of the problem.
This document summarizes a presentation on integrating the ACORD framework for insurance enterprise architecture with The Open Group's ArchiMate modeling language. It discusses the collaboration between ACORD and The Open Group to develop an insurance industry reference model in ArchiMate. It also provides an overview of ACORD initiatives and standards, and presents a case study applying ArchiMate views to model a new business setup process using the ACORD framework. The conclusion is that further alignment of TOGAF, ArchiMate and ACORD would make their combined use even easier for insurance enterprise architects.
Apache Kafka® Delivers a Single Source of Truth for The New York Timesconfluent
The New York Times stores every piece of content it has ever published in Apache Kafka. It takes a log-based approach where all content is published as events to a central "Monolog" topic in Kafka. This log becomes the single source of truth, and all applications consume from the log. The content is stored in Kafka as Protobuf messages with a well-defined schema. A separate "Skinny Log" topic contains notifications that content was processed, to enable caching and track service level objectives. This log-based architecture aims to decouple producers and consumers of content and make the system more flexible and scalable.
What Can We Do With The ArchiMate Language?Iver Band
Last year, the Open Group released version 3.0 of the ArchiMate® standard, which provides a language with concepts for describing enterprise and solution architectures, a framework for organizing these concepts, a graphical notation for these concepts, and recommendations for viewpoints, which are visualization templates that address the concerns of particular stakeholders. The standard is public and free for end users. It can be extended through specialization of its concepts and relationships, and is supported by an increasing number of tools, consultancies and training organizations.
We use a fictitious—but realistic—case study to describe what we can do with the ArchiMate language. Each of the sections in this article presents one or more views of an ArchiMate model that tells a story about the collection and analysis of Big Data to create business value. Big Data consists of datasets that cannot be handled efficiently with traditional centralized data architectures due to their extensive volume, variety, velocity and variability. These characteristics demand scalable architectures for efficient storage, manipulation and analysis.
Decomposing Applications for Scalability and Deployability (April 2012)Chris Richardson
Today, there are several trends that are forcing application architectures to evolve. Users expect a rich, interactive and dynamic user experience on a wide variety of clients including mobile devices. Applications must be highly scalable, highly available and run on cloud environments. Organizations often want to frequently roll out updates, even multiple times a day. Consequently, it’s no longer adequate to develop simple, monolithic web applications that serve up HTML to desktop browsers. In this talk we describe the limitations of a monolithic architecture. You will learn how to use the scale cube to decompose your application into a set of narrowly focused, independently deployable back-end services and an HTML 5 client. We will also discuss the role of technologies such as NodeJS and AMQP brokers. You will learn how a modern PaaS such as Cloud Foundry simplifies the development and deployment of this style of application.
Este documento resume las principales novedades del universo JavaScript en Drupal 8. Introduce las nuevas APIs como Drupal.behaviors y Drupal.theme, y explica cómo añadir JavaScript a módulos y temas mediante librerías declaradas en ficheros YAML. También ofrece consejos sobre buenas prácticas de desarrollo como usar el modo estricto y crear plugins y bibliotecas propias.
After unnecessary complexity has been reduced from the problem being solved, the scope of the solution to the problem is governed by the complexity of the problem. Complexity is needed to handle and process complexity. Systems acquire or accrete unnecessary complexity over time as originally unforeseen exceptions or changes are incorporated. It may be possible to reduce complexity by collapsing/compressing/combining/consolidating elements and by removing non-value-adding, duplicate, redundant activities. When unnecessary or accreted complexity in the problem being solved has been removed, you are left with necessary complexity that must be incorporated into the solution. Simple problems do not have complex solutions. Complex problems do not have simple solutions. The complexity factor of the proposed solution must match the complexity factor of the problem being resolved. Many system implementation and operational failures arise because of failure to understand and address the core complexity of the problem.
This document summarizes a presentation on integrating the ACORD framework for insurance enterprise architecture with The Open Group's ArchiMate modeling language. It discusses the collaboration between ACORD and The Open Group to develop an insurance industry reference model in ArchiMate. It also provides an overview of ACORD initiatives and standards, and presents a case study applying ArchiMate views to model a new business setup process using the ACORD framework. The conclusion is that further alignment of TOGAF, ArchiMate and ACORD would make their combined use even easier for insurance enterprise architects.
Apache Kafka® Delivers a Single Source of Truth for The New York Timesconfluent
The New York Times stores every piece of content it has ever published in Apache Kafka. It takes a log-based approach where all content is published as events to a central "Monolog" topic in Kafka. This log becomes the single source of truth, and all applications consume from the log. The content is stored in Kafka as Protobuf messages with a well-defined schema. A separate "Skinny Log" topic contains notifications that content was processed, to enable caching and track service level objectives. This log-based architecture aims to decouple producers and consumers of content and make the system more flexible and scalable.
What Can We Do With The ArchiMate Language?Iver Band
Last year, the Open Group released version 3.0 of the ArchiMate® standard, which provides a language with concepts for describing enterprise and solution architectures, a framework for organizing these concepts, a graphical notation for these concepts, and recommendations for viewpoints, which are visualization templates that address the concerns of particular stakeholders. The standard is public and free for end users. It can be extended through specialization of its concepts and relationships, and is supported by an increasing number of tools, consultancies and training organizations.
We use a fictitious—but realistic—case study to describe what we can do with the ArchiMate language. Each of the sections in this article presents one or more views of an ArchiMate model that tells a story about the collection and analysis of Big Data to create business value. Big Data consists of datasets that cannot be handled efficiently with traditional centralized data architectures due to their extensive volume, variety, velocity and variability. These characteristics demand scalable architectures for efficient storage, manipulation and analysis.
Decomposing Applications for Scalability and Deployability (April 2012)Chris Richardson
Today, there are several trends that are forcing application architectures to evolve. Users expect a rich, interactive and dynamic user experience on a wide variety of clients including mobile devices. Applications must be highly scalable, highly available and run on cloud environments. Organizations often want to frequently roll out updates, even multiple times a day. Consequently, it’s no longer adequate to develop simple, monolithic web applications that serve up HTML to desktop browsers. In this talk we describe the limitations of a monolithic architecture. You will learn how to use the scale cube to decompose your application into a set of narrowly focused, independently deployable back-end services and an HTML 5 client. We will also discuss the role of technologies such as NodeJS and AMQP brokers. You will learn how a modern PaaS such as Cloud Foundry simplifies the development and deployment of this style of application.
How to Enable Change Management with Jira Service ManagementCprime
Improve your agility by moving towards automation and streamlined processes between your IT and dev teams. ITSM with Jira Service Management (JSM) can help optimize your processes and significantly reduce manual touch points, while change management minimizes risks and disruptions to your IT services.
This is the first part in a series where we cover change management with Jira Service Management in depth. Join our ITIL-certified experts to learn how to manage changes to your software or infrastructure using Jira Service Management so that you accurately understand the impact and scope of changes up and downstream.
Explore:
• How to get started with change management
• A demo of change management features in JSM
• Change management best practices and tips
Git Anti-Patterns - Extended Version With 28 Common Anti-Patterns) - SCTurkey...Lemi Orhan Ergin
This document discusses common Git anti-patterns and provides recommendations to avoid them. It begins by explaining how Git works under the hood in terms of files, folders, references, and objects. It then covers 15 specific anti-patterns to avoid, such as treating Git like Dropbox, having long-living topic branches, merging too late without validation, and being afraid to delete branches. For each anti-pattern, it provides alternatives and recommendations, such as splitting work into small tasks, committing early and often, rebasing rather than merging, and deleting merged branches. The overall message is how to use Git properly and cure common issues by following best practices.
Essentials of enterprise architecture toolsiasaglobal
Enterprise architecture tools help organizations transform by capturing essential business and IT information. The tools must:
1. Include repositories for business, information, technology, and solutions viewpoints and their relationships.
2. Support modeling, decision analysis, visualization, and administration capabilities.
3. Integrate with project and portfolio management to ensure investments align with business strategy and vision.
The document discusses how enterprise architecture tools can help organizations address challenges like aligning supply and demand, integrating business and IT strategies, and executing business strategies. It outlines requisites for tools to support business strategy modeling, domain modeling, process modeling, and governance. Overall, the document argues that enterprise architecture tools are necessary to drive organizational change and
The document describes the different types of viewpoints and artifacts that can be produced at various phases of an architecture project following the TOGAF standard. It outlines catalogs, matrices, diagrams that define foundational and domain-specific views, including principles catalogs in preliminary phase, stakeholder maps in phase A, and various business, data, application, and technology models in subsequent phases. The document provides details on the purpose and contents of specific viewpoints and artifacts.
We often relate Domain-Driven Design with the content of Eric Evans' book; however even this book suggests looking outside for other patterns and inspirations: analysis patterns (Accounting, Finance), domain-oriented use of design patterns (the Flyweight pattern), established formalisms (e.g. monoids) and XP literature in particular (e.g. the patterns on the c2 wiki and OOPSLA papers).
The world has not stopped since the book either, and new ideas keep on emerging regularly. And you can share your own patterns as well.
In this session, through examples and code we'll go through some particularly important patterns which deserve to be in your tool belt. We'll also provide guidance on how best to use them (or not), at the right time and in the right context, and on how to train your colleagues on them!
The Acord Framework - An Insurance Enterprise Architecture (2011).pdfhavoc2003
The document discusses ACORD's Enterprise Architecture Framework, which includes five facets: the Business Glossary, Capability Model, Process Maps, Information Model, and standards mappings. The Framework provides a common foundation for insurance organizations and aims to streamline standards development. The Capability Model defines the key capabilities of insurers, while the Information Model organizes insurance concepts and forms the basis for developing standards in a consistent, model-driven manner. The Framework is intended to facilitate greater efficiency, collaboration, and innovation across the insurance industry.
Logging is one of those things that everyone complains about, but doesn't dedicate time to. Of course, the first rule of logging is "do it". Without that, you have no visibility into system activities when investigations are required. But, the end goal is much, much more than this. Almost all applications require security audit logs for compliance; application logs for visibility across all cloud properties; and application tracing for tracking usage patterns and business intelligence. The latter is that magic sauce that helps businesses learn about their customer or in some cases the data is FOR the customer. Without a strategy this can get very messy, fast. In this session Michele will discuss design patterns for a sound logging and audit strategy; considerations for security and compliance; the benefits of a noSQL approach; and more.
The document provides an agenda for an enterprise architecture presentation covering topics such as EA introductions, frameworks, content modeling, repositories, development methods, and updates to business architecture and EA tools. It includes diagrams to illustrate EA concepts such as relating EA to Lego blocks, architecture domains, and the enterprise continuum for categorizing architecture. The presentation aims to provide an overview of enterprise architecture and discuss best practices.
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...luisw19
Originally designed by Facebook to allow its mobile clients to define exactly what data should be send back by an API and therefore avoid unnecessary roundtrips and data usage, GraphQL is a JSON based query language for Web APIs. Since it was open sourced by Facebook in 2015, it has undergone very rapid adoption and many companies have already switch to the GraphQL way of building APIs – see http://GraphQL.org/users.
However, with some many hundreds of thousands of REST APIs publicly available today (and many thousands others available internally), what are the implications of moving to GraphQL? Is it really worth the effort of replacing REST APIs specially if they’re successful and performing well in production? What are the pros/cons of using GraphQL? What tools / languages can be used for GraphQL? What about API Gateways? What about API design?
With a combination of rich content and hands-on demonstrations, attend this session for a point of view on how address these and many other questions, and most importantly get a better understanding and when/where/why/if GraphQL applies for your organisation or specific use case.
Understanding and Applying The Open Group Architecture Framework (TOGAF)Nathaniel Palmer
TOGAF is a framework for enterprise architecture developed and supported by The Open Group. It provides best practices for developing architectures and includes components such as the Architecture Development Method, reference models and a resource base. The latest version, TOGAF 8, focuses on aligning architecture with business needs and making TOGAF easier to use. TOGAF certification and training are available for individuals and organizations.
Software Architecture: views and viewpointsHenry Muccini
This is an introductory lecture to Software Architecture Views and Viewpoints, part of the Advanced Software Engineering course, at the University of L'Aquila, Italy (www.di.univaq.it/muccini/SE+/2012)
A link schema in DOORS helps provide control, enable analysis, and ensure consistency. It defines the allowed relationships between different information types, like how requirements satisfy other requirements or tests. The document provides tips for setting up a link schema, such as drawing out expected information types and relationships, planning links from later to earlier information, avoiding round trip or within-module links, and not using the default Links module. Analysis views can then be created and saved in DOORS to facilitate traceability and reporting across projects.
The Enterprise Architecture Toolkit (EATK) is a solution accelerator that introduces new capabilities to simplify and consolidate enterprise architecture design. It leverages existing tools like Microsoft SharePoint, Office, and Visio by providing architecture templates, a portal, and processes. The EATK aims to enable transparency, create a proactive architecture process, and empower architects by surfacing relevant information through its architecture repository.
This document provides an architectural overview of the C-Registration System developed by Wylie College to support online course registration. It includes 4 views: use case view, logical view, process view, and deployment view. The use case view describes the key use cases such as registering for courses, maintaining student information, and submitting grades. The logical view shows the system divided into 3 packages - user interface, business services, and business objects. The business services package controls interactions with external systems like the billing system.
A pattern language for microservices - June 2021 Chris Richardson
The microservice architecture is growing in popularity. It is an architectural style that structures an application as a set of loosely coupled services that are organized around business capabilities. Its goal is to enable the continuous delivery of large, complex applications. However, the microservice architecture is not a silver bullet and it has some significant drawbacks.
The goal of the microservices pattern language is to enable software developers to apply the microservice architecture effectively. It is a collection of patterns that solve architecture, design, development and operational problems. In this talk, I’ll provide an overview of the microservice architecture and describe the motivations for the pattern language. You will learn about the key patterns in the pattern language.
NYCCAMP 2015 Demystifying Drupal AJAX Callback CommandsMichael Miles
When Drupal 7 was released in 2011, it came with an improved implementation of AJAX functionality. Good-bye “AHAH” and hello “AJAX Framework”. But four years later, some of the improvements that came along with the Drupal AJAX Framework go widely unused or unknown.
Introducing AJAX Callback commands. The set of functions you should already be using, which allow AJAX callbacks to do much more then return rendered HTML.
This session will highlight and outline the Drupal AJAX Callback command functions offered by the AJAX framework in both Drupal 7 and Drupal 8. In this session we will cover the following:
The Drupal AJAX command functions.
What functionality AJAX command functions provide.
When and how to use the AJAX command functions.
How to create custom AJAX commands.
Анатолий Поляков - Drupal.ajax framework from a to zLEDC 2016
This document discusses Drupal's AJAX framework and how it can be used to build AJAX functionality into forms and other elements. It provides examples of using the framework to add AJAX features to forms, blocks, and links. Commands are used to manipulate the DOM and return HTML. Custom commands can also be added. The framework handles most business logic on the backend and allows building complex AJAX functionality with little required JavaScript code.
How to Enable Change Management with Jira Service ManagementCprime
Improve your agility by moving towards automation and streamlined processes between your IT and dev teams. ITSM with Jira Service Management (JSM) can help optimize your processes and significantly reduce manual touch points, while change management minimizes risks and disruptions to your IT services.
This is the first part in a series where we cover change management with Jira Service Management in depth. Join our ITIL-certified experts to learn how to manage changes to your software or infrastructure using Jira Service Management so that you accurately understand the impact and scope of changes up and downstream.
Explore:
• How to get started with change management
• A demo of change management features in JSM
• Change management best practices and tips
Git Anti-Patterns - Extended Version With 28 Common Anti-Patterns) - SCTurkey...Lemi Orhan Ergin
This document discusses common Git anti-patterns and provides recommendations to avoid them. It begins by explaining how Git works under the hood in terms of files, folders, references, and objects. It then covers 15 specific anti-patterns to avoid, such as treating Git like Dropbox, having long-living topic branches, merging too late without validation, and being afraid to delete branches. For each anti-pattern, it provides alternatives and recommendations, such as splitting work into small tasks, committing early and often, rebasing rather than merging, and deleting merged branches. The overall message is how to use Git properly and cure common issues by following best practices.
Essentials of enterprise architecture toolsiasaglobal
Enterprise architecture tools help organizations transform by capturing essential business and IT information. The tools must:
1. Include repositories for business, information, technology, and solutions viewpoints and their relationships.
2. Support modeling, decision analysis, visualization, and administration capabilities.
3. Integrate with project and portfolio management to ensure investments align with business strategy and vision.
The document discusses how enterprise architecture tools can help organizations address challenges like aligning supply and demand, integrating business and IT strategies, and executing business strategies. It outlines requisites for tools to support business strategy modeling, domain modeling, process modeling, and governance. Overall, the document argues that enterprise architecture tools are necessary to drive organizational change and
The document describes the different types of viewpoints and artifacts that can be produced at various phases of an architecture project following the TOGAF standard. It outlines catalogs, matrices, diagrams that define foundational and domain-specific views, including principles catalogs in preliminary phase, stakeholder maps in phase A, and various business, data, application, and technology models in subsequent phases. The document provides details on the purpose and contents of specific viewpoints and artifacts.
We often relate Domain-Driven Design with the content of Eric Evans' book; however even this book suggests looking outside for other patterns and inspirations: analysis patterns (Accounting, Finance), domain-oriented use of design patterns (the Flyweight pattern), established formalisms (e.g. monoids) and XP literature in particular (e.g. the patterns on the c2 wiki and OOPSLA papers).
The world has not stopped since the book either, and new ideas keep on emerging regularly. And you can share your own patterns as well.
In this session, through examples and code we'll go through some particularly important patterns which deserve to be in your tool belt. We'll also provide guidance on how best to use them (or not), at the right time and in the right context, and on how to train your colleagues on them!
The Acord Framework - An Insurance Enterprise Architecture (2011).pdfhavoc2003
The document discusses ACORD's Enterprise Architecture Framework, which includes five facets: the Business Glossary, Capability Model, Process Maps, Information Model, and standards mappings. The Framework provides a common foundation for insurance organizations and aims to streamline standards development. The Capability Model defines the key capabilities of insurers, while the Information Model organizes insurance concepts and forms the basis for developing standards in a consistent, model-driven manner. The Framework is intended to facilitate greater efficiency, collaboration, and innovation across the insurance industry.
Logging is one of those things that everyone complains about, but doesn't dedicate time to. Of course, the first rule of logging is "do it". Without that, you have no visibility into system activities when investigations are required. But, the end goal is much, much more than this. Almost all applications require security audit logs for compliance; application logs for visibility across all cloud properties; and application tracing for tracking usage patterns and business intelligence. The latter is that magic sauce that helps businesses learn about their customer or in some cases the data is FOR the customer. Without a strategy this can get very messy, fast. In this session Michele will discuss design patterns for a sound logging and audit strategy; considerations for security and compliance; the benefits of a noSQL approach; and more.
The document provides an agenda for an enterprise architecture presentation covering topics such as EA introductions, frameworks, content modeling, repositories, development methods, and updates to business architecture and EA tools. It includes diagrams to illustrate EA concepts such as relating EA to Lego blocks, architecture domains, and the enterprise continuum for categorizing architecture. The presentation aims to provide an overview of enterprise architecture and discuss best practices.
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...luisw19
Originally designed by Facebook to allow its mobile clients to define exactly what data should be send back by an API and therefore avoid unnecessary roundtrips and data usage, GraphQL is a JSON based query language for Web APIs. Since it was open sourced by Facebook in 2015, it has undergone very rapid adoption and many companies have already switch to the GraphQL way of building APIs – see http://GraphQL.org/users.
However, with some many hundreds of thousands of REST APIs publicly available today (and many thousands others available internally), what are the implications of moving to GraphQL? Is it really worth the effort of replacing REST APIs specially if they’re successful and performing well in production? What are the pros/cons of using GraphQL? What tools / languages can be used for GraphQL? What about API Gateways? What about API design?
With a combination of rich content and hands-on demonstrations, attend this session for a point of view on how address these and many other questions, and most importantly get a better understanding and when/where/why/if GraphQL applies for your organisation or specific use case.
Understanding and Applying The Open Group Architecture Framework (TOGAF)Nathaniel Palmer
TOGAF is a framework for enterprise architecture developed and supported by The Open Group. It provides best practices for developing architectures and includes components such as the Architecture Development Method, reference models and a resource base. The latest version, TOGAF 8, focuses on aligning architecture with business needs and making TOGAF easier to use. TOGAF certification and training are available for individuals and organizations.
Software Architecture: views and viewpointsHenry Muccini
This is an introductory lecture to Software Architecture Views and Viewpoints, part of the Advanced Software Engineering course, at the University of L'Aquila, Italy (www.di.univaq.it/muccini/SE+/2012)
A link schema in DOORS helps provide control, enable analysis, and ensure consistency. It defines the allowed relationships between different information types, like how requirements satisfy other requirements or tests. The document provides tips for setting up a link schema, such as drawing out expected information types and relationships, planning links from later to earlier information, avoiding round trip or within-module links, and not using the default Links module. Analysis views can then be created and saved in DOORS to facilitate traceability and reporting across projects.
The Enterprise Architecture Toolkit (EATK) is a solution accelerator that introduces new capabilities to simplify and consolidate enterprise architecture design. It leverages existing tools like Microsoft SharePoint, Office, and Visio by providing architecture templates, a portal, and processes. The EATK aims to enable transparency, create a proactive architecture process, and empower architects by surfacing relevant information through its architecture repository.
This document provides an architectural overview of the C-Registration System developed by Wylie College to support online course registration. It includes 4 views: use case view, logical view, process view, and deployment view. The use case view describes the key use cases such as registering for courses, maintaining student information, and submitting grades. The logical view shows the system divided into 3 packages - user interface, business services, and business objects. The business services package controls interactions with external systems like the billing system.
A pattern language for microservices - June 2021 Chris Richardson
The microservice architecture is growing in popularity. It is an architectural style that structures an application as a set of loosely coupled services that are organized around business capabilities. Its goal is to enable the continuous delivery of large, complex applications. However, the microservice architecture is not a silver bullet and it has some significant drawbacks.
The goal of the microservices pattern language is to enable software developers to apply the microservice architecture effectively. It is a collection of patterns that solve architecture, design, development and operational problems. In this talk, I’ll provide an overview of the microservice architecture and describe the motivations for the pattern language. You will learn about the key patterns in the pattern language.
NYCCAMP 2015 Demystifying Drupal AJAX Callback CommandsMichael Miles
When Drupal 7 was released in 2011, it came with an improved implementation of AJAX functionality. Good-bye “AHAH” and hello “AJAX Framework”. But four years later, some of the improvements that came along with the Drupal AJAX Framework go widely unused or unknown.
Introducing AJAX Callback commands. The set of functions you should already be using, which allow AJAX callbacks to do much more then return rendered HTML.
This session will highlight and outline the Drupal AJAX Callback command functions offered by the AJAX framework in both Drupal 7 and Drupal 8. In this session we will cover the following:
The Drupal AJAX command functions.
What functionality AJAX command functions provide.
When and how to use the AJAX command functions.
How to create custom AJAX commands.
Анатолий Поляков - Drupal.ajax framework from a to zLEDC 2016
This document discusses Drupal's AJAX framework and how it can be used to build AJAX functionality into forms and other elements. It provides examples of using the framework to add AJAX features to forms, blocks, and links. Commands are used to manipulate the DOM and return HTML. Custom commands can also be added. The framework handles most business logic on the backend and allows building complex AJAX functionality with little required JavaScript code.
Drupal8Day: Demystifying Drupal 8 Ajax Callback commandsMichael Miles
This session outlines and explains Drupal 8 AJAX callback commands and how to use them. AJAX callback commands are the sets of PHP and JavaScript functions that control all AJAX functionality on a Drupal site. You will be surprised about how simple and straight forward they are. Mastering these commands will allow your AJAX calls to do so much more then just return rendered HTML. Allowing you to provide the visitors of your Drupal 8 site a more dynamic, richer experience.
Demystifying AJAX Callback Commands in Drupal 8Michael Miles
This session outlines and explains Drupal 8 AJAX callback commands and how to use them. AJAX callback commands are the sets of PHP and JavaScript functions that control all AJAX functionality on a Drupal site. You will be suprised about how simple and straight forward they are. Mastering these commands will allow your AJAX calls to do so much more then just return rendered HTML. Allowing you to provide the visitors of your Drupal 8 site a more dynamic, richers experience.
This session is presented in three parts.
First, explaining what AJAX callback commands are.
Second, explaining how to use AJAX callback commands.
Third, explaining how to create and use your own custom commands.
Each section provides example code and walks through a real world Drupal 8 scenario.
Attendees should already be familiar with PHP and JavaScript, as well as, have a general understanding of Drupal and AJAX.
How to Create and Load Model in LaravelYogesh singh
A model is a PHP class where perform data logic and database manipulation like – retrieve data, insert, update, and delete.
In Laravel models classes are stored in app/ directory.
This mainly loads from the controller.
In this tutorial, I show how you create and load Model in the controller and fetch records from MySQL database in Laravel.
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016Nicolás Bouhid
This document provides an overview of using AJAX on Drupal, including:
- What the AJAX API is and how it works through commands to dynamically update content without page refreshes
- How to use it with forms to reload fields or content through callbacks
- Attaching JavaScript behaviors to allow AJAX functionality
- Creating custom commands to extend its capabilities
- Triggering AJAX requests without forms by linking or instantiating AJAX objects
- New features in Drupal 8 like improved commands and documentation
MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8Michael Miles
This session outlines and explains Drupal 8 AJAX callback commands and how to use them. AJAX callback commands are the sets of PHP and JavaScript functions that control all AJAX functionality on a Drupal site. You will be surprised about how simple and straight forward they are. Mastering these commands will allow your AJAX calls to do so much more then just return rendered HTML.
This session is presented in three parts.
- First, explaining what AJAX callback commands are.
- Second, explaining how to use AJAX callback commands.
- Third, explaining how to create and use your own custom commands.
Each section provides example code and a real world Drupal 8 scenario.
This document discusses using JavaScript with Drupal. It introduces Drupal.js, which handles communication between Drupal and JavaScript scripts. It covers defining behaviors, settings, locales, and themes in JavaScript. It also discusses adding and managing scripts, working with libraries like jQuery, and Drupal's Ajax framework for building Ajax forms and functionality.
The document discusses the Model-View-Controller (MVC) pattern, which separates an application into three main components: the model, the view, and the controller. The model manages the application's data logic and rules. The view displays the data to the user. The controller handles input and converts it to commands for the model and view. An example PHP MVC application is provided to illustrate how the components work together. Benefits of MVC include flexibility, testability, and separation of concerns between the three components.
The state of hooking into Drupal - DrupalCon DublinNida Ismail Shah
https://events.drupal.org/dublin2016/sessions/state-hooking-drupal
Major portion of drupal development has been about hooks. We have all used them. But there have been talks about replacing the procedural hook system in Drupal with its Object oriented version - Events. We are already on the track and we, as of now, are required to use Events for many things in Drupal 8.
This session will mainly elustrate:
How hooks work in Drupal.
How we are on the track of moving from hooks to Events in Drupal 8
Where we are? What all do we need Events for and where we are still stuck with hooks.
When to alter and when to fire an event.
How to create and dispatch an Event from your module.
How to listen or subscribe to an Event from your custom Event or an event from core.
How to expose custom hooks in Drupal 8.
Attendees should be familiar with:
Basic Drupal 8 module development.
Basic OOP principles and practices.
Symfony components used in D8.
After attending this session attendees will be able to:
Create their custom events in Drupal 8
Subscribe to the events from core and other modules and to their custom events too.
Will have a knowledge of where to explore the events and where we have to still use hooks.
This document discusses JavaScript fundamentals like variables, data types, objects, and functions. It then covers topics related to organizing JavaScript code including modularization, dependency management, and bundling. Modularization is introduced as a way to organize code into independent and reusable modules. Dependency management with LoadRunner and AMD is presented for loading modules and their dependencies. Bundling is described as a way to merge modules into a single file to reduce HTTP requests. Code examples are provided for many of the concepts and techniques discussed.
This document provides an overview and examples of using PHP and MySQL together for database applications. It begins with a brief review of MySQL including using the command line client and creating database tables. It then covers the basic PHP MySQL functions for connecting to a database, making queries, accessing and processing query results, and freeing resources. Examples are provided for each function. It concludes with a more complex example that displays the contents of a books database table using these PHP MySQL functions.
The document discusses connecting to a MySQL database and selecting a database in PHP. It provides code examples to connect to MySQL using mysql_connect(), select a database using mysql_select_db(), and includes error handling. It also discusses executing simple queries, retrieving query results, counting returned records, and updating, inserting, and deleting records in PHP.
Drupal 7 Theming - Behind the Scenes: PHP control flow starting from entering URL to browser displaying webpage. Covers Theme info file, regions, an Rendear Arrays (Phoenix User Group 1/25/2012)
Come to this talk prepared to learn about the Doctrine PHP open source project. The Doctrine project has been around for over a decade and has evolved from database abstraction software that dates back to the PEAR days. The packages provided by the Doctrine project have been downloaded almost 500 million times from packagist. In this talk we will take you through how to get started with Doctrine and how to take advantage of some of the more advanced features.
1. Job scheduling in PowerShell allows running jobs at scheduled times using triggers and the Register-ScheduledJob cmdlet. An example schedules a daily backup job to run at 3am.
2. The PipelineVariable parameter lets you save command output as a variable accessible in the remainder of the pipeline.
3. Starting in PowerShell 4.0, dynamic method invocation allows calling methods using variable names, and requiring administrator privileges uses a #Requires statement.
Writing HTML5 Web Apps using Backbone.js and GAERon Reiter
A walkthrough of how to write a complete HTML5 web app (both front end and back end) using Google App Engine (Python), Backbone.js, Require.js, underscore.js and jQuery.
Inclusive Design: Thinking beyond accessibilityMichael Miles
There are many differences that impact the way people experience the digital world. From age and gender, vision and dexterity, to location and education. Each difference affects digital inclusion and experiences. As Drupalists it is our job to build products that are usable by, and inclusive of, as many people as possible. To do so, it is important that we plan for the many differences that make up our users.
This session details the importance of having an inclusive mindset in the creation of our digital projects. It explains how Inclusive Design allow for producing positive experiences for a wider audience. Attendees will learn four simple guidelines that they can follow to apply Inclusive Design principles across all project phases including: ux, development and content creation. Attendees will leave with the tools they need to reach a bigger user base while also building towards an accessible and inclusive digital world.
The success of a project is not just the result of the framework that is chosen or the lines of code that are written. Success is also determined by the team of people that work on a project and how they operate as a cohesive unit. To execute with repeated project successes, it’s imperative to first build successful and productive teams.
How does one create an environment of productivity and success in their respective teams? The answer lies in fostering the growth of four key attributes; Communication, Collaboration, Positivity, Responsibility.
This session will explore aforementioned attributes and outline why they are essential to continued team success. Explaining why each attribute matters and how it builds trust and excellence within a team. Attendees of this session will leave with the knowledge of how to foster these qualities within their own team.
How to Foster Team Success | Drupalcon 2017Michael Miles
The success of a project is not just the result of the framework that is chosen or the lines of code that are written. Success is also determined by the team of people that work on a project and how they operate as a cohesive unit. To execute with repeated project successes, it’s imperative to first build successful and productive teams.
How does one create an environment of productivity and success in their respective teams? The answer lies in fostering the growth of four key attributes; Communication, Collaboration, Positivity and Responsibility.
This session will explore aforementioned attributes and outline why they are essential to continued team success. Explaining why each attribute matters and how it builds trust and excellence within a team.
Inclusive Design: Thinking Beyond Accessibility | NERDSummit 2017Michael Miles
There are many differences that impact the way people experience the digital world. From age and gender, vision and dexterity, to location and education. Each difference affects digital inclusion and experiences. As builders of the digital world it is our job to build products that are usable by, and inclusive of, as many people as possible. To do so, it is important that we plan for the many differences that make up our users.
This session details the importance of having an inclusive mindset in the ux and content aspects of our digital projects. It explains how Inclusive Design allow for producing positive experiences for a wider audience. Attendees will learn four simple guidelines that they can follow to apply Inclusive Design principles to their ux and content phases. Attendees will leave with the tools they need to reach a bigger user base while also building towards an accessible and inclusive digital world.
This session is intended for anyone who wants to build digital products that reach as many people as possible.
Inclusive Design: Thinking Beyond Accessibility | DCNL 2017Michael Miles
There are many differences that impact the way people experience the digital world, including (but not lmited to) age, gender, vision, dexterity, location, and education. Each difference affects digital inclusion and experiences. As creators of the digital world it is our job to build products that are usable by, and inclusive of, as many people as possible. To do so, it is important that we plan for the many differences that make up our users. Inclusive Design is the process of creating products and/or services that are accessible to, and usable by, as many people as reasonably possible ... without the need for special adaptation or specialised design.
This session details the importance of having an inclusive mindset in the ux and content aspects of our digital projects. It explains how Inclusive Design allow for producing positive experiences for a wider audience. Attendees will learn four simple guidelines that they can follow to apply Inclusive Design principles to their ux and content phases. Attendees will leave with the tools they need to reach a bigger user base while also building towards an accessible and inclusive digital world.
This session is intended for anyone who wants to build digital products that reach as many people as possible.
The Flexibility of Drupal 8 | DCNLights 2017Michael Miles
In this session we will demonstrate the flexibility of Drupal by going over 8 different ways in Drupal 8 that data can be manipulated. From non-technical methods, "frontend" javascript & templating methods, to "Backend" methods such as building a custom module and overriding services. This session will demonstrate how to implement each one outlining their individual pros and cons, proving that no matter your skill sets you can make Drupal 8 do what you want.
INCLUSIVE DESIGN: Going beyond AccessibilityMichael Miles
People are not ones(1) and zeros(0) and the world is not just black and white. Everyone identifies themselves differently and while it may be impossible to cater to everyones needs, it is important that we strive to make our websites, applications and tools as inclusive as possible.
Inclusive Design is a form of accessibility. It is the concept of begin mindful in making technology available to and usable by all people whatever their abilities, age, economic situation, orientation, language, etc...
In this session we will talk about some of the ways to think about inclusive design on your projects and why it is important. We will discuss what questions and conversations to have with clients, what considerations to think about when planning the UX and design of your site and what architectural decisions to think about when building your site. Along the way we will look at examples of inclusive design in the wild and the benefits they offer.
In this session we will talk about some of the ways to think about inclusive design on your projects and why it is important. We will discuss what questions and conversations to have with clients, what considerations to think about when planning the UX and design of your site and what architectural decisions to think about when building your site. Along the way we will look at examples of inclusive design in the wild and the benefits they offer.
No other CMS offers more flexibility then Drupal. If you need to implement a piece of functionality or change a piece of data, there are a million different ways you can go about it. However, this flexibility can also be daunting and frustrating.How do you know if you are going about your changes the “right" way? The truth of the matter is that there is no “right" way - just the “right for me” way. Any method you choose will come with it’s own sets of drawbacks and benefits.
In this session we will demonstrate the flexibility of Drupal by going over 8 different ways in Drupal 8 that data can be manipulated. From non-technical methods, "frontend" javascript & templating methods, to "Backend" methods such as building a custom module and overriding services. This session will demonstrate how to implement each one outlining their individual pros and cons, proving that no matter your skill sets you can make Drupal 8 do what you want.
No other CMS offers more flexibility then Drupal. If you need to implement a piece of functionality or change a piece of data, there are a million different ways you can go about it. However, this flexibility can also be daunting and frustrating. How do you know if you are going about your changes the “right" way? The truth of the matter is that there is no “right" way - just the “right for me” way. Any method you choose will come with it’s own sets of drawbacks and benefits. In this session we will demonstrate the flexibility of Drupal by going over 8 different ways in Drupal 8 that data can be manipulated. From non-technical methods, "frontend" javascript & templating methods, to "Backend" methods such as building a custom module. This session will demonstrate how to implement each one and outline their individual pros and cons.
Badcamp 2015 - R.E.A.D: Four Steps for Selecting The Right ModulesMichael Miles
One of the most crucial and important steps in building any Drupal project is how to determine which modules to use. When you are reviewing your functionality needs you may ask yourself:
- Where and how can I find the modules I need?
- Will this module I found solve my functionality needs?
- Will I need to patch this module?
- Should I just write my own custom module?
To quickly and correctly answer these questions, there are four simple steps you should follow. It's as simple as learning how to R.E.A.D.
This session goes over the four steps of R.E.A.D, which can help you to quickly and correctly identify which module fits your functionality needs, if you should patch a contrib module or if you should write your own custom module.
This session will use real world examples of using the steps of R.E.A.D to make module decisions. We will also cover the basics and best practices of writing patches and custom modules and how to contribute them back to the Drupal community.
This session is geared towards developer, site builders and functionality decision makers who consider themselves new to Drupal. This session can also prove to be beneficial to experienced drupalists who want to validate/improve habits they have developed.
No other CMS offers more flexibility then Drupal. If you need to implement a piece of functionality or change a piece of data, there are a million different ways you can go about it. However, this flexibility can also be daunting and frustrating. How do you know if you are going about your changes the “right" way?
The truth of the matter is that there is no “right" way - just the “right for me” way. Any method you choose will come with it’s own sets of drawbacks and benefits.
In this session we will demonstrate the flexibility of Drupal by going over 9 different ways (across Drupal 7 and Drupal 8) that data can be manipulated. From a backend only solution to a front-end only solution, a “Drupal friendly” way to a “hacky” way, using a contrib module to writing a custom module. This session will demonstrate how to implement each one and outline their individual pros and cons.
No other CMS offers more flexibility then Drupal. If you need to implement a piece of functionality or change a piece of data, there are a million different ways you can go about it. However, this flexibility can also be daunting and frustrating. How do you know if you are going about your changes the “right way”?
The truth of the matter is that there is no “right way” - just the “right for me” way. Any method you choose will come with it’s own sets of drawbacks and benefits.
One of the most common elements manipulated in Drupal are menu items. Changing destinations, titles, styling, display and order, there are many ways a menu item may be altered and many ways to going about doing so.
In this session we will demonstrate the flexibility of Drupal by going over 9 different ways (across Drupal 7 and Drupal 8) that a menu item could be manipulated. From a backend only solution to a front-end only solution, a “Drupal friendly” way to a “hacky” way, using a contrib module to writing a custom module. This session will demonstrate how to implement each one and outline their individual pros and cons.
Flcamp2015 - R.E.A.D: Four steps for selecting the right modulesMichael Miles
One of the most crucial and important steps in building any Drupal project is determing which modules to use. When you are reviewing your functionality needs you may ask yourself:
Where and how can I find the modules I need?
Will this module I found solve my functionality needs?
Will I need to patch this module?
Should I just write my own custom module?
To quickly and correctly answer these questions, there are four simple steps you should follow. It's as simple as learning how to R.E.A.D.
This session goes over the four steps of R.E.A.D, which can help you to quickly and correctly identify which module fits your functionality needs, if you should patch a contrib module or if you should write your own custom module.
This session will use real world examples of using the steps of R.E.A.D to make module decisions. We will also cover the basics and best practices of writing patches and custom modules and how to contribute them back to the Drupal community.
This session is geared towrds developer, site builders and functionality decision makers who consider themselves new to Drupal. This session can also prove to be beneficial to experienced drupalists who want to validate/improve habits they have developed.
R.E.A.D: Four steps for selecting the right modules Midcamp 2015Michael Miles
One of the most crucial and important steps in building any Drupal project is determing which modules to use. When you are reviewing your functionality needs you may ask yourself:
Where and how can I find the modules I need?
Will this module I found solve my functionality needs?
Will I need to patch this module?
Should I just write my own custom module?
To quickly and correctly answer these questions, there are four simple steps you should follow. It's as simple as learning how to R.E.A.D.
This session goes over the four steps of R.E.A.D, which can help you to quickly and correctly identify which module fits your functionality needs, if you should patch a contrib module or if you should write your own custom module.
This session will use real world examples of using the steps of R.E.A.D to make module decisions. We will also cover the basics and best practices of writing patches and custom modules and how to contribute them back to the Drupal community.
This session is geared towrds developer, site builders and functionality decision makers who consider themselves new to Drupal. This session can also prove to be beneficial to experienced drupalists who want to validate/improve habits they have developed.
How to R.E.A.D: Steps for how to select the correct module @NEWDCamp 2014Michael Miles
This document outlines the R.E.A.D. method for determining whether to use an existing Drupal module, patch a module, or create a custom module. The steps are: Research what exists, Evaluate options, Analyze functionality gaps, and Determine the amount of required changes. Two examples are provided where an exif module is patched and a scheduler module is customized. The guidelines emphasize researching existing solutions, evaluating options like community support, analyzing missing functionality, and only developing custom modules for features other sites could use.
To Patch or Custom: How to decide when to patch a contrib module or go custom...Michael Miles
To use a contrib (community) module, patch a contrib module or write a custom module, that is the question.
With over 25,000 community contributed modules available for download it is rare to find one that does not offer the functionality you are looking for. However, when you cannot find a module that fits your needs you are then faced with a choice. Do you patch an existing contrib module? Or write a custom one?
To figure out the answer to the answer you just need to remember to R.E.A.D.
In this session we will go over the four steps of R.E.A.D that help you decide which path you should follow and how you can quickly and correctly identify if you should patch a contrib module or write your own custom module. We will use some real world examples to demo straight how these steps were utilized to make the correct decision.
We will also talk about the basics and best practices of writing and contributing a patch, and the best practices to follow if you decide to pursue writing a custom module and how to contribute it back to the Drupal community.
This session is geared to developer, site builders and functionality decision makers who consider themselves new to Drupal. This session can also prove to be beneficial to experienced drupalists who want validation on habits they have developed over time.
Gen Z and the marketplaces - let's translate their needsLaura Szabó
The product workshop focused on exploring the requirements of Generation Z in relation to marketplace dynamics. We delved into their specific needs, examined the specifics in their shopping preferences, and analyzed their preferred methods for accessing information and making purchases within a marketplace. Through the study of real-life cases , we tried to gain valuable insights into enhancing the marketplace experience for Generation Z.
The workshop was held on the DMA Conference in Vienna June 2024.
Discover the benefits of outsourcing SEO to Indiadavidjhones387
"Discover the benefits of outsourcing SEO to India! From cost-effective services and expert professionals to round-the-clock work advantages, learn how your business can achieve digital success with Indian SEO solutions.
HijackLoader Evolution: Interactive Process HollowingDonato Onofri
CrowdStrike researchers have identified a HijackLoader (aka IDAT Loader) sample that employs sophisticated evasion techniques to enhance the complexity of the threat. HijackLoader, an increasingly popular tool among adversaries for deploying additional payloads and tooling, continues to evolve as its developers experiment and enhance its capabilities.
In their analysis of a recent HijackLoader sample, CrowdStrike researchers discovered new techniques designed to increase the defense evasion capabilities of the loader. The malware developer used a standard process hollowing technique coupled with an additional trigger that was activated by the parent process writing to a pipe. This new approach, called "Interactive Process Hollowing", has the potential to make defense evasion stealthier.
2. Goals of this Session
Explain what AJAX callback commands are
Demonstrate how to use AJAX callback commands
Outline how to create AJAX callback commands
6. From a High Level
The response of AJAX request
PHP code to instruct JavaScript functions
A JavaScript function attached to an object
Defined by Drupal core or modules
17 AJAX callback commands in Drupal 7
7. Example: The "Remove" Command
Using the "examples" module (available on Drupal.org), showing using the 'remove' AJAX Callback
command. The checkbox is checked, which makes an AJAX request, which returns the command to
remove the element with the sample text.
8. On the Client Side [D7]
A function on the 'Drupal.ajax.prototype.commands' object
Receives 'ajax', 'response' and 'status' arguments
A wrapper for additional javascript
// Provide a series of commands that the server can request the client perform.
Drupal.ajax.prototype.commands = {
//...
/**
* Command to remove a chunk from the page.
*/
remove: function (ajax, response, status) {
var settings = response.settings || ajax.settings || Drupal.settings;
Drupal.detachBehaviors($(response.selector), settings);
$(response.selector).remove();
},
//...
}
misc/ajax.js
9. On the Server Side [D7]
A PHP function which returns an associative array
Array must have an element with key of 'command'
The value is the name of a JavaScript function
Additional array elements set as response data
/**
* Creates a Drupal Ajax 'remove' command.
*/
function ajax_command_remove($selector) {
return array(
'command' => 'remove',
'selector' => $selector,
);
}
includes/ajax.inc
12. Example Scenario
As a user
When I navigate to the 'my-messages' page
Then I see a list of my unread messages
And I see a list of my read messages
When I click on an unread message
Then the full messaged is retrieved from the server
And I see the content of my message
And the message is removed from the unread messages list
And the message is added to the read messages list
14. To Use Commands...
1. Include Drupal AJAX JavaScript library
2. Attach AJAX to page elements
3. Define a callback path and function
Returns a render array of commands [D7]
15. 1. Include Drupal AJAX library
// Render a page of messages.
function mymodule_messages_page() {
// Include AJAX library.
drupal_add_library('system', 'drupal.ajax');
// Create inital page content.
$content = theme_item_list(array(
'title' => t('Unread Messages'),
'type' => 'ul',
'attributes' => array( 'id' => 'unread-msgs'),
'items' => mymodule_messages_list(mymodule_get_unread_messages()),
));
$content .= '<div id="current-msg"><h2></h2><p></p></div>';
$content .= theme_item_list(array(
'title' => t('Read Messages'),
'type' => 'ul',
'attributes' => array('id' => 'read-msgs'),
'items' => mymodule_messages_list(mymodule_get_read_messages(), FALSE),
));
return $content;
}
mymodule/mymodule.module
Function to build a page of messages. On line #4, using the drupal_add_librry() function to include the
AJAX library on the page.
16. 2. Attach AJAX to page elements
// Return array of message titles for use in a list.
function mymodule_messages_list($messages, $display_link = TRUE) {
$list_items = array();
foreach ($messages as $mid => $msg) {
// Build link to AJAX callback to load message.
$link = l($msg->subject, 'read-message-callback/nojs/' . $mid, array(
// Add class to link so Drupal knows to use AJAX.
'attributes' => array('class' => array('use-ajax')),
));
// Create list item for message.
$list_items[] = array(
'id' => 'msg-' . $mid,
// Set data to read message link or just message subject.
'data' => $display_link ? $link : $msg->subject,
);
}
return $list_items;
}
mymodule/mymodule.module
Function to build a list of messages. On line #6, creating a link element which links to our callback path.
On line #8, adding the class 'useajax' so AJAX framework knows to serve link with an AJAX request.
17. 3.a Define a callback path
// Implements hook_menu().
function mymodule_menu() {
$items = array();
//.. Other menu items.
// None JS callback, for graceful degredation.
$items['read-message-callback/nojs/%'] = array(
'title' => 'AJAX Callback to Read Message',
'access arguments' => array('access content'),
'page callback' => 'mymodule_read_message_callback',
'page arguments' => array(1,2),
'type' => MENU_CALLBACK,
);
// Create AJAX callback. Add ajax_delivery callback.
$items['read-message-callback/ajax/%'] = array(
'delivery callback' => 'ajax_deliver',
) + $items['read-message-callback/nojs/%'];
return $items;
}
mymodule/mymodule.module
Creating two menu items for callback functions. The first is for handling graceful degredation when
reached outside an AJAX Request. The second is the AJAX callback, which add a delivery callback of
"ajax_callback" so Drupal know to return an AJAX Response object.
18. 3.b Return array of commands using a render array [D7]
// AJAX Callback to read a message.
function mymodule_read_message_callback($method, $mid) {
$message = mymodule_load_message($mid);
// @TODO: Graceful degredation if not from ajax method or if no message.
$commands = array(
// Replace content of current message subject.
ajax_command_html('#current-msg h2', $message->subject),
// Replace content of current message body.
ajax_command_html('#current-msg p', $message->content),
// Remove message from unread list.
ajax_command_remove('#msg-' . $mid),
// Add message to read list
ajax_command_append('#read-msgs', '<li>' . $message->subject . '</li>'),
);
// Return an AJAX render array.
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}
mymodule/mymodule.module
Lines #5 thru #14, building an array of Core AJAX Callback commands. Each mapps to a javascript
function. Line #16 building a render array of type 'ajax'. Drupal will package into JSON and send back to
the client.
21. To Create a Command...
1. Add a function to the Drupal ajax command JavaScript object
2. Write PHP code that returns an associative array.
Must have an element with key of 'command'
Value is name of the JavaScript function
Additional elements for response data
23. A Custom Command in Drupal 7
1. Add a function to 'Drupal.ajax.prototype.commands'
2. Define a PHP function to return an array
24. 1. Add a function to 'Drupal.ajax.prototype.commands'
(function($, Drupal) {
// Add new command for reading a message.
Drupal.ajax.prototype.commands.readMessage = function(ajax, response, status){
// Place content in current-msg div.
$('#current-msg h2').html(response.subject);
$('#current-msg p').html(response.content);
// Remove from unread list.
$('#msg-' + response.mid).remove();
// Add message to read list.
$('#read-msgs').append('<li>' + response.subject + '</li>');
}
})(jQuery, Drupal);
mymodule/js/commands.js
Attach a new 'readMessage' command to the Drupal AJAX Commands JavaScript object. Function takes
in the 3 arguments "ajax", "response" & "status". Wraps jQuery functions to display a message on the
page.
25. 2. Define a PHP function to return an associative array
/**
* AJAX command to read a message.
*/
function mymodule_command_read_message($message) {
return array(
'command' => 'readMessage',
'mid' => $message->mid,
'subject' => $message->subject,
'content' => $message->content,
);
}
mymodule/mymodule.module
PHP function that mapps to the new JavaScript 'readMessage' array. Returns an associative array, with
an element that has a key of 'command' and value of the JavaScript function name 'readMessage'. Then
additional elements to be sent as request data.
26. Using a custom command...
1. Tell Drupal to include custom JavaScript
2. Return custom command in callback function
28. Using a Custom Command in Drupal 7
1. Use drupal_add_js() to include custom JavaScript on page
2. Add command to render array returned by callback
29. 1. Use drupal_add_js() to include custom JavaScript on page
// Render a page of my messages
function mymodule_messages_page() {
// Include AJAX library.
drupal_add_library('system', 'drupal.ajax');
// Include custom JavaScript.
drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/commands.js');
// .. Build $content.
return $content;
}
mymodule/mymodule.module
The example function for creating the messages page. In addition to adding the Drupal AJAX library on
line #4 also using drupal_add_js() to include custom javascript file on line #6.
30. 2. Add command to render array returned by callback
// AJAX Callback to read a message.
function mymodule_read_message_callback($method, $mid) {
$message = mymodule_load_message($mid);
// @TODO: Graceful degredation if not from ajax method or if no message.
$commands = array(
// Call the readMessage javascript function.
mymodule_command_read_message($message),
);
// Return an AJAX render array.
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}
mymodule/mymodule.module
The example callback function that returns an AJAX render array. Commands array on lines #5 thru #8,
only returns a single command. The new custom command that was created.
33. Changes to AJAX Commands
22 AJAX callback commands in Drupal 8
JavaScript attatches to 'Drupal.AjaxCommands.prototype' object
A PHP object that implements CommandInterface
Must implement 'render' method
34. Example: The "Remove" Command
Using the "examples" module (available on Drupal.org), showing using the 'remove' AJAX Callback
command. The checkbox is checked, which makes an AJAX request, which returns the command to
remove the element with the sample text.
35. A function on the 'Drupal.AjaxCommands.prototype' object
/**
* Provide a series of commands that the client will perform.
*/
Drupal.AjaxCommands.prototype = {
//...
/**
* Command to remove a chunk from the page.
*/
remove: function (ajax, response, status) {
var settings = response.settings || ajax.settings || drupalSettings;
$(response.selector).each(function () {
Drupal.detachBehaviors(this, settings);
}).remove();
},
//...
}
misc/ajax.js
36. An object that implements CommandInterface
Must implement 'render' method
namespace DrupalCoreAjax;
use DrupalCoreAjaxCommandInterface;
// AJAX command for calling the jQuery remove() method.
class RemoveCommand Implements CommandInterface {
protected $selector;
// Constructs a RemoveCommand object.
public function __construct($selector) {
$this->selector = $selector;
}
// Implements DrupalCoreAjaxCommandInterface:render().
public function render() {
return array(
'command' => 'remove',
'selector' => $this->selector,
);
}
}
core/lib/Drupal/Core/Ajax/RemoveCommand.php
37. To Use Commands in Drupal 8
1. Include Drupal AJAX JavaScript library
Must attach to a render array
2. Attach AJAX to page elements
3. Define a callback path and function
Returns an AjaxResponse object
39. Attach library to a render array
namespace DrupalmymoduleController;
use DrupalCoreControllerControllerBase;
class MyModuleController extends ControllerBase {
// ...
// Render a page of my messages
public function messagesPage() {
// ... build $content
// Create render array.
$page[] = array(
'#type' => 'markup',
'#markup' => $content,
);
// Attach JavaScript library.
$page['#attached']['library'][] = 'core/drupal.ajax';
return $page;
}
// ...
}
mymodule/src/Controller/MyModuleController.php
Function for building messages page is now using a render array. to the '#attached', 'library' array of
that render array, declaring the drupal.ajax library to be included.
40. Callback returns commands using an AJAXResponse() [D8]
namespace DrupalmymoduleController;
use DrupalCoreControllerControllerBase;
class MyModuleController extends ControllerBase {
// ...
// AJAX Callback to read a message.
public function readMessageCallback($method, $mid) {
$msg = mymodule_load_message($mid);
// Create AJAX Response object.
$response = new AjaxResponse();
// Replace content of current message subject.
$response->addCommand(new HtmlCommand('#current-msg h2', $msg->subject));
// Replace content of current message body.
$response->addCommand(new HtmlCommand('#current-msg p', $msg->content));
// Remove message from unread list.
$response->addCommand(new RemoveCommand('#msg-' . $mid));
// Add message to read list.
$item = '<li>' . $msg->subject . '</li>';
$response->addCommand(new AppendCommand('#read-msgs', $item));
// Return ajax response.
return $response;
}
mymodule/src/Controller/MyModuleController.php
Returning an AjaxResponse object instead of a render array like in Drupal 7. AjaxResponse has an
'addCommand' method, which takes the argument of a command object.
41. Custom Commands in Drupal 8
1. Add function to 'Drupal.AjaxCommands.prototype'
2. Define a command object that implements CommandInterface
42. 1. Add function to 'Drupal.AjaxCommands.prototype'
(function($, Drupal) {
/**
* Add new command for reading a message.
*/
Drupal.AjaxCommands.prototype.readMessage = function(ajax, response, status){
// Place content in current-msg div.
$('#current-msg h2').html(response.subject);
$('#current-msg p').html(response.content);
// Remove from unread list.
$('#msg-' + response.mid).remove();
// Add message to read list.
$('#read-msgs').append('<li>' + response.subject + '</li>');
}
})(jQuery, Drupal);
mymodule/js/commands.js
Adding the custom 'readMessage' function to the Drupal 8 JavaScript AJAX Commands object. Still takes
the same three arguments as in Drupal 7.
43. 2. Define command object that implements CommandInterface
namespace DrupalmymoduleAjax;
use DrupalCoreAjaxCommandInterface;
class ReadMessageCommand implements CommandInterface {
protected $message;
// Constructs a ReadMessageCommand object.
public function __construct($message) {
$this->message = $message;
}
// Implements DrupalCoreAjaxCommandInterface:render().
public function render() {
return array(
'command' => 'readMessage',
'mid' => $this->message->mid,
'subject' => $this->message->subject,
'content' => $this->message->content,
);
}
}
mymodule/src/Ajax/ReadMessageCommand.php
Creating a Command object which implements the CommandInterface. Must declare a 'render' method,
which will return an associative array. This associative array must have an element with the key of
'command' and value of the JavaScript function to run.
44. Using a Custom Command in Drupal 8
1. Tell Drupal about custom JavaScript library
2. Attach library to a render array
3. Add command to AjaxResponse object in callback
45. 1. Tell Drupal about custom JavaScript library
mymodule.commands:
version: VERSION
js:
js/commands.js: {}
dependencies:
- core/drupal.ajax
mymodule/mymodule.libraries.yml
Must tell Drupal about custom library with a libraries.yml file. Provide an Asset library name, lists all the
js files needed, and any dependencies on other libraries.
46. 2. Attach library to a render array
namespace DrupalmymoduleController;
use DrupalCoreControllerControllerBase;
class MyModuleController extends ControllerBase {
// ...
// Render a page of my messages
public function messagesPage() {
// .. build $content
// Create render array.
$page[] = array(
'#type' => 'markup',
'#markup' => $content,
);
// Attach JavaScript library.
$page['#attached']['library'][] = 'mymodule/mymodule.commands';
return $page;
}
// ...
}
mymodule/mymodule.module
Function for building messages page is now using a render array. to the '#attached', 'library' array of
that render array, including the custom library. No longer including the AJAX library, as Drupal will know
to include it from the libraries.yml file.
47. 3. Add command to AjaxResponse object in callback
namespace DrupalmymoduleController;
use DrupalCoreControllerControllerBase;
class MyModuleController extends ControllerBase {
// ...
// AJAX Callback to read a message.
public function readMessageCallback($method, $mid) {
$msg = mymodule_load_message($mid);
// Create AJAX Response object.
$response = new AjaxResponse();
// Call the readMessage javascript function.
$response->addCommand( new ReadMessageCommand($msg));
);
// Return ajax response.
return $response;
}
//...
}
mymodule/mymodule.module
Returning an AjaxResponse object instead of adding the core commands, just adding the new custom
command using the 'addCommand' method.
50. AJAX Callback Commands Are...
Returned by all AJAX Framework requests
PHP abstraction for JavaScript functions
Defined by core and modules
51. To Use AJAX Callback Commands...
Include Drupal AJAX JavaScript library
Attach AJAX to page elements
Have server side callback return array of commands
52. To Create AJAX Callback Commands...
Add function to Drupal ajax command JavaScript object.
Write PHP code to return associative array with a 'command' key
53. To Use Custom AJAX Callback
Commands...
Include custom JavaScript
Include custom command in callback function