Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Drupal 8 Custom Plugin Types
Sep 14, 2015 @ 16:08:06

The SitePoint PHP blog has posted an overview from Daniel Sipos covering custom plugin types in Drupal 8 and how you can combine them (custom forms) with node entities.

In this article series of two parts, we will use this system to build a feature that allows the use of custom forms together with node entities. After we’re done, we’ll be able to do the following: configure node bundles to use one of multiple form types to be displayed together with the node display and easily define new form types by extending from a sensible base class. [...] We will get started by creating our custom plugin type. T

He starts with the plugin manager, showing you how to create a custom ReusableFormsManager in the module to set up the manager and add it to the system. He then sets up the plugin interface the manager is expecting to find. This piece defines methods to get the name of the plugin and to build the form. He then creates a simple ReusableForm annotation class and builds out the plugin base. This base class includes a form builder object used to build and output the custom form. Finally he gets into building the form and its matching interface. It's a simple "Contact Us" kind of form that outputs three fields (first name, last name, email) and a "Submit" button.

tagged: drupal8 custom plugin type tutorial form contactus

Link: http://www.sitepoint.com/drupal-8-custom-plugin-types/

Web Development Blog:
Add a MailChimp subscribe feature to your contact form
May 05, 2015 @ 17:14:13

The Web Development Blog has a tutorial posted showing how to add a Mailchimp "subscribe" feature to your current contact forms. They make use of the MailChimp API wrapper library to make the calls back to the service and subscribe the user at their request.

MailChimp is a great email marketing service provider with an easy to use control panel and features like: campaign management (RSS-driven, A/B Split, Plain-text and regular), statistics, auto-responder and a complete set of list management tools. They offer different ways to place a subscriber form on your website or blog. If you to like add the MailChimp subscribe feature to your existing contact form you need to add some custom code.

They start with a few things you'll need to do to prepare for the connection including the setup of an API key to make the request. He provides a simple "Contact Us" form for reference and the code needed on submit to validate the input and make the subscription call to the API with the email the user provided. He also includes a bit of response handling.

tagged: mailchimp tutorial subscribe contactus form api request

Link: http://www.web-development-blog.com/archives/mailchimp-subscribe-contact-form/


Trending Topics: