<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4530028210150333092</id><updated>2026-09-20T17:10:39.306+05:30</updated><category term="Drupal 7"/><category term="Drupal 8"/><category term="drupal tips"/><category term="blocking user"/><title type='text'>Drupal Solutions for You</title><subtitle type='html'>At &quot;Drupal Experts&quot; we have tried to cover wide range of experience and solutions from various professionals and try to keep good knowledge of online environment. We have taken information from various websites and professionals so it can be concluded into one platform. We are updating our blog so please be patient.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>226</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-1847996890609055828</id><published>2016-02-17T13:20:00.000+05:30</published><updated>2016-02-17T13:20:06.241+05:30</updated><title type='text'> Arbitrary &quot;OR&quot; SQL Queries</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I was working on a Drupal migration project today using the &lt;a href=&quot;http://www.drupal.org/project/migrate&quot;&gt;Migrate&lt;/a&gt; module where I needed to import only select user roles from the source (Drupal 6) database.&lt;br /&gt;

The Migrate module allows for a custom query to select only the user 
roles that need to be imported. In my case, the two roles I wanted to 
import had role IDs of 4 and 6. So, how do I write a query using the &lt;a href=&quot;http://drupal.org/developing/api/database&quot;&gt;Drupal Database API&lt;/a&gt; to do this? Turns out there&#39;s a pretty elegant answer. Rather than writing something like:&lt;br /&gt;

&lt;code&gt;SELECT * FROM role r WHERE rid=4 OR rid=6;&lt;/code&gt;&lt;br /&gt;

The &lt;em&gt;proper&lt;/em&gt; way of writing the select query is:&lt;br /&gt;

&lt;code&gt;$query = parent::query();&lt;br /&gt;
$ored = db_or();&lt;br /&gt;
$ored&lt;br /&gt;
  -&amp;gt;condition(&#39;rid&#39;, 4)&lt;br /&gt;
  -&amp;gt;condition(&#39;rid&#39;, 6);&lt;br /&gt;
$query-&amp;gt;condition($ored);&lt;/code&gt;&lt;br /&gt;

Note the elegant &quot;db_or()&quot; function that returns a DatabaseCondition 
object. Add the two conditions to this object, and they&#39;re automagically
 &quot;or&quot;ed.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/1847996890609055828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/arbitrary-or-sql-queries.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1847996890609055828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1847996890609055828'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/arbitrary-or-sql-queries.html' title=' Arbitrary &quot;OR&quot; SQL Queries'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-6660644478958869881</id><published>2016-02-17T13:19:00.005+05:30</published><updated>2016-02-17T13:19:41.987+05:30</updated><title type='text'> Drush Lock: Freeze the version of a Module during &#39;drush up&#39;</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/543/body/und/full&quot;&gt;
Every
 so often I will find myself needing to update lots of Drupal modules 
but not one in particular. Perhaps I have patched the module, or perhaps
 there is a new version of the theme that I know will break my site 
layout.&lt;br /&gt;

&lt;a href=&quot;http://drush.ws/&quot;&gt;Drush can save you from this dilemma&lt;/a&gt;, as of version 4.x - yes, it&#39;s true!&lt;br /&gt;

Just use:&lt;br /&gt;

&lt;code&gt;drush up --lock=omega&lt;/code&gt;
&lt;br /&gt;
Assuming Omega is the project that needs to keep the same version number. Omega will not be updated until you reverse the lock.&lt;br /&gt;

&lt;code&gt;drush up --unlock=omega&lt;/code&gt;
&lt;br /&gt;
You can also just:&lt;br /&gt;

&lt;code&gt;drush up omega&lt;/code&gt;
&lt;br /&gt;
If you want to.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/6660644478958869881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drush-lock-freeze-version-of-module.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/6660644478958869881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/6660644478958869881'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drush-lock-freeze-version-of-module.html' title=' Drush Lock: Freeze the version of a Module during &#39;drush up&#39;'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-7081434458199274145</id><published>2016-02-17T13:19:00.002+05:30</published><updated>2016-02-17T13:19:20.390+05:30</updated><title type='text'> Where did the catpath and termpath tokens go in pathauto?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/536/body/und/full&quot;&gt;
In the old days of web design, we had to put all of our files in folders, so having a path like &lt;code&gt;example.com/category/sweaters/cashmere/winter-special.html&lt;/code&gt; was really common. You could also remove any part of the path and be sure you would get an index page, such as &lt;code&gt;example.com/category/sweaters/index.html&lt;/code&gt;.&lt;br /&gt;

In a front-controller CMS like Drupal, all the paths are arbitrary, 
so a hierarchical folder structure has to be faked with URL Aliases. 
Luckily the community maintains two modules to round out this 
functionality in &lt;a href=&quot;http://drupal.org/project/token&quot;&gt;Token&lt;/a&gt; and &lt;a href=&quot;http://drupal.org/project/pathauto&quot;&gt;Pathauto&lt;/a&gt;, along with the excellent &lt;a href=&quot;http://drupal.org/project/entity&quot;&gt;Entity API&lt;/a&gt;
 module and the Entity Tokens that comes bundled with it. However, 
Tokens were completely (and necessarily) rewritten from Drupal 6 to 
Drupal 7, and some of the cool things you could do with pathauto to 
emulate old-school folder structures became less transparent.&lt;br /&gt;

After a few minutes of searching the issue queue, lo and behold, &lt;a href=&quot;http://drupal.org/node/860082#comment-4649530&quot;&gt;a replacement for Drupal 6&#39;s &quot;catpath&quot; token&lt;/a&gt;:&lt;br /&gt;

&lt;code&gt;category/[term:parent:url:path]/[term:name]&lt;/code&gt;&lt;br /&gt;

If your taxonomy is properly arranged in a hierarchy, this acts as a 
recursive loop to generate the terms that should be properly nested. 
That means that &lt;code style=&quot;color: #333333; font-size: 12px; font-style: inherit;&quot;&gt;example.com/sweaters/cashmere/&lt;/code&gt; should show you all the nodes tagged with cashmere, and likewise for &lt;code style=&quot;color: #333333; font-size: 12px; font-style: inherit;&quot;&gt;example.com/sweaters&lt;/code&gt;.&lt;br /&gt;

OK, but what about the nodes? No problem there either:&lt;br /&gt;

&lt;code&gt;category/[node:category:url:path]/[node:title]&lt;/code&gt;&lt;br /&gt;

Again, this creates a recursive loop where the path of the node 
depends on the path of the term, and that depends on its parent terms. 
(if you&#39;d like to add .html to the end, that is fine too).&lt;br /&gt;

&lt;strong&gt;The pattern is different depending on the name of your vocabulary. &lt;/strong&gt;In a site upgraded from Drupal 6, the word &quot;category&quot; will be replaced by a vocabulary ID.&lt;br /&gt;

&lt;code&gt;category/[node:taxonomy-vocabulary-2:url:path]/[node:title]&lt;/code&gt;&lt;br /&gt;

if your field has multiple values you may need to address the term with a delta:&lt;br /&gt;

&lt;code&gt;category/[node:taxonomy-vocabulary-2:0:url:path]/[node:title]&lt;/code&gt;&lt;br /&gt;

Last but not least, if you want absolute control over which term is used you may also want to check out Dave Ried&#39;s &lt;a href=&quot;http://drupal.org/project/taxonomy_entity_index&quot;&gt;Taxonomy Entity Index&lt;/a&gt; module.&lt;br /&gt;

BTW I never used to like putting &quot;category&quot; in front of my URL 
aliases, but there is a good round up of some security holes you may 
open by not putting some static text in front of pathauto patterns: &lt;a href=&quot;http://drupal.org/node/73232&quot;&gt;Pathauto Patterns that can be Dangerous&lt;/a&gt;&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/7081434458199274145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/where-did-catpath-and-termpath-tokens.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/7081434458199274145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/7081434458199274145'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/where-did-catpath-and-termpath-tokens.html' title=' Where did the catpath and termpath tokens go in pathauto?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-529469697482113987</id><published>2016-02-17T13:18:00.008+05:30</published><updated>2016-02-17T13:18:59.967+05:30</updated><title type='text'> Drupal Text Formats and Content for Test Nodes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/513/body/und/full&quot;&gt;
When
 building a Drupal-based website or theme, you will invariably create 
some test nodes of a content type that has at least one text area field.
 You should then add some example text, to see how those fields will 
look on the website. But beyond those nodes focused on styling, you may 
find it necessary or advisable to create a large number of additional 
test nodes of that content type. When you begin this process, you may 
wonder whether it would be best to add placeholder text (such as the 
venerable &quot;Lorem ipsum&quot;) or leave those fields empty. Also, are there 
any ramifications of choosing one text format or another?&lt;br /&gt;

If a text area contains no content, then no text format is associated
 with that particular node&#39;s text area, and changes to the text format 
setting (made through the user interface) are not retained. However, if 
placeholder text is added to the field, then users who do not have 
permission for the chosen text format, will naturally not be able to 
edit the text. Consequently, you or someone else would be forced to 
change the text formats on all of the problematic nodes — manually or 
with database commands. On the other hand, if you leave those text areas
 empty, then those users can add whatever text they want, and specify 
any of the text formats for which they have permissions.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/529469697482113987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drupal-text-formats-and-content-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/529469697482113987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/529469697482113987'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drupal-text-formats-and-content-for.html' title=' Drupal Text Formats and Content for Test Nodes'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-1332161580994020566</id><published>2016-02-17T13:18:00.005+05:30</published><updated>2016-02-17T13:18:39.523+05:30</updated><title type='text'> Hardcoding the Temporary Directory Path</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/484/body/und/full&quot;&gt;
When
 working on a local copy of a site that also has a production, stage, 
and/or development environment on another server, it can be handy to 
hard-code the &quot;Temporary directory&quot; file path as found on 
admin/config/media/file-system&lt;br /&gt;

The reason is so that when you restore a copy of the database from 
another server to your local machine, you don&#39;t have to redo the 
temporary directory setting. For example, on most sites we build, we set
 up a shared development environment on &lt;a href=&quot;http://webenabled.com/&quot;&gt;WebEnabled&lt;/a&gt;
 (shameless plug) where multiple developers are often configuring 
different parts of the site. When I want to work locally, I like to have
 an up-to-date copy of the database. I use the &lt;a href=&quot;http://www.drupal.org/project/backup_migrate&quot;&gt;Backup and Migrate module&lt;/a&gt; or &lt;a href=&quot;http://www.drupal.org/project/drush&quot;&gt;Drush&lt;/a&gt; to copy the database from the shared development environment to my local machine. &lt;br /&gt;

To hard-code the temporary directory path of your local site, simply 
add the following line to the bottom of your local settings.php file:&lt;br /&gt;

&lt;code&gt;$conf[&#39;file_temporary_path&#39;] = &#39;/tmp&#39;;&lt;/code&gt;&lt;br /&gt;

Where &quot;/tmp&quot; is the your local temporary directory path.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/1332161580994020566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/hardcoding-temporary-directory-path.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1332161580994020566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1332161580994020566'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/hardcoding-temporary-directory-path.html' title=' Hardcoding the Temporary Directory Path'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-2873137471494435372</id><published>2016-02-17T13:18:00.002+05:30</published><updated>2016-02-17T13:18:24.160+05:30</updated><title type='text'> Get notified of new comments with Rules</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/480/body/und/full&quot;&gt;
I know there are modules to handle this, but Rules can do it all:&lt;br /&gt;

If you visit admin &amp;gt; config &amp;gt; workflow &amp;gt; rules on your site, start a new Rule like so:&lt;br /&gt;

&lt;em&gt;
&lt;/em&gt;
&lt;em&gt;&lt;strong&gt;Name:&lt;/strong&gt; &quot;Notify of new comment&quot;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;
&lt;strong&gt;React on Event:&lt;/strong&gt; After saving a new comment&lt;br /&gt;

&lt;/em&gt;
I normally tag the rule with the name of the site, like &quot;drupaleasy&quot;.&lt;br /&gt;

Next add a new Condition:&lt;br /&gt;

&lt;em&gt;
&lt;/em&gt;
&lt;em&gt;&lt;strong&gt;Select the condition to add:&lt;/strong&gt; User &amp;gt; User has role(s)&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;
&lt;/em&gt;
&lt;strong&gt;User &amp;gt; Data selector:&lt;/strong&gt; &quot;comment:author&quot;&lt;br /&gt;

&lt;strong&gt;Roles &amp;gt; Value:&lt;/strong&gt; administrator&lt;br /&gt;

check the &lt;strong&gt;Negate&lt;/strong&gt; box&lt;br /&gt;



This looks at the role of the person who just left the new 
comment. If he or she is an administrator, this rule wil not fire. 
Chances are, if an admin left a comment, you don&#39;t want to know about 
it. On most sites I don&#39;t add this condition, but on a single-user site 
like a blog, this rule will make a lot of sense.&lt;br /&gt;

Next add an Action - this is what you want to happen when a new comment is created (that was not added by the administrator):&lt;br /&gt;

&lt;em&gt;
&lt;/em&gt;
&lt;em&gt;&lt;strong&gt;System:&lt;/strong&gt; Send mail&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;
&lt;/em&gt;
&lt;strong&gt;To &amp;gt; Value:&lt;/strong&gt; &quot;[site:mail]&quot;&lt;br /&gt;

&lt;strong&gt;Subject &amp;gt; Value: &lt;/strong&gt;&quot;New comment on [comment:node]&quot;&lt;br /&gt;

&lt;strong&gt;Message &amp;gt; Value:&lt;/strong&gt;&lt;br /&gt;


[site:url]admin/content/comment/approval&lt;br /&gt;

[comment:url]&lt;br /&gt;


[comment:title] - [comment:node]&lt;br /&gt;

at [comment:created] by [comment:author]&lt;br /&gt;

[comment:mail] - [comment:homepage]&lt;br /&gt;


[comment:body]&lt;br /&gt;


[comment:edit-url]&lt;br /&gt;

&lt;strong&gt;From &amp;gt; Value:&lt;/strong&gt; &quot;[comment:mail]&quot;&lt;br /&gt;



On my sites, Anonymous comments have to pass approval - we just 
get too much spam otherwise. Luckily, now that we have this rule in 
place, we can think about lifting the approval gate so comments appear 
instantaneously while still helping us cut down on spam.&lt;br /&gt;

Here is an exported version of the rule:&lt;br /&gt;


&lt;pre&gt;{ &quot;rules_notify_of_new_comments&quot; : {
    &quot;LABEL&quot; : &quot;Notify of new Comments&quot;,
    &quot;PLUGIN&quot; : &quot;reaction rule&quot;,
    &quot;TAGS&quot; : [ &quot;drupaleasy&quot; ],
    &quot;REQUIRES&quot; : [ &quot;rules&quot;, &quot;comment&quot; ],
    &quot;ON&quot; : [ &quot;comment_insert&quot; ],
    &quot;IF&quot; : [
      { &quot;NOT user_has_role&quot; : {
          &quot;account&quot; : [ &quot;comment:author&quot; ],
          &quot;roles&quot; : { &quot;value&quot; : { &quot;3&quot; : &quot;3&quot; } }
        }
      }
    ],
    &quot;DO&quot; : [
      { &quot;mail&quot; : {
          &quot;to&quot; : &quot;[site:mail]&quot;,
          &quot;subject&quot; : &quot;New comment on [comment:node:title]&quot;,
          &quot;message&quot; : &quot;[site:url]admin\/content\/comment\/approval\r\n[comment:url]\r\n\r\n[comment:title]\t - [comment:node]\r\nat [comment:created] by [comment:author]\r\n[comment:mail] - [comment:homepage]\r\n\r\n[comment:body]\r\n\r\n[comment:edit-url]&quot;,
          &quot;from&quot; : &quot;[comment:mail]&quot;
        }
      }
    ]
  }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/2873137471494435372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/get-notified-of-new-comments-with-rules.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/2873137471494435372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/2873137471494435372'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/get-notified-of-new-comments-with-rules.html' title=' Get notified of new comments with Rules'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-3546976120691961568</id><published>2016-02-17T13:17:00.006+05:30</published><updated>2016-02-17T13:17:59.869+05:30</updated><title type='text'> Enabling Drupal 7 &#39;www&#39; Redirection on a Local Host</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Drupal 7&#39;s HTTP access file, .htaccess, contains some URL rewriting code
 for redirecting all site visitors to the domain name starting with 
&quot;www.&quot;, in case they try to go to the domain name without the prefix. 
For instance, you might want all visitors to go to &lt;a href=&quot;http://www.example.com/&quot;&gt;www.example.com&lt;/a&gt;, and never example.com, for SEO purposes.&lt;br /&gt;
This is achieved by uncommenting the code on lines 81-82:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;
RewriteCond %{HTTP_HOST} !^www\. [NC]&lt;br /&gt;
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]&lt;/code&gt;&lt;br /&gt;
This works fine when used on a remote server, but not on a local server 
that is not set up to handle the prefix. For instance, if you have a 
local installation of Drupal at &lt;a href=&quot;http://localhost/my_site/&quot;&gt;http://localhost/my_site/&lt;/a&gt;, then the rewrite code will change that into an invalid URL: &lt;a href=&quot;http://www.localhost/my_site/&quot;&gt;http://www.localhost/my_site/&lt;/a&gt;&lt;br /&gt;
This problem can be fixed by adding the following line above the RewriteRule:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;
RewriteCond %{HTTP_HOST} !^localhost$ [NC]&lt;/code&gt;&lt;br /&gt;
Or, more simply, the existing RewriteCond line can be modified:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;
RewriteCond %{HTTP_HOST} !^(www\.|localhost$) [NC]&lt;/code&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/3546976120691961568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/enabling-drupal-7-www-redirection-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/3546976120691961568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/3546976120691961568'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/enabling-drupal-7-www-redirection-on.html' title=' Enabling Drupal 7 &#39;www&#39; Redirection on a Local Host'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-1921564661128159467</id><published>2016-02-17T13:17:00.003+05:30</published><updated>2016-02-17T13:17:43.193+05:30</updated><title type='text'> Filter a view based on empty Imagefield</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/456/body/und/full&quot;&gt;
Turns out there is no filter that asks wether or not an imagefield (or filefield) has a value. I came across this tip on &lt;a href=&quot;http://drupal.org/node/327661&quot;&gt;Drupal.org&lt;/a&gt;. The recommendation was to use a relationship, and then choose &quot;Require this relationship&quot; to act as a filter. Pretty cool.&lt;br /&gt;

So assuming your imagefield is just called &quot;Image&quot;, here is the walkthrough:&lt;br /&gt;

&lt;ol&gt;
&lt;li&gt;Add a new view of type &quot;node&quot;&lt;/li&gt;
&lt;li&gt;Add one or more fields (I assume you want to include the image field) in the normal way&lt;/li&gt;
&lt;li&gt;Click the button next to Relationships to open the dialog for adding relationships&lt;/li&gt;
&lt;li&gt;From the &quot;Content&quot; group, choose your Image field (which will be followed by &quot;fid&quot;)&lt;/li&gt;
&lt;li&gt; Make sure you click the &quot;Require this relationship&quot; box when adding the relationship&lt;/li&gt;
&lt;/ol&gt;
That should be it! &lt;br /&gt;

I don&#39;t know if this changes for Views 3.x and Drupal 7, but this is 
the only way to do this in Drupal 6 and Views 2.x. You&#39;re welcome.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/1921564661128159467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/filter-view-based-on-empty-imagefield.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1921564661128159467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1921564661128159467'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/filter-view-based-on-empty-imagefield.html' title=' Filter a view based on empty Imagefield'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-2949914845755130559</id><published>2016-02-17T13:16:00.002+05:30</published><updated>2016-02-17T13:16:34.004+05:30</updated><title type='text'> I can&#39;t log in to my Drupal site - every page says &quot;access denied&quot;</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/569/body/und/full&quot;&gt;
Once
 upon a time I updated a Drupal site and was unable to log in after the 
update was complete. I tried messing with the $cookie_domain and 
$base_url to no avail. When I used the Web Inspector or Firebug to view 
my Cookies I noticed I was not getting a familiar PHP Session Cookie.&lt;br /&gt;

Here&#39;s how to check:&lt;br /&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Chrome or Safari: &lt;/strong&gt;right click and Inspect 
Element, then switch to the &quot;Resources&quot; tab, click &quot;Cookies&quot; then the 
domain name of your site, like &quot;drupaleasy.com&quot;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Firebug:&lt;/strong&gt; Open Firebug, click the &quot;Cookies&quot; tab (you may have to enable it first)&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Firefox:&lt;/strong&gt; Open the &quot;Developer Toolbar&quot; (shift+F2 or 
Tools &amp;gt; Web Developer &amp;gt; Developer Toolbar) and a small black bar 
appears at the bottom of your window. Type:&lt;br /&gt;&lt;code&gt;cookie list&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;All of the above:&lt;/strong&gt; Open the Javascript Console and type:&amp;nbsp;&lt;code&gt;document.cookie&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
Make sure you can see a cookie that starts with SESS. Try to log in and look again.&lt;br /&gt;

If you don&#39;t see one, sessions are likely messed up. Try truncating your session table in your site&#39;s database.&lt;br /&gt;

From the sql command line:&lt;br /&gt;

&lt;code&gt;truncate table sessions;&lt;/code&gt;
&lt;br /&gt;
Everyone who is currently logged in will be logged out, but in my case I was now able to log in. Hope that helps.&lt;br /&gt;

If you use a graphical tool like phpMyAdmin, you can truncate a table
 by clicking on the box next to the &quot;sessions&quot; table and choosing the 
&quot;Empty&quot; option.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/2949914845755130559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/i-cant-log-in-to-my-drupal-site-every.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/2949914845755130559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/2949914845755130559'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/i-cant-log-in-to-my-drupal-site-every.html' title=' I can&#39;t log in to my Drupal site - every page says &quot;access denied&quot;'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-7303199920215970106</id><published>2016-02-17T13:15:00.002+05:30</published><updated>2016-02-17T13:15:36.666+05:30</updated><title type='text'> Drupal 7 Check for Available Updates Solution</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/631/body/und/full&quot;&gt;
On
 a Drupal 7 website&#39;s &quot;Available updates&quot; page 
(admin/reports/updates/update), if and when you request that Drupal 
manually check for updates (of modules and themes), it can sometimes 
fail to get available update data for most or all of the projects, 
regardless of how many times you retry the process. The problem is 
caused by errant records in the cache_update table in the Drupal 
database, which apparently are not removed by the update request. In 
theory, this should be fixable by requesting that the system clear all 
of the caches (admin/config/development/performance), but even that 
operation can fail to empty the table. In this case, you must empty — 
&quot;truncate&quot;, in database parlance, not &quot;drop&quot; — that table yourself and 
then manually check for update data again.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/7303199920215970106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drupal-7-check-for-available-updates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/7303199920215970106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/7303199920215970106'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drupal-7-check-for-available-updates.html' title=' Drupal 7 Check for Available Updates Solution'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-5899826912543189734</id><published>2016-02-17T13:14:00.002+05:30</published><updated>2016-02-17T13:14:16.517+05:30</updated><title type='text'> Limiting Drupal Registrations to Profiles</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/634/body/und/full&quot;&gt;
If you are using the &lt;a href=&quot;https://drupal.org/project/profile2&quot;&gt;Profile 2 module&lt;/a&gt;
 to set up multiple profiles in a Drupal website, and you want each 
visitor to register any new account using only one of those profiles, 
then you should redirect the Drupal path &quot;user/register&quot; — using a URL 
alias or an HTTP redirect — to a new page that explains the different 
profiles and has links to the unique registration pages for each one. 
(For any profile P, the Drupal path to the profile-specific registration
 page would be &quot;/P/register&quot;.) Otherwise, a visitor may arrive at the 
generic registration page (intentionally or otherwise) and create a new 
account independent of those profiles.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/5899826912543189734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/limiting-drupal-registrations-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/5899826912543189734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/5899826912543189734'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/limiting-drupal-registrations-to.html' title=' Limiting Drupal Registrations to Profiles'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-817555442651215379</id><published>2016-02-17T13:10:00.002+05:30</published><updated>2016-02-17T13:10:42.994+05:30</updated><title type='text'> Drush on Mac OS X Troubles? Could be a Case Issue...</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/636/body/und/full&quot;&gt;
I recently discovered the solution to a long-standing &lt;a href=&quot;http://www.drupal.org/project/drush&quot;&gt;drush&lt;/a&gt; issue I have been experiencing on Mac OS X. The symptoms of the problem included several &lt;a href=&quot;https://drupal.org/node/1305254&quot;&gt;mysterious&lt;/a&gt; &lt;a href=&quot;https://drupal.org/node/2026149&quot;&gt;fatal errors&lt;/a&gt; that would crop up from time-to-time as well as the fact that I&#39;ve had to use the &lt;code&gt;--uri=mysite.dev&lt;/code&gt; parameter for every local site on my computer.&lt;br /&gt;

I finally tracked down the issue to case-sensitivity. On my Mac, I keep all my local sites in the &lt;code&gt;/Users/michael/Sites&lt;/code&gt;
 directory - this is the default directory that comes with OS X, and can
 be used by the Mac&#39;s built-in version of Apache. I use both MAMP Pro 
(for client sites) and Acquia Dev Desktop (for teaching), and every site
 I have lives in this directory.&lt;br /&gt;

Up until yesterday, whenever I would fire up my Terminal app, I would (by default) be deposited in &lt;code&gt;/Users/michael&lt;/code&gt;, so my first order of business would be to do a &lt;code&gt;cd sites/[directory of the site I wanted to work with]&lt;/code&gt;.
 While that worked fine as far as my Mac was concerned, when I then went
 to run a drush command, I would either get a fatal error (cannot 
redeclare a function) or drush wouldn&#39;t know which site it was in, and 
I&#39;d be forced to either use a drush alias or the &lt;code&gt;--uri=mysite.dev&lt;/code&gt;
 parameter. It turns out that because drush is (and most *nix-y tools 
are) case sensitive, it wasn&#39;t actually finding my site, hence the need 
for the &lt;code&gt;--uri=mysite.dev&lt;/code&gt; parameter.&lt;br /&gt;

The solution is dead simple. When I fire up my Terminal app, I now use &lt;code&gt;cd Sites&lt;/code&gt;, with a capital &quot;S&quot; (actually, I just set a new default directory for it). So far (less than 24 hours in), this has solved &lt;em&gt;every single drush issue I had been having&lt;/em&gt;.&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/817555442651215379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drush-on-mac-os-x-troubles-could-be.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/817555442651215379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/817555442651215379'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drush-on-mac-os-x-troubles-could-be.html' title=' Drush on Mac OS X Troubles? Could be a Case Issue...'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-2100728861198856340</id><published>2016-02-17T13:03:00.002+05:30</published><updated>2016-02-17T13:03:34.261+05:30</updated><title type='text'> Re-ordering Views Attachment Displays</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/635/body/und/full&quot;&gt;
If
 you have a Drupal 7 view with more than one attachment display, it is 
not super-obvious how you can reorder the displays. When you create a 
new attachment display, you can choose the display to attach the 
attachment display to as well as the position (&quot;before&quot;, &quot;after&quot;, or 
&quot;both&quot;).&lt;br /&gt;

But what if you need to attach two attachment displays &quot;before&quot; 
another display - how can you control the order of the two attachment 
displays.&lt;br /&gt;

it&#39;s actually quite easy once you know how - in the view&#39;s &quot;edit view
 name/description&quot;, there is a &quot;reorder displays&quot; option. Click it and 
behold!&lt;br /&gt;&lt;img alt=&quot;Views screenshot&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/displays_reorder.png&quot; /&gt;&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/2100728861198856340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/re-ordering-views-attachment-displays.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/2100728861198856340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/2100728861198856340'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/re-ordering-views-attachment-displays.html' title=' Re-ordering Views Attachment Displays'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-4309322018903820174</id><published>2016-02-17T13:02:00.002+05:30</published><updated>2016-02-17T13:02:23.694+05:30</updated><title type='text'> Debugging with PhpStorm (Including Drush)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I recently made the switch from another (several) code editors to &lt;a href=&quot;http://www.jetbrains.com/phpstorm/&quot;&gt;PhpStorm&lt;/a&gt;
 based on the recommendations of several members of the Drupal community
 - not to mention all the postive things I&#39;ve heard about it on IRC and 
various other places.&lt;br /&gt;

My main motivation for making the switch was the ability to have a 
integrated debugger - both when running Drupal in a web browser and via 
Drush. While there are plenty of resources online demonstrating how to 
set up the debugger, I found that I needed to do a combination of things
 to make it happen&lt;br /&gt;

&lt;h2&gt;
Enable xDebug&lt;/h2&gt;
Depending on your *AMP stack, xDebug may or may not be enabled by 
default. I use MAMP Pro, and it wasn&#39;t. It was easy enough to enable - I
 added the following to my php.ini file (note that the path will be 
dependent on the version of PHP you&#39;d like to use):&lt;br /&gt;

&lt;code&gt;[xdebug]&lt;br /&gt;
zend_extension=&quot;/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so&quot;&lt;br /&gt;
xdebug.profiler_enable = 0&lt;br /&gt;
xdebug.profiler_output_dir = &quot;/tmp&quot;&lt;br /&gt;
xdebug.remote_enable=1&lt;br /&gt;
xdebug.remote_host=localhost&lt;br /&gt;
xdebug.remote_port=9000&lt;br /&gt;
xdebug.remote_handler=dbgp&lt;br /&gt;
xdebug.max_nesting_level=500&lt;br /&gt;
xdebug.idekey=PHPSTORM&lt;/code&gt;&lt;br /&gt;

To make it work from the command line (Drush), I also had to add this stuff to &lt;em&gt;another&lt;/em&gt; php.ini file. I figured out which one by doing a &lt;code&gt;drush status&lt;/code&gt; and seeing which PHP configuration it was using. Here&#39;s some &lt;a href=&quot;http://confluence.jetbrains.com/display/PhpStorm/Xdebug+Installation+Guide&quot;&gt;documentation&lt;/a&gt; demonstrating how to confirm you&#39;re good-to-go.&lt;br /&gt;

&lt;h2&gt;
Update .bash_profile&lt;/h2&gt;
If you want to be able to debug Drush commands, you&#39;ll need to add the following to your .bash_profile:&lt;br /&gt;

&lt;code&gt;export XDEBUG_CONFIG=&quot;idekey=PHPSTORM&quot;&lt;/code&gt;&lt;br /&gt;

If you&#39;re using another command line interface, you&#39;ll need to make a similar addition. Be sure to &lt;code&gt;source ~/.bash_profile&lt;/code&gt; after you make the change (or restart your terminal session). See Angus Max&#39;s &lt;a href=&quot;https://www.lullabot.com/blog/article/debugging-drush-commands-xdebug-and-phpstorm&quot;&gt;post on Lullabot.com&lt;/a&gt; for more details.&lt;br /&gt;

&lt;h2&gt;
Configure PhpStorm&lt;/h2&gt;
JetBrains (the makers behind PhpStorm) provide decent online documentation - I found &lt;a href=&quot;http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm&quot;&gt;this post&lt;/a&gt; and &lt;a href=&quot;http://tv.jetbrains.net/videocontent/debugging-configuration-validation-in-phpstorm-phpstorm-video-tutorial&quot;&gt;this screencast&lt;/a&gt; especially helpful. For my situation, where I wanted to debug a local site, the following settings are key:&lt;br /&gt;

&lt;h3&gt;
Max. Simultaneous Connections&lt;/h3&gt;
When debugging automated tests using the run-tests.sh script, it is 
crucial that PhpStorm&#39;s &quot;Max Simultaneous Connections&quot; for PHP Debugging
 is set to a sufficiently large value. &quot;9&quot; works for me.&lt;br /&gt;

&lt;img alt=&quot;Max. Simultaneous Connections&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/cursor_and_preferences.png&quot; /&gt;&lt;br /&gt;

&lt;h3&gt;
Setting up a deployment server&lt;/h3&gt;
Configuring a deployment server is one of the key things you need to 
do in order to debug in PhpStorm. While PhpStorm supports remote 
debugging, for my situation, the &quot;In place&quot; deployment type was 
sufficient.&lt;br /&gt;

&lt;img alt=&quot;Deployment server type: In place&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/preferences_and_index_php_-_drupal8_-_sites_drupal8_.png&quot; /&gt;&lt;br /&gt;

The deployment server mappings were left at their default values:&lt;br /&gt;

&lt;img alt=&quot;Deployment server mappings&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/deployment_mappings.png&quot; /&gt;&lt;br /&gt;

&lt;h3&gt;
Troubleshooting&lt;/h3&gt;
At this point, you should be able to enable the PhpStorm debugging 
listener, go into your browser, turn debugging on (either via a &lt;a href=&quot;https://extensions.apple.com/details/?id=nl.wrep.xdebug-helper.safari-28RC4265JU&quot;&gt;browser&lt;/a&gt; &lt;a href=&quot;https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc&quot;&gt;extension&lt;/a&gt; or &lt;a href=&quot;http://www.jetbrains.com/phpstorm/marklets/&quot;&gt;bookmarklet&lt;/a&gt;&lt;br /&gt;
and happily debug away. If it doesn&#39;t work, here are a couple of things you can take a look at:&lt;br /&gt;

&lt;ol&gt;
&lt;li&gt;Case-senstitivity in paths - on my machine, the path to my 
&quot;Sites&quot; directory is &quot;/Users/michael/Sites&quot;. I had an issue where 
breakpoints weren&#39;t working that I tracked down to a lower case &quot;s&quot; in 
&quot;Sites&quot; that I mistakenly set up in my Apahce virtual host for the site 
(&quot;/Users/michael/sites&quot; instead of &quot;/Users/michael/Sites&quot;).  &lt;/li&gt;
&lt;li&gt;xdebug version - some versions of xdebug are better than others. 
Several months ago I had an issue with xdebug not working properly when 
debugging from the commandline (Drush). I tracked it down to an old, 
buggy version of xdebug. I updated xdebug and all was well.  &lt;/li&gt;
&lt;li&gt;Some people use PhpStorm &quot;configurations&quot; to configure debugging, 
while this works fine, it isn&#39;t necessary. I have zero &quot;configurations&quot; 
configured on my machine.  &lt;/li&gt;
&lt;li&gt;Debugging from Drush - be sure to set your PHP_ID_CONFIG value to same value as your PhpStorm project &quot;server&quot;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Do you use Acquia Dev Desktop?&amp;nbsp;  &lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/4309322018903820174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/debugging-with-phpstorm-including-drush.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/4309322018903820174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/4309322018903820174'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/debugging-with-phpstorm-including-drush.html' title=' Debugging with PhpStorm (Including Drush)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-8375963435111440188</id><published>2016-02-17T12:53:00.003+05:30</published><updated>2016-02-17T12:53:39.370+05:30</updated><title type='text'> Drupal 8 paths inconsistencies</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/742/body/und/full&quot;&gt;
While
 Drupal 8 has plenty of things to be excited about, there are a few 
&quot;gotchas&quot; that site-builders need to be aware of as they build out 
sites. I found the first thing that I had trouble with was the way that 
Drupal 8 isn&#39;t very consistent (yet?) with the way it handles paths. In 
Drupal 7 and before, anytime you needed to enter a path, it (almost?) 
never started with a leading &quot;/&quot;. For example, need to add an new alias 
for a node? You would enter &quot;my-new-node&quot;, not &quot;/my-new-node&quot;.&lt;br /&gt;

With Drupal 8, a leading slash &lt;strong&gt;is required&lt;/strong&gt; for path 
aliases. Unfortunately, leading slashes are not required everywhere. For
 example, in Drupal 8 page displays in Views do not require a leading 
slash. Neither do contact form post-submit redirects (they actually 
require something like &quot;entity:node/743&quot;!) But, block visibility 
settings require the leading slash. In most cases, the help text 
indicates when the leading slash is necessary, so it helps to pay 
attention!&lt;br /&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/8375963435111440188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drupal-8-paths-inconsistencies.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/8375963435111440188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/8375963435111440188'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/drupal-8-paths-inconsistencies.html' title=' Drupal 8 paths inconsistencies'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-237455487735918192</id><published>2016-02-17T12:53:00.000+05:30</published><updated>2016-02-17T12:53:08.017+05:30</updated><title type='text'> X Marks the Spot: A Beginner&#39;s Guide to Online Maps in Drupal</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 class=&quot;js-quickedit-page-title&quot;&gt;
&lt;span data-quickedit-field-id=&quot;node/630/title/und/full&quot;&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;section id=&quot;block-drupaleasy-content&quot;&gt;
  
  
    

    &lt;div&gt;
    
    &lt;article class=&quot;contextual-region&quot; data-history-node-id=&quot;630&quot; data-quickedit-entity-id=&quot;node/630&quot; id=&quot;node-630&quot; role=&quot;article&quot;&gt;
  &lt;div class=&quot;de-article&quot;&gt;
    
        

        &lt;div class=&quot;posted&quot;&gt;
            
    &lt;/div&gt;
&lt;div class=&quot;field field--name-body field--type-text-with-summary field--label-hidden field__item&quot; data-quickedit-field-id=&quot;node/630/body/und/full&quot;&gt;
&lt;img alt=&quot;X Marks the Spot sample map&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/tutorial_intro.png&quot; /&gt;&lt;br /&gt;
Mapping address data in Drupal can be confusing, if only because of the 
great number of contributed modules available that involve online maps. 
Picking the right module (or combination of modules) is challenging - 
especially for site builders who are new to mapping in Drupal. In this 
tutorial, we&#39;ll utilize the popular and well-supported &lt;a href=&quot;http://www.drupal.org/project/geofield&quot;&gt;Geofield&lt;/a&gt; module as one of the key ingredients in the common task of entering address data and having it displayed on an interactive map.&lt;br /&gt;

This tutorial contains step-by-step instructions for accomplishing 
this task, as well as a screencast demonstrating all of the steps. &lt;br /&gt;

We&#39;ll use the example of adding DrupalCamp address information to a 
Drupal 7 site. The site will then automatically display the DrupalCamp 
on a map on each camp&#39;s page, as well as display all camps on a single 
map. Finally, we&#39;re going to look at some of the options for using 
different map base layers.&lt;br /&gt;

This tutorial assumes that you&#39;re familiar with Drupal&#39;s &quot;big 5&quot; 
(content types, taxonomy, menus, users/roles/permissions, and 
blocks/regions/themes), the &lt;a href=&quot;http://www.drupal.org/project/views&quot;&gt;Views&lt;/a&gt; module, as well as downloading, installing, and enabling modules.&lt;br /&gt;

Here are the basic steps of what we&#39;ll be doing:&lt;br /&gt;

&lt;ol&gt;
&lt;li&gt;Create a new DrupalCamp content type with a standard (postal) address field.  &lt;/li&gt;
&lt;li&gt;Add a (Geofield) field to the DrupalCamp content type to store each address&#39;s corresponding latitude and longitude. The &lt;a href=&quot;http://www.drupal.org/project/geocoder&quot;&gt;Geocoder&lt;/a&gt; module will be used to convert the postal address into latitude and longitude values.  &lt;/li&gt;
&lt;li&gt;Configure the DrupalCamp content type so that a the latitude and longitude field are displayed as a map.  &lt;/li&gt;
&lt;li&gt;Create a view that displays all DrupalCamp nodes&#39; address information on a single map.  &lt;/li&gt;
&lt;li&gt;Check out the various options for changing the look of the maps.  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
Screencast&lt;/h2&gt;
&lt;div class=&quot;embed-container&quot;&gt;
&lt;/div&gt;
&lt;h2&gt;
Create a new &quot;DrupalCamp&quot; Content Type&lt;/h2&gt;
We&#39;re going to use the &lt;a href=&quot;http://www.drupal.org/project/addressfield&quot;&gt;Address Field&lt;/a&gt; module (which requires the &lt;a href=&quot;http://www.drupal.org/project/ctools&quot;&gt;Chaos tools&lt;/a&gt;
 module) to allow users to easliy input postal address information for 
each camp. Once the module is enabled, create a new &quot;DrupalCamp&quot; content
 type and add a new field of type &quot;Postal address&quot; (provided by the 
Address Field module). Give it a label of &quot;Location&quot;, and set its 
configuration as follows  (anything not listed can be left at default 
values):&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Available countries: United States  &lt;/li&gt;
&lt;li&gt;Format handlers: Address form (country-specific) and Name  &lt;/li&gt;
&lt;/ul&gt;
&lt;img alt=&quot;DrupalCamp content type&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/tutorial_contenttype.png&quot; /&gt;&lt;br /&gt;

&lt;h2&gt;
Provide a Field to Store Latitude and Longitude&lt;/h2&gt;
The &lt;a href=&quot;http://www.drupal.org/project/geofield&quot;&gt;Geofield&lt;/a&gt; 
module is used to store geographic data in Drupal 7. It can store 
points, lines, and polygons, but for this example, we&#39;ll just be storing
 individual points (locations) - luckily, this is the easiest (and most 
common) scenario. The Geofield module also requires the &lt;a href=&quot;http://www.drupal.org/project/ctools&quot;&gt;Chaos tools&lt;/a&gt; module as well as the &lt;a href=&quot;http://www.drupal.org/project/geophp&quot;&gt;geoPHP&lt;/a&gt; module.&lt;br /&gt;

The Geofield module also comes with the Geofield Map module, which we&#39;ll be using later in this tutorial.&lt;br /&gt;

Before we go ahead and add a new Geofield field type field to our 
DrupalCamp content type, we&#39;re going to want to go ahead and also enable
 the &lt;a href=&quot;http://www.drupal.org/project/geocoder&quot;&gt;Geocoder&lt;/a&gt; 
module. This is because the Geocoder module provides a widget for the 
Geofield field type that we&#39;re going to use. The Geocoder module also 
requires the &lt;a href=&quot;http://www.drupal.org/project/ctools&quot;&gt;Chaos tools&lt;/a&gt; and &lt;a href=&quot;http://www.drupal.org/project/geophp&quot;&gt;geoPHP&lt;/a&gt; modules.&lt;br /&gt;

Now that we have all the required modules enabled, let&#39;s go ahead and
 add a new field to our DrupalCamp content type. Give it a label of 
&quot;Location lat/lon&quot;, use a field type of &quot;Geofield&quot;, and set its widget 
to &quot;Geocode from another field&quot; (this is where the Geocoder module comes
 in). Settings for the field are  (anything not listed can be left at 
default values):&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Geocode from field: Location  &lt;/li&gt;
&lt;li&gt;Geocoder: Google Geocoder  &lt;/li&gt;
&lt;/ul&gt;
&lt;img alt=&quot;DrupalCamp Location Lat/Lon field settings&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/tutorial_geocoder.png&quot; /&gt;&lt;br /&gt;

These two field settings are the key for automatically converting 
postal address data entered in the &quot;Location&quot; field into 
latitude/longitude data stored in the &quot;Location lat/lon&quot; field. The 
settings instruct the Geocoder module to grab the postal address data 
and send it to the Google Geocoder web service which does the heavy 
lifting of converting it to a latitude and longitude. Other geocoding 
services are available, but each one provides different capabilities and
 different usage limits. For Google Geocoder:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.google.com/maps/documentation/geocoding/#Limits&quot;&gt;Limit of 2,500 requests per 24 hour period&lt;/a&gt; - additional requests are available at various price points.  &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gmaps-samples.googlecode.com/svn/trunk/mapcoverage_filtered.html&quot;&gt;Works for most countries&lt;/a&gt;  &lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;Note: you&#39;ll need to have an active internet connection for the Geocoding to work.&lt;/strong&gt;&lt;br /&gt;

&lt;em&gt;Feel free to add other fields to the DrupalCamp content type at 
your lesiure, but for this tutorial, this is all that we&#39;re going to 
need.&lt;/em&gt;&lt;br /&gt;

&lt;h2&gt;
Display a Map for Each DrupalCamp Node&lt;/h2&gt;
At this point, we&#39;re ready to add some DrupalCamp nodes. &lt;a href=&quot;http://www.drupical.com/&quot;&gt;Find&lt;/a&gt; &lt;a href=&quot;http://buildamodule.com/drupal-camps-calendar&quot;&gt;some&lt;/a&gt; DrupalCamps to enter - be sure to enter complete location information for each.&lt;br /&gt;

You&#39;ll notice that as each one is added the &quot;Location lat/lon&quot; field 
displays something like &quot;POINT (-90.3288385 38.6491536)&quot;. Navigate on 
over to the &quot;Manage Display&quot; settings for the DrupalCamp content type 
and notice that the formatter for the field is set to &quot;Well Known Text 
(WKT)&quot;. &lt;a href=&quot;http://en.wikipedia.org/wiki/Well-known_text&quot;&gt;According to Wikipedia&lt;/a&gt;:&lt;br /&gt;

&lt;em&gt;Well Known Text (WKT) is a text markup language for representing 
vector geometry objects on a map, spatial reference systems of spatial 
objects and transformations between spatial reference systems.&lt;/em&gt;&lt;br /&gt;

While useful, it doesn&#39;t really provide site visitors with what 
they&#39;re looking for. By enabling the Geofield Map module (which comes 
with Geofield), we can now utilize the &quot;Geofield Map&quot; formatter on the 
&quot;Location lat/lon&quot; field (via the &quot;Manage Display&quot; page of our 
DrupalCamp content type). Select this, then set the formatter&#39;s settings
 as follows (anything not listed can be left at default values):&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Zoom: 15  &lt;/li&gt;
&lt;/ul&gt;
&lt;img alt=&quot;DrupalCamp content type Manage Display settings&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/tutorial_managedisplay.png&quot; /&gt;&lt;br /&gt;

Now, go back and take a look at one of your DrupalCamp nodes; instead
 of the Well Known Text data, you should see a Google Map with a pin at 
the location of the DrupalCamp. Note that this is a fully-enabled Google
 Map that you can pan, zoom, and do most anything else you do with any 
other Google Map.&lt;br /&gt;

&lt;strong&gt;Note: you&#39;ll need to have an active internet connection for the map to display.&lt;/strong&gt;&lt;br /&gt;

&lt;h2&gt;
View All DrupalCamps on a Single Map&lt;/h2&gt;
The ability to view numerous DrupalCamps on a single map is the next logical step. The &lt;a href=&quot;http://www.drupal.org/project/views&quot;&gt;Views module&lt;/a&gt;
 provides the ability to display lists of content. In this case, our 
content is DrupalCamp, and instead of a traditional &quot;list&quot;, we&#39;re going 
to output our view as a map.&lt;br /&gt;

Let&#39;s create a new view called &quot;All DrupalCamps&quot;. Give it a single 
page display with a path of &quot;all-drupalcamps&quot; and filter it by:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Content: Published =  Yes  &lt;/li&gt;
&lt;li&gt;Content: Type = DrupalCamp  &lt;/li&gt;
&lt;/ul&gt;
For fields, we&#39;ll keep it simple:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Content: Title  &lt;/li&gt;
&lt;li&gt;Content: Location lat/lon  &lt;/li&gt;
&lt;/ul&gt;
In the &quot;Content: Location lat/lon&quot; settings, click to &quot;Exclude 
it from display&quot; and leave other settings at their default values.&lt;br /&gt;

We want to be sure that we display all the DrupalCamp nodes on a single map, so modify the Pager settings as well:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Pager: Display all items   &lt;/li&gt;
&lt;/ul&gt;
All that is left at this point is to set the Format of the 
display. Click on &quot;Unformatted text&quot; in the Format settings, and change 
the format to &quot;Geofield Map&quot;. For its settings use the following 
(anything not listed can be left at default values):&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Data Source: Location lat/lon  &lt;/li&gt;
&lt;li&gt;Popup Text: title  &lt;/li&gt;
&lt;/ul&gt;
The &quot;Data Source&quot; setting tells the Geofield Map formatter where
 to look for the latitude and longitude data. In this case, the 
Geofield-based &quot;Location lat/lon&quot; field that we included in our list of 
fields for this view. The &quot;Popup Text&quot; setting instructs Geofield Map to
 use the title field as the text to display when the camp&#39;s pin is 
clicked.&lt;br /&gt;

&lt;img alt=&quot;DrupalCamp All DrupalCamps view&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/tutorial_views.png&quot; /&gt;&lt;br /&gt;

Navigate to the &quot;all-drupalcamps&quot; page on your site and you should 
see a Google Map with a pin displayed for each DrupalCamp node on your 
site.&lt;br /&gt;

&lt;h2&gt;
Alternative Map Styles&lt;/h2&gt;
While the Geofield Map module outputs only Google Maps, the &lt;a href=&quot;http://www.drupal.org/project/leaflet&quot;&gt;Leaflet&lt;/a&gt;
 module provides a number of alternative &quot;base layers&quot; that can give 
your map various looks. While the Leaflet module does a lot more than 
just provide alternate base layers, we&#39;ll only be looking at this 
functionality in this tutorial.&lt;br /&gt;

The Leaflet module requires the &lt;a href=&quot;http://www.drupal.org/project/libraries&quot;&gt;Libraries module&lt;/a&gt;, the &lt;a href=&quot;http://www.drupal.org/project/entity&quot;&gt;Entity API module&lt;/a&gt;, as well as the 3rd-party &lt;a href=&quot;http://leafletjs.com/download.html&quot;&gt;Leaflet JS library&lt;/a&gt;. Be sure to read the &lt;a href=&quot;https://drupal.org/node/1645460&quot;&gt;installation instructions&lt;/a&gt; to make sure everything is installed properly.&lt;br /&gt;

The Leaflet module comes with several modules. For this tutorial, 
we&#39;ll need to enable the &quot;Leaflet&quot;, &quot;Leaflet More Maps&quot;, and &quot;Leaflet 
views&quot;. modules.&lt;br /&gt;

Once everything is enabled, navigate back to the edit page for the 
&quot;All DrupalCamps&quot; view. Click to change the Format from &quot;Geofield Map&quot; 
to &quot;Leaflet Map&quot;. Set the format settings as follows (anything not 
listed can be left at default values):&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Data Source: Content: Location lat/lon  &lt;/li&gt;
&lt;li&gt;Title Field: Content: Title  &lt;/li&gt;
&lt;li&gt;Map: pick one!  &lt;/li&gt;
&lt;/ul&gt;
&lt;img alt=&quot;Leaflet map&quot; src=&quot;https://www.drupaleasy.com/sites/drupaleasy.com/files/tutorial_leaflet.png&quot; /&gt;&lt;br /&gt;

The &quot;Map&quot; setting provides numerous different options for various 
base layers for your map. Depending on the type of content and/or the 
style of the site, one base layer may be more appropriate than another. 
There are a good number of other options in the &quot;Leaflet Map&quot; settings, 
including the ability to use custom &quot;points&quot; (or &quot;pins&quot;) and vector 
display options (for when the map is displaying more than just points). 
There&#39;s also a &quot;Descriptive Content&quot; field that can be used to display 
additional content about the DrupalCamp when the pin is clicked. This is
 commonly populated with a trimmed version of the body field of the 
node.&lt;br /&gt;

&lt;h2&gt;
Wrap-up&lt;/h2&gt;
Over the years, there have been lots of ways for displaying 
interactive maps on a Drupal site. Each iteration provides more features
 and easier setup and configuration. What this tutorial covered is just 
scratching the surface of what can be done. There are numerous Geofield-
 and Leaflet-related modules that extend the functionality of the basics
 presented here, be sure to check them out!&lt;/div&gt;
&lt;/div&gt;
&lt;/article&gt;&lt;/div&gt;
&lt;/section&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/237455487735918192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/x-marks-spot-beginners-guide-to-online.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/237455487735918192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/237455487735918192'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/x-marks-spot-beginners-guide-to-online.html' title=' X Marks the Spot: A Beginner&#39;s Guide to Online Maps in Drupal'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-4038828952115400315</id><published>2016-02-17T12:50:00.000+05:30</published><updated>2016-02-17T12:50:51.437+05:30</updated><title type='text'>What’s new on Drupal.org? - January 2016</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3&gt;
Following the Conversation&lt;/h3&gt;
One of the most requested features from a wide swath of the community
 has been a better way to follow content on Drupal.org and receive email
 notifications. The issue queues have had this follow functionality for 
some time, but the implementation was quite specific to issues, and not 
easily extensible to the rest of the site.
&lt;br /&gt;

&lt;img src=&quot;https://www.drupal.org/files/follow-function.gif&quot; title=&quot;The Follow button in action&quot; /&gt;&lt;br /&gt;

Because of the volume of content on Drupal.org we have to be careful 
that our implementation will scale well. We now use a notification 
system based on the &lt;a href=&quot;https://www.drupal.org/node/2180145&quot;&gt;Message stack&lt;/a&gt; which functions much more generically and therefore can be applied to many content types on Drupal.org.
&lt;br /&gt;

Follow functionality is now available for comments on Forum topics, 
Posts (like this one), Case Studies, and documentation Book Pages.
&lt;br /&gt;

In the future we intend to extend this follow functionality to 
include notification of new revisions (for relevant content types, 
particularly documentation).
&lt;br /&gt;

&lt;h3&gt;
Community Elections for the Board&lt;/h3&gt;
&lt;img class=&quot;left&quot; src=&quot;https://www.drupal.org/files/board_icon.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

Nominations for the position of At-Large Director from the community are &lt;a href=&quot;https://assoc.drupal.org/blog/holly.ross.drupal/2016-nominations-open-drupal-association-large-director&quot;&gt;now open&lt;/a&gt;.
 There are two of these positions on the board, each elected on 
alternating years. For this year&#39;s elections process we&#39;ve made several 
small refinements:
&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Candidates are now no longer required to display their real 
names on their candidate profile. We will now default to the Drupal.org 
username.&lt;/li&gt;
&lt;li&gt;Candidates do not have to provide a photo, we will default to a generic avatar.&lt;/li&gt;
&lt;li&gt;There is now an &lt;a href=&quot;https://assoc.drupal.org/drupal-association-board-elections&quot;&gt;elections landing page&lt;/a&gt; with complete details about the elections process. &lt;/li&gt;
&lt;/ul&gt;
We encourage members of the community to nominate themselves!
&lt;br /&gt;

&lt;h3&gt;
Drupal.org Enhancements&lt;/h3&gt;
&lt;img class=&quot;right&quot; src=&quot;https://www.drupal.org/files/issues/Screen%20Shot%202015-12-04%20at%204.35.08%20PM.png&quot; title=&quot;&quot; width=&quot;60%&quot; /&gt;&lt;br /&gt;

A number of smaller enhancements made it into the January sprints as well. One of the key ones was the ability to &lt;a href=&quot;https://www.drupal.org/node/2268449#comment-10638058&quot;&gt;configure an arbitrary one-off test&lt;/a&gt;
 in the issue queues against a custom branch. This is a small step 
towards ensuring that the DrupalCI testing framework will support the 
wider testing matrix required for feature branching, so that Drupal can &lt;a href=&quot;http://buytaert.net/always-be-shippable&quot;&gt;always be shippable&lt;/a&gt;.
&lt;br /&gt;

We also spent some time in January reviewing the results of the 
documentation survey that was placed on all existing documentation pages
 on the site. This information is helping to inform the next big item on
 the &lt;a href=&quot;https://www.drupal.org/drupalorg/roadmap&quot;&gt;roadmap&lt;/a&gt; - improved Documentation section on Drupal.org.
&lt;br /&gt;

Finally, we&#39;ve continued our battle against spam with the help of Technology Supporter, &lt;a href=&quot;https://www.distilnetworks.com/&quot;&gt;Distil Networks&lt;/a&gt;.
 We&#39;ve seen some very promising results in initial trials to prevent 
spam account registrations from happening in the first place, and will 
continue to work on refining our integration.&lt;br /&gt;

&lt;h2&gt;
Sustaining support and maintenance&lt;/h2&gt;
&lt;img class=&quot;left&quot; src=&quot;https://www.drupal.org/files/NOLA-Logo-Purple-crown.png&quot; title=&quot;&quot; width=&quot;25%&quot; /&gt;&lt;br /&gt;

&lt;h3&gt;
DrupalCon New Orleans Full -Site Launched!&lt;/h3&gt;
In January we also launched the full -site for &lt;a href=&quot;https://neworleans2016.drupal.org/&quot;&gt;DrupalCon New Orleans&lt;/a&gt;
 with registration and the call for papers. As part of this launch, 
Events.drupal.org now supports multiple, simultaneous event 
registrations with multiple currencies, payment processors, and invoice 
formats. This was a significant engineering lift, but has made 
Events.drupal.org even more robust.
&lt;br /&gt;

DrupalCon New Orleans is happening from May 9-13th, and will be the 
first North American DrupalCon after the release of Drupal 8!&lt;br /&gt;

&lt;h3&gt;
DrupalCon Dublin &lt;/h3&gt;
&lt;img class=&quot;right&quot; src=&quot;https://www.drupal.org/files/dublin_2016_logo_watercolor.jpg&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

The next European DrupalCon will also be here before you know it, and
 we&#39;ve been working with the local community and our designer to update 
the &lt;a href=&quot;https://dublin2016.drupal.org/&quot;&gt;DrupalCon Dublin&lt;/a&gt; splash page with a new logo that we will carry through into the design for the full-site once that is ready to launch.
&lt;br /&gt;

&lt;h3&gt;
Permissions for Elevated Users&lt;/h3&gt;
In January we also focused on auditing the users with elevated 
privileges on Drupal.org, both to ensure that they had the permissions 
they needed, and to enforce our principle of least-access. Users at 
various levels of elevated privileges were contacted to see if they were
 still needed, and if not those privileged roles were removed.
&lt;br /&gt;

The following privileges were also fixed or updated: webmasters can 
now view a user&#39;s&#39; public ssh keys; content moderators can administer 
comments and block spam users without user profile editing privileges. 
We also fixed taxonomy vocabulary access and now both content moderators
 and webmasters have access to edit tags in various vocabularies such as
 Issue tags, giving more community members access to clean those up and 
fight duplicates or unused tags.
&lt;br /&gt;

&lt;h3&gt;
Updates traffic now redirects to HTTPS&lt;/h3&gt;
SSL is now the default for FTP traffic from Drupal.org and for 
Updates.drupal.org itself. This helps to enforce a best practice of 
using SSL wherever possible, and helps to address an oblique attack 
surface where a man-in-the-middle could potentially hijack an update for
 someone running their Drupal installation on an unprotected network 
(i.e. development environments on a personal laptop in a coffee shop).
&lt;br /&gt;

&lt;h3&gt;
Devwww2 Recovery&lt;/h3&gt;
Drupal.org pre-production environments were affected by some 
instability in January, particulary the devwww2 server. A combination of
 a hard restart due to losing a NIC on the machine and some file-system 
level optimizations in the database containers lead to corruption on the
 dev site databases. Drupal.org infrastructure engineers restored the 
system and recovered the critical dev sites, and while some instability 
continues the system has been recovering more cleanly as they work to 
resolve the issue permanently.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/4038828952115400315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2016/02/whats-new-on-drupalorg-january-2016.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/4038828952115400315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/4038828952115400315'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2016/02/whats-new-on-drupalorg-january-2016.html' title='What’s new on Drupal.org? - January 2016'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-609445398971556636</id><published>2015-11-06T16:19:00.001+05:30</published><updated>2015-11-06T16:19:48.782+05:30</updated><title type='text'>Building Custom cTools Plugins in Drupal 7</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;https://www.drupal.org/project/ctools&quot;&gt;cTools&lt;/a&gt; is one of 
those critical Drupal 7 modules many others depend on. It provides a lot
 of APIs and functionality that makes life easier when developing 
modules. Views and Panels are just two examples of such powerhouses that
 depend on it. &lt;br /&gt;

cTools makes available different kinds of functionality. &lt;a href=&quot;http://www.webomelette.com/ctools-object-cache-multi-step-form&quot;&gt;Object caching&lt;/a&gt;,
 configuration exportability, form wizards, dialogs and plugins are but a
 few. A lot of the credit you would normally attribute to Views or 
Panels is actually owed to cTools.&lt;br /&gt;

&lt;img alt=&quot;Drupal logo&quot; src=&quot;http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2014/11/1417342899logo_drupal.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

In this article, we are going to take a look at cTools plugins, 
especially how we can create our very own. After a brief introduction, 
we will immediately go hands on with a custom module that will use the 
cTools plugins to make defining Drupal blocks nicer (more in tune to how
 we define them in Drupal 8).&lt;br /&gt;

&lt;h2 id=&quot;introduction&quot;&gt;
Introduction&lt;/h2&gt;
cTools plugins in Drupal 7 (conceptually not so dissimilar to the 
plugin system in Drupal 8) are meant for easily defining reusable bits 
of functionality. That is to say, for the ability to define isolated 
business logic that is used in some &lt;em&gt;context&lt;/em&gt;. The goal is to set up that &lt;em&gt;context&lt;/em&gt; and plugin type once, and allow other modules to then define plugins that can be used in that &lt;em&gt;context&lt;/em&gt; automatically. &lt;br /&gt;

If you’ve been developing Drupal sites for more than a year you’ve 
probably encountered cTools plugins in one shape or form. I think the 
first plugin type we usually deal with is the &lt;code class=&quot; language-php&quot;&gt;content_type&lt;/code&gt;
 plugin which allows us to create our own custom panel panes that 
display dynamic content. And that is awesome. Some of the others you may
 have encountered in the same realm of Panels are probably &lt;code class=&quot; language-php&quot;&gt;context&lt;/code&gt; and &lt;code class=&quot; language-php&quot;&gt;access&lt;/code&gt; (visibility rules). Maybe even &lt;code class=&quot; language-php&quot;&gt;relationships&lt;/code&gt; and &lt;code class=&quot; language-php&quot;&gt;arguments&lt;/code&gt;. These are all provided by cTools. Panels adds to this list by introducing &lt;code class=&quot; language-php&quot;&gt;layouts&lt;/code&gt; and &lt;code class=&quot; language-php&quot;&gt;styles&lt;/code&gt; that we normally use for creating Panels layouts and individual pane styles. These are I think the more common ones.&lt;br /&gt;

However, all of the above are to a certain extent a black box to 
many. All we know is that we need to define a hook to specify a 
directory and then provide an include file with some definition and 
logic code and the rest happens by magic. Going forward, I would like us
 to look into how a plugin type is &lt;em&gt;defined&lt;/em&gt; so that if the case 
arises, we can create our own plugins to represent some reusable bits of
 functionality. To demonstrate this, we will create a module that turns 
the pesky hook system of defining custom Drupal blocks into a plugin 
based approach similar to what Drupal 8 is using. &lt;br /&gt;

The final code (+ a bit more) can be found in &lt;a href=&quot;https://github.com/upchuk/block_plugin&quot;&gt;this repository&lt;/a&gt; if you want to follow along. And I do expect you are familiar with the steps necessary for defining &lt;a href=&quot;https://api.drupal.org/api/examples/block_example%21block_example.module/7&quot;&gt;custom Drupal blocks&lt;/a&gt;.&lt;br /&gt;

&lt;h2 id=&quot;the-blockplugin-module&quot;&gt;
The block_plugin module&lt;/h2&gt;
As I mentioned, I would like to illustrate the power of cTools 
plugins with a custom plugin type that makes defining Drupal 7 blocks 
saner. Instead of implementing the 2 main hooks (&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_block_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_block_view&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;)
 necessary to define a block, we’ll be able to have separate plugin 
files each responsible for all the logic related to their own block. No 
more switch cases and changing the hook implementation every time we 
need a new block. So how do we do this?&lt;br /&gt;

First, let’s create our &lt;code class=&quot; language-php&quot;&gt;block_plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;info&lt;/code&gt; file to get started with our module:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Block Plugin
description &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Using cTools plugins to define Drupal core blocks
core &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;x
dependencies&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ctools&lt;/code&gt;&lt;/pre&gt;
Simple enough. &lt;br /&gt;

&lt;h2 id=&quot;the-plugin-type&quot;&gt;
The plugin type&lt;/h2&gt;
In order to define our news plugin type, inside the &lt;code class=&quot; language-php&quot;&gt;block_plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;module&lt;/code&gt; file we need to implement &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_ctools_plugin_type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; which is responsible for defining new plugin types cTools will recognize:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_ctools_plugin_type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;block&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;label&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Block&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;use hooks&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;FALSE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;process&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;block_plugin_process_plugin&#39;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
In this hook we need to return an associative array of all the plugin
 type definitions we need keyed by the machine name of the plugin type 
name. Today we are only creating one called &lt;code class=&quot; language-php&quot;&gt;block&lt;/code&gt;. For more information on all the options available here, feel free to consult the &lt;code class=&quot; language-php&quot;&gt;plugins&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;creating&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;html&lt;/code&gt; help file within the cTools module. No use repeating all that information here. &lt;br /&gt;

The &lt;code class=&quot; language-php&quot;&gt;process&lt;/code&gt; key defines a function
 name that gets triggered every time cTools loads for us a plugin and is
 responsible for shaping or massaging the plugin data before we use it. 
It’s sort of a helper function that prepares the plugin for us each time
 so we don’t have to bother. So let’s see what we can do inside that 
function:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_process_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Add a block admin title
&lt;/span&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;admin title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$exploded&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;explode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;_&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$exploded&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$part&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ucfirst&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$part&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;admin title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // By default we also show a block title but this can be overwritten
&lt;/span&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;show title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;show title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;TRUE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Add a block view function
&lt;/span&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;view&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;view&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;module&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;_&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;_view&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Add a block form function
&lt;/span&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;configure&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;configure&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;module&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;_&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;_configure&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Add a block save function
&lt;/span&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;save&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;save&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;module&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;_&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;_save&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This callback receives the plugin array as a reference and some 
information about the plugin type. The task at hand is to either change 
or add data to the plugin dynamically. So what do we achieve above?&lt;br /&gt;

First, if the developer hasn’t defined an admin title for the block 
plugin, we generate one automatically based on the machine name of the 
plugin. This is so that we always have an admin title in the Drupal 
block interface. &lt;br /&gt;

Second, we choose to always display the title of the block so we mark the &lt;code class=&quot; language-php&quot;&gt;show title&lt;/code&gt;
 key of the plugin array as TRUE. When defining the block plugin, the 
developer has the  option of setting this to FALSE in which case we 
won’t show a block title (subject).&lt;br /&gt;

Third, fourth and fifth, we generate a callback function for the 
block view, save and configure actions (if they haven’t already been set
 by the developer for a given plugin). These callbacks will be used when
 implementing &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_block_view&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;, &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_block_configure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_block_save&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;,
 respectively. We won’t be covering the latter two in this article but 
feel free to check out the repository to see what these can look like. &lt;br /&gt;

And that’s pretty much all we need for defining our custom plugin type. We should, however, also implement &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_ctools_plugin_directory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; which, as you may know, is responsible for telling cTools where a plugin of a certain type can be found in the current module:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_ctools_plugin_directory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$module&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$module&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;block_plugin&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;in_array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;array_keys&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;block_plugin_ctools_plugin_type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;plugins/&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This will need to be implemented also by any other module that wants to define &lt;code class=&quot; language-php&quot;&gt;block&lt;/code&gt; plugins. &lt;br /&gt;

&lt;h2 id=&quot;drupal-blocks&quot;&gt;
Drupal blocks&lt;/h2&gt;
Now that we have the plugin type, let’s write the code which turns any defined &lt;code class=&quot; language-php&quot;&gt;block&lt;/code&gt; plugin into a Drupal block. Will start with the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_block_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; implementation:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_block_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$blocks&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$plugins&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_get_all_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugins&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$blocks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;DELTA_PREFIX&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;info&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;admin title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$blocks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Here we load all of the plugins using a helper function and define 
the minimum required information for the block. Here you can add also 
more information but we are keeping it simple for brevity.&lt;br /&gt;

We know each plugin will have a machine name (the name of the include file basically) and an &lt;code class=&quot; language-php&quot;&gt;admin title&lt;/code&gt; because we generate one in the processing phase if one doesn’t exist. The &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;DELTA_PREFIX&lt;/span&gt;&lt;/code&gt;
 is a simple constant in which we define the prefix we want for the 
block machine name because we need to reuse it and should be able to 
easily change it if we want to:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;DELTA_PREFIX&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;block_plugin_&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Our helper function we saw earlier looks like this:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_get_all_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ctools_get_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;block_plugin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;block&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
It’s a simple wrapper around the respective cTools function. And for 
that matter, we also have the following function responsible for loading
 a single plugin by its machine name:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_get_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ctools_get_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;block_plugin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;block&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This is very similar to the one before. &lt;br /&gt;

In order to make our Drupal block definitions complete, we need to implement &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;hook_block_view&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;: &lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_block_view&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$delta&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_plugin_from_delta&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$delta&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$block&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Optional title
&lt;/span&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;show title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;FALSE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$block&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;subject&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Block content
&lt;/span&gt;  &lt;span class=&quot;token variable&quot;&gt;$block&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;content&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;view&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$delta&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$block&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
So what’s happening here? &lt;br /&gt;

First, we use another helper function to try to load a plugin based 
on the delta of the current block and do nothing if we are not dealing 
with a plugin block. &lt;br /&gt;

Second, we build the block. If the user specified a &lt;code class=&quot; language-php&quot;&gt;title&lt;/code&gt; key on the plugin and the &lt;code class=&quot; language-php&quot;&gt;show title&lt;/code&gt;
 key is not false, we set the subject of the block (its title basically)
 as the former’s value. As for the actual block content, we simply call 
the &lt;code class=&quot; language-php&quot;&gt;view&lt;/code&gt; callback defined in the plugin. And that’s it. &lt;br /&gt;

Let us quickly see also the helper function responsible for loading a plugin based on a block delta:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_plugin_from_delta&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$delta&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$prefix_length&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;DELTA_PREFIX&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$delta&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$prefix_length&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_get_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;FALSE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Nothing complicated going on here.&lt;br /&gt;

&lt;h2 id=&quot;defining-block-plugins&quot;&gt;
Defining block plugins&lt;/h2&gt;
Since we told cTools that it can find &lt;code class=&quot; language-php&quot;&gt;block&lt;/code&gt; plugins inside the &lt;code class=&quot; language-php&quot;&gt;plugins&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;block&lt;/code&gt; folder of our module, let’s go ahead and create that folder. In it, we can add our first block inside a file with the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;inc&lt;/code&gt; extension, for example &lt;code class=&quot; language-php&quot;&gt;my_block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;inc&lt;/code&gt;: &lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token delimiter&quot;&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&#39;title&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;This is my block&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * Returns a renderable array that represents the block content
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;block_plugin_my_block_view&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$delta&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;markup&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#markup&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Yo block!&#39;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Like we do with all other plugins (&lt;code class=&quot; language-php&quot;&gt;content_type&lt;/code&gt;, &lt;code class=&quot; language-php&quot;&gt;context&lt;/code&gt;, etc), the plugin definition is in the form of an array inside a variable called &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;/code&gt;. And for our case all we need at this point is a &lt;code class=&quot; language-php&quot;&gt;title&lt;/code&gt; (and not even that since without it the block simply won’t show a title). &lt;br /&gt;

Below it, we defined our callback function to display the block. The 
naming of this function is important. It matches the pattern we used for
 it during the processing phase (&lt;code class=&quot; language-php&quot;&gt;module_name_plugin_name_view&lt;/code&gt;). If we want to name it differently, all we have to do is reference the function name in the &lt;code class=&quot; language-php&quot;&gt;view&lt;/code&gt; key of the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$plugin&lt;/span&gt;&lt;/code&gt; and it will use that one instead. &lt;br /&gt;

And that is basically it. We can now clear our caches and go to the 
Block administration screen where we can find our block and add it to a 
region. Showing that block on the page should trigger the &lt;code class=&quot; language-php&quot;&gt;view&lt;/code&gt; callback for that block plugin and render the contents.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/609445398971556636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2015/11/building-custom-ctools-plugins-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/609445398971556636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/609445398971556636'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2015/11/building-custom-ctools-plugins-in.html' title='Building Custom cTools Plugins in Drupal 7'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-6507870314427079637</id><published>2015-11-06T16:18:00.002+05:30</published><updated>2015-11-06T16:18:34.420+05:30</updated><title type='text'>Custom Display Suite Fields in Drupal 8</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Without question, &lt;a href=&quot;https://www.drupal.org/project/ds&quot;&gt;Display Suite&lt;/a&gt;
 is one of the most popular modules in Drupal’s contributed modules 
history. It allows the creation of layouts, fields and exposes all sorts
 of other powerful tools we use to build the presentation layer of our 
Drupal sites.&lt;br /&gt;

&lt;img alt=&quot;Drupal 8 logo&quot; src=&quot;http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2014/11/1416938561drupal8wide-1024x332.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

One of the more powerful features of Display Suite (DS) is the 
ability to create custom fields that can be displayed inside DS layouts 
alongside the actual core field values. In Drupal 7, this has been a 
very popular way of building layouts and showing dynamic data that is 
not strictly related to the output of any Field API field on the node 
(or other) entity. &lt;br /&gt;

Display Suite has been ported and is being maintained for Drupal 8. Depending on another contributed module called &lt;a href=&quot;https://www.drupal.org/project/layout_plugin&quot;&gt;Layout Plugin&lt;/a&gt;, the D8 version offers much of what we have available in Drupal 7 and probably even more.&lt;br /&gt;

In this article, we are going to look at how we can create our own 
Display Suite field in Drupal 8 using the new OOP architecture and 
plugin system. To demonstrate this, we are going to create a DS field 
available only on the Article nodes that can be used to display a list 
of taxonomy terms from a certain vocabulary. And we’re going to make it 
so that the latter can be configured from the UI, namely admins will be 
able to specify which vocabulary’s terms should be listed. Not much 
usefulness in this example, I know, but it will allow you to understand 
how things work.&lt;br /&gt;

If you are following along, the code we write is available in &lt;a href=&quot;https://github.com/upchuk/d8-demo-modules/tree/master/demo&quot;&gt;this repository&lt;/a&gt; inside the &lt;code class=&quot; language-php&quot;&gt;Demo&lt;/code&gt; module. So feel free to check that out.&lt;br /&gt;

&lt;h2 id=&quot;drupal-8-plugins&quot;&gt;
Drupal 8 plugins&lt;/h2&gt;
Much of the functionality that used to be declared using an &lt;code class=&quot; language-php&quot;&gt;_info&lt;/code&gt;
 hook in Drupal 7 is now declared using plugins in Drupal 8. For more 
information on using plugins and creating your own plugin types, make 
sure you check out a previous Sitepoint article that talks about just that. &lt;br /&gt;

Display Suite also uses the new plugin system to allow other modules to define DS fields. It exposes a &lt;code class=&quot; language-php&quot;&gt;DsField&lt;/code&gt; plugin type which allows us to write and maintain all the necessary logic for such a field inside a single plugin class (+ any &lt;a href=&quot;http://www.webomelette.com/drupal-8-dependency-injection-service-container-and-all-jazz&quot;&gt;services we might inject&lt;/a&gt; into it). So we no longer implement &lt;a href=&quot;http://www.drupalcontrib.org/api/drupal/contributions%21ds%21ds.api.php/function/hook_ds_fields_info/7&quot;&gt;hook_ds_field_info()&lt;/a&gt;
 and return an array of field information per entity type, but create a 
plugin class with data straight in its annotation and the relevant logic
 inside its methods.&lt;br /&gt;

&lt;h2 id=&quot;vocabularyterms-class&quot;&gt;
VocabularyTerms class&lt;/h2&gt;
Let us start by creating our plugin class called &lt;code class=&quot; language-php&quot;&gt;VocabularyTerms&lt;/code&gt; inside the &lt;code class=&quot; language-php&quot;&gt;src&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;plugins&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;DsField&lt;/code&gt; folder of our custom module and annotating it for our purposes:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;demo&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Plugin&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;DsField&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;ds&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Plugin&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;DsField&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;DsFieldBase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * Plugin that renders the terms from a chosen taxonomy vocabulary.
 *
 * @DsField(
 *   id = &quot;vocabulary_terms&quot;,
 *   title = @Translation(&quot;Vocabulary Terms&quot;),
 *   entity_type = &quot;node&quot;,
 *   provider = &quot;demo&quot;,
 *   ui_limit = {&quot;article|*&quot;}
 * )
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;VocabularyTerms&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DsFieldBase&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This class alone will hold all of our logic for our very simple 
DsField plugin. But here are a couple of remarks about what we have so 
far:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;The annotation is quite self explanatory: it provides meta information about the plugin.&lt;/li&gt;
&lt;li&gt;The class extends &lt;code class=&quot; language-php&quot;&gt;DsFieldBase&lt;/code&gt; which provides base functionality for all the plugins of this type. &lt;/li&gt;
&lt;li&gt;At the time of writing, the &lt;code class=&quot; language-php&quot;&gt;ui_limit&lt;/code&gt;
 annotation has just been committed to HEAD so it might not be available
 in the release you are using. Limiting the availability of the field on
 content types and view modes can be done by overriding the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;isAllowed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; method of the base class and performing the logic there. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;default-configuration&quot;&gt;
Default configuration&lt;/h2&gt;
We want our field to be configurable: the ability to select from a 
list of existing vocabularies. So let’s start off by providing some 
defaults to this configuration so that if the user selects nothing, the &lt;code class=&quot; language-php&quot;&gt;Tags&lt;/code&gt; vocabulary which comes with core will be used. For this, we have to implement the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;defaultConfiguration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; method:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * {@inheritdoc}
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;defaultConfiguration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$configuration&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;tags&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$configuration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
And since we only have one configuration option, we return an array 
with one element keyed by the configuration name. That’s about it. &lt;br /&gt;

&lt;h2 id=&quot;formatters&quot;&gt;
Formatters&lt;/h2&gt;
We also want to have the ability to specify from the UI if the list 
of taxonomy terms is a series of links to their term pages or formatter 
as plain text. We could implement this within the configuration realm 
but let’s do so using formatters instead. And it’s very simple: we 
implement the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;formatters&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; method and return an array of available formatters:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * {@inheritdoc}
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;formatters&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;linked&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Linked&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;unlinked&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Unlinked&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;img alt=&quot;DS Field Formatter Options&quot; src=&quot;http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/10/1443943798DS-Field-Formatter-Options.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

These will be available for selection in the UI under the &lt;code class=&quot; language-php&quot;&gt;Field&lt;/code&gt;
 heading of the Manage Display page of the content type. And we’ll be 
able to see the choice when we are building the actual field for 
display. But more on that in a second. &lt;br /&gt;

&lt;h2 id=&quot;configuration-summary&quot;&gt;
Configuration summary&lt;/h2&gt;
It’s also recommended that if we are using UI defined settings, we 
have a summary of what has been selected as a simple string that 
describes it. This gets printed under the &lt;code class=&quot; language-php&quot;&gt;Widget&lt;/code&gt; heading of the Manage Display page of the content type. &lt;br /&gt;

&lt;img alt=&quot;DS Configuration Summary&quot; src=&quot;http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/10/1443943989DS-Configuration-Summary.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

To do this, we need to implement the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;settingsSummary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; method and return said text:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * {@inheritdoc}
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;settingsSummary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$settings&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getConfiguration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$no_selection&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;No vocabulary selected.&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$vocabulary&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;Vocabulary&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$vocabulary&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Vocabulary: &#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$vocabulary&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$no_selection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$no_selection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Here we start getting more intimate with the actual configuration that was stored with the field, available by calling the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;getConfiguration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;
 method on our plugin class. What we do above, then, is check if the 
vocabulary setting has been set, we load it based on its machine name 
using the &lt;code class=&quot; language-php&quot;&gt;Vocabulary&lt;/code&gt; class and return an array of strings that need to be printed. &lt;br /&gt;

Since we are referencing the &lt;code class=&quot; language-php&quot;&gt;Vocabulary&lt;/code&gt; class, we also need to &lt;em&gt;use&lt;/em&gt; it at the top:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;taxonomy&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Entity&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Vocabulary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;strong&gt;Important to note&lt;/strong&gt;: I am using &lt;code class=&quot; language-php&quot;&gt;Vocabulary&lt;/code&gt; statically here to load an entity for the sake of brevity. It is highly recommended you inject the relevant storage using dependency injection and use that to load entities. The same goes for most classes you’ll see me referencing statically below. &lt;br /&gt;

&lt;h2 id=&quot;settings-form&quot;&gt;
Settings form&lt;/h2&gt;
Now that we display which configuration has been chosen from the UI, 
it’s time to provide the actual form which will allow the user to do so.
 This will be made available by clicking the cogwheel under the &lt;code class=&quot; language-php&quot;&gt;Operations&lt;/code&gt; heading of the Manage Display page of the content type. &lt;br /&gt;

&lt;img alt=&quot;DS Field Settings Form&quot; src=&quot;http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/10/1443944105DS-Field-Settings-Form.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * {@inheritdoc}
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;settingsForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; FormStateInterface &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getConfiguration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$names&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;taxonomy_vocabulary_get_names&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$vocabularies&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;Vocabulary&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadMultiple&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$names&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; 
  &lt;span class=&quot;token variable&quot;&gt;$options&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$vocabularies&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$vocabulary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$options&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$vocabulary&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$vocabulary&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$settings&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;select&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#title&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#default_value&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#options&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$options&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$settings&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Like before, we need to implement a method for this. And what we do 
inside is load all the taxonomy vocabulary names and prepare an array of
 options to be used with a Form API select list. The latter is the only 
element we need for this form. &lt;br /&gt;

&lt;h2 id=&quot;rendering-the-field&quot;&gt;
Rendering the field&lt;/h2&gt;
The last thing left to do is implement the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; method responsible for rendering the contents of our field:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * {@inheritdoc}
 */&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getConfiguration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$query&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; \&lt;span class=&quot;token scope&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;entityQuery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;taxonomy_term&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;condition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vid&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;vocabulary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$tids&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$query&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$tids&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$terms&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;Term&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadMultiple&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$tids&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$terms&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#theme&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;item_list&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&#39;#items&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;buildTermList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$terms&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
So what do we do here? First, we access the chosen vocabulary from the configuration. Then we run an EntityQuery to find all the terms in this vocabulary. Next, we load all these terms and finally we return a render array that uses the &lt;code class=&quot; language-php&quot;&gt;item_list&lt;/code&gt; theme to print our terms. &lt;br /&gt;

Although we don’t need it here, in most cases you’ll need to access 
the node entity that is currently being rendered. That is available 
inside the configuration array under the &lt;code class=&quot; language-php&quot;&gt;entity&lt;/code&gt; key. Moreover, under the &lt;code class=&quot; language-php&quot;&gt;build&lt;/code&gt;
 key you have the actual render array of the node being built. So keep 
this in mind and do inspect the other elements of the configuration 
array on your own for more information.&lt;br /&gt;

I would like to mention a few more things before we take a look at the actual &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;buildTermList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;
 method. First, for brevity, we used the EntityQuery service statically.
 In your project, you should inject it. Second, we used the &lt;code class=&quot; language-php&quot;&gt;Term&lt;/code&gt;
 class statically to load the taxonomy term entities. Again, you should 
inject its storage and use that for this purpose. And lastly, we should 
import the &lt;code class=&quot; language-php&quot;&gt;Term&lt;/code&gt; class at the top with &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt;&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;taxonomy&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Entity&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Term&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Now that this is clear, let’s take a look at our own &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;buildTermList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; method:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buildTermList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$terms&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getConfiguration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$formatter&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;field&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;formatter&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;field&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;formatter&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;field&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;formatter&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;unlinked&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$items&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$terms&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$term&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;buildTermListItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$term&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$formatter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This method is responsible for getting the field formatter, looping 
through the term entities and building an array of term information that
 can be printed using the &lt;code class=&quot; language-php&quot;&gt;item_list&lt;/code&gt; 
theme. As you can see, though, the individual term entity and formatter 
are passed to yet another helper method to keep things nice and tidy:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buildTermListItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Term &lt;span class=&quot;token variable&quot;&gt;$term&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$formatter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$formatter&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;linked&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$link_url&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;Url&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromRoute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;entity.taxonomy_term.canonical&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;taxonomy_term&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$term&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; \&lt;span class=&quot;token scope&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$term&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$link_url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;SafeMarkup&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;checkPlain&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$term&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Finally, in the &lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;buildTermListItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt; method we either return the sanitized title of the term or a link to it depending on the formatter. &lt;br /&gt;

Again we see classes which should be injected but were used 
statically to save some space. With the risk of sounding like a broken 
record, keep in mind that you should inject these. For now, we must &lt;em&gt;use&lt;/em&gt; them at the top:&lt;br /&gt;

&lt;pre class=&quot;prettyprint prettyprinted language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Component&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Utility&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;SafeMarkup&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/6507870314427079637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2015/11/custom-display-suite-fields-in-drupal-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/6507870314427079637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/6507870314427079637'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2015/11/custom-display-suite-fields-in-drupal-8.html' title='Custom Display Suite Fields in Drupal 8'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-6506904348993146089</id><published>2015-11-06T16:17:00.000+05:30</published><updated>2015-11-06T16:17:06.974+05:30</updated><title type='text'>PHP vs Node.js</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The web is ever-changing technology landscape. Server-side developers
 have a bewildering choice of long-standing heavy-weights such as Java, 
C, and Perl to newer, web-focused languages such as Ruby, Clojure and 
Go. It rarely matters what you choose, presuming your application works.&lt;br /&gt;

&lt;em&gt;But how do those new to web development make an informed choice?&lt;/em&gt;&lt;br /&gt;

I hope not to start a holy war, but I’m pitting two development disciplines against each other:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://php.net/&quot;&gt;&lt;strong&gt;PHP&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
PHP was created by Rasmus Lerdorf in 1994. It is processed by an 
interpreter normally installed as a module in a web server such as 
Apache or Nginx.
PHP code can be intermingled with HTML. That’s not necessarily 
best-practice, but those new to the language can produce useful code 
very quickly. It contributed to the language’s popularity, and PHP is 
now used on more than 80% of the world’s web servers. It has been helped in no small part by WordPress — a PHP Content Management System which powers a quarter of all sites.
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://nodejs.org/&quot;&gt;&lt;strong&gt;Node.js&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
Node.js was created by Ryan Dahl in 2009. It uses Google’s &lt;a href=&quot;https://code.google.com/p/v8/&quot;&gt;V8 JavaScript engine&lt;/a&gt;, which also powers client-side code in the &lt;a href=&quot;http://www.google.com/chrome/&quot;&gt;Chrome web browser&lt;/a&gt;.
 Unusually, the platform has built-in libraries to handle web requests 
and responses — you don’t need a separate web server or other 
dependencies.
Node.js is relatively new but has been rapidly gaining traction. It’s
 used by companies including Microsoft, Yahoo, LinkedIn and PayPal.
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;where&quot;&gt;
Where’s C#, Java, Ruby, Python, Perl, Erlang, C++, Go, Dart, Scala, Haskell, etc?&lt;/h2&gt;
An article which compared every option would be long. Would you read 
it? Do you expect a single developer to know them all? I’ve restricted 
this smackdown to PHP and Node.js because:&lt;br /&gt;

&lt;ol&gt;
&lt;li&gt;It’s a good comparison. They’re both open source, primarily aimed at web development and applicable to similar projects.&lt;/li&gt;
&lt;li&gt;PHP is a long-established language but Node.js is a young upstart 
receiving increased attention. Should PHP developers believe the Node.js
 hype? Should they consider switching?&lt;/li&gt;
&lt;li&gt;I know and love the languages. I’ve been developing with PHP and 
JavaScript since the late 1990s, with a few years of Node.js experience.
 I’ve dabbled in other technologies, but couldn’t do them justice in 
this review.&lt;/li&gt;
&lt;/ol&gt;
Besides, it wouldn’t matter how many languages I compared. Someone, 
somewhere, would complain that I hadn’t included their favorite!&lt;br /&gt;

&lt;h2 id=&quot;about&quot;&gt;
About Smackdowns&lt;/h2&gt;
Developers spend many years honing their craft. Some have languages 
thrust upon them, but those who reach Ninja level usually make their own
 choice based on a host of factors. It’s subjective; you’ll promote and 
defend your technology decision.&lt;br /&gt;

That said, Smackdowns are not &lt;em&gt;“use whatever suits you, buddy”&lt;/em&gt;
 reviews. I will make recommendations based on my own experience, 
requirements and biases. You’ll agree with some points and disagree with
 others; that’s great — your comments will help others make an informed 
choice.&lt;br /&gt;

&lt;h2 id=&quot;eval&quot;&gt;
Evaluation Methodology&lt;/h2&gt;
PHP and Node.js are compared in the following ten rounds. Each bout 
considers a general development challenge which could be applied to any 
web technology. We won’t go too deep; few people will care about the 
relative merits of random number generators or array sorting algorithms.&lt;br /&gt;

The overall winner will be the technology which wins the most rounds. Ready? Let the battle commence …&lt;br /&gt;

&lt;h2 id=&quot;r1&quot;&gt;
Round 1: Getting Started&lt;/h2&gt;
How quickly can you build a “Hello World” web page? In PHP:&lt;br /&gt;

&lt;pre class=&quot; language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token php&quot;&gt;&lt;span class=&quot;token delimiter&quot;&gt;&amp;lt;?php&lt;/span&gt;
 &lt;span class=&quot;token keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Hello World!&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token delimiter&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
The code can be placed in any file which is interpreted by the PHP engine — typically, one with a &lt;code class=&quot; language-undefined&quot;&gt;.php&lt;/code&gt; extension. Enter the URL which maps to that file in your browser and you’re done.&lt;br /&gt;

Admittedly, this isn’t the whole story. The code will only run via a 
web server with PHP installed. (PHP has a built-in server, although it’s
 best to use something more robust). Most OSs provide server software 
such as IIS on Windows or Apache on Mac and Linux, although they need to
 be enabled and configured. It’s often simpler to use a pre-built set-up
 such as &lt;a href=&quot;https://www.apachefriends.org/&quot;&gt;XAMPP&lt;/a&gt; or a virtual OS image (such as Vagrant). Even easier: upload your file to almost any web host.&lt;br /&gt;

By comparison, installing Node.js is a breeze. You can either &lt;a href=&quot;https://nodejs.org/download/&quot;&gt;download the installer&lt;/a&gt; or &lt;a href=&quot;https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager&quot;&gt;use a package manager&lt;/a&gt;. So let’s create our web page in &lt;code class=&quot; language-undefined&quot;&gt;hello.js&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot; language-javascript&quot;&gt;&lt;code class=&quot; language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; http &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;http&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
http&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createServer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
 res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;writeHead&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Content-Type&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;text/plain&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Hello World!&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;127.0.0.1&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
You need to start the app from the terminal with &lt;code class=&quot; language-undefined&quot;&gt;node hello.js&lt;/code&gt;
 before you can visit http://127.0.0.1:3000/ in your browser. We’ve 
created a small web server in five lines of code and, amazing though 
that is, even those with strong client-side JavaScript experience would 
struggle to understand it.&lt;br /&gt;

&lt;strong&gt;PHP&lt;/strong&gt; is conceptually simpler and wins this round. 
Those who know a few PHP statements can write something useful. It has 
more software dependencies, but PHP concepts are less daunting to new 
developers.&lt;br /&gt;

There’s a greater intellectual leap between knowing some JavaScript 
and coding Node.js apps. The development approach is different from most
 server-side technologies, and you need to understand fairly complex 
concepts such as closures and callback functions.&lt;br /&gt;

&lt;h2 id=&quot;r2&quot;&gt;
Round 2: Help and Support&lt;/h2&gt;
You won’t get far without some development assistance from the official documentation and resources such as courses, forums and &lt;a href=&quot;http://stackoverflow.com/&quot;&gt;StackOverflow&lt;/a&gt;. &lt;strong&gt;PHP&lt;/strong&gt; wins this round easily; it has a great &lt;a href=&quot;http://php.net/docs.php&quot;&gt;manual&lt;/a&gt; and twenty years’ worth of Q&amp;amp;As. Whatever you’re doing, someone will have encountered a similar issue before.&lt;br /&gt;

&lt;a href=&quot;https://nodejs.org/documentation/&quot;&gt;Node.js has good documentation&lt;/a&gt;
 but is younger and there is less help available. JavaScript has been 
around as long as PHP, but the majority of assistance relates to 
in-browser development. That rarely helps.&lt;br /&gt;

&lt;h2 id=&quot;r3&quot;&gt;
Round 3: Language Syntax&lt;/h2&gt;
Are statements and structures logical and easy to use?&lt;br /&gt;

Unlike some languages and frameworks, PHP doesn’t force you to work 
in a specific way and grows with you. You can start with a few 
multi-line programs, add functions, progress to simple PHP4-like objects
 and eventually code beautiful object-oriented MVC PHP5+ applications. 
Your code may be chaotic to start with, but it’ll work and evolve with 
your understanding.&lt;br /&gt;

PHP syntax can change between versions, but backward compatibility is generally good. Unfortunately, this has led to a problem: &lt;em&gt;PHP is a mess&lt;/em&gt;. For example, how do you count the number of characters in a string? Is it &lt;code class=&quot; language-undefined&quot;&gt;count&lt;/code&gt;? &lt;code class=&quot; language-undefined&quot;&gt;str_len&lt;/code&gt;? &lt;code class=&quot; language-undefined&quot;&gt;strlen&lt;/code&gt;? &lt;code class=&quot; language-undefined&quot;&gt;mb_strlen&lt;/code&gt;?
 There are hundreds of functions and they can be inconsistently named. 
Try writing a few lines of code without consulting the manual.&lt;br /&gt;

JavaScript is comparatively concise, with a few dozen core 
statements. That said, the syntax attracts venom from developers because
 its prototypal object model seems familiar but isn’t. You’ll also find 
complaints about mathematical errors (&lt;code class=&quot; language-undefined&quot;&gt;0.1 + 0.2 != 0.3&lt;/code&gt;) and type conversion confusion (&lt;code class=&quot; language-undefined&quot;&gt;&#39;4&#39; + 2 == &#39;42&#39;&lt;/code&gt; and &lt;code class=&quot; language-undefined&quot;&gt;&#39;4&#39; - 2 == 2&lt;/code&gt;) — but these situations rarely cause problems, and all languages have quirks.&lt;br /&gt;

PHP has benefits, but I’m awarding round three to &lt;strong&gt;Node.js&lt;/strong&gt;. The reasons include:&lt;br /&gt;

&lt;ol&gt;
&lt;li id=&quot;bull31&quot;&gt;JavaScript remains the world’s most misunderstood language — but, once the concepts click, it makes other languages seem cumbersome.&lt;/li&gt;
&lt;li id=&quot;bull32&quot;&gt;JavaScript code is terse compared to PHP. For example, you’ll no longer need to translate to/from JSON and — &lt;em&gt;thankfully&lt;/em&gt; — UTF-8.&lt;/li&gt;
&lt;li id=&quot;bull33&quot;&gt;Full-stack developers can use JavaScript on the client and server. Your brain doesn’t need to switch modes.&lt;/li&gt;
&lt;li id=&quot;bull34&quot;&gt;Understanding JavaScript makes you want to use it more. I couldn’t say the same for PHP.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;r4&quot;&gt;
Round 4: Development Tools&lt;/h2&gt;
Both technologies have a good range of editors, IDEs, debuggers, 
validators and other tools. I considered calling a draw but there’s one 
tool which gives &lt;strong&gt;Node.js&lt;/strong&gt; an edge: &lt;a href=&quot;https://www.npmjs.com/&quot;&gt;npm — the Node Package Manager&lt;/a&gt;. npm allows you to install and manage dependencies, set configuration variables, define scripts and more.&lt;br /&gt;

PHP’s &lt;a href=&quot;http://getcomposer.org/&quot;&gt;Composer project&lt;/a&gt; was 
influenced by npm and is better in some respects. However, it’s not 
provided with PHP by default, has a smaller active repository and has 
made less of an impact within the community.&lt;br /&gt;

npm is partially responsible for the growth of build tools such as 
Grunt and Gulp which have revolutionized development. PHP developers 
will probably want/need to install Node.js at some point. The reverse 
isn’t true.&lt;br /&gt;

&lt;h2 id=&quot;r5&quot;&gt;
Round 5: Environments&lt;/h2&gt;
Where can the technologies be used and deployed? Which platforms and 
ecosystems are supported? Web developers often need to create 
applications which aren’t strictly for the web, e.g. build tools, 
migration tools, database conversion scripts, etc.&lt;br /&gt;

There are ways to use PHP for desktop and command-line app development. &lt;em&gt;You won’t use them.&lt;/em&gt; At heart, PHP is a server-side development technology. It’s good at that job but is rarely stretched beyond those boundaries.&lt;br /&gt;

A few years ago, JavaScript would have been considered more 
restrictive. There were a few fringe technologies but its main place was
 in the browser. &lt;strong&gt;Node.js&lt;/strong&gt; has changed that perception 
and there has been an explosion of JavaScript projects. You can use 
JavaScript everywhere — in the browser, on the server, terminal, desktop
 and even embedded systems. Node.js has made JavaScript ubiquitous.&lt;br /&gt;

&lt;h2 id=&quot;r6&quot;&gt;
Round 6: Integration&lt;/h2&gt;
Development technologies are restricted unless they can integrate with databases and drivers. &lt;strong&gt;PHP&lt;/strong&gt;
 is strong in this area. It’s been around for many years and its 
extensions system allow direct communication with a host of popular and 
obscure APIs.&lt;br /&gt;

Node.js is catching up fast, but you may struggle to find mature integration components for older, less-popular technologies.&lt;br /&gt;

&lt;h2 id=&quot;r7&quot;&gt;
Round 7: Hosting and Deployment&lt;/h2&gt;
How easy is deploying your shiny new app to a live web server? It’s another clear win for &lt;strong&gt;PHP&lt;/strong&gt;.
 Contact a random selection of web hosting companies and you’ll discover
 the majority offer PHP support. You’ll probably get MySQL thrown in for
 a bargain price. PHP is considerably easier to sandbox and more risky 
extensions can be disabled.&lt;br /&gt;

Node.js is a different beast and server-side apps run permanently. 
You’ll need a real/virtual/cloud or specialist server environment, 
ideally with root SSH access. That’s a step too far for some hosts, 
especially on shared hosting where you could bring down the whole 
system.&lt;br /&gt;

Node.js hosting will become simpler, but I doubt it’ll ever match the ease of FTP’ing a few PHP files.&lt;br /&gt;

&lt;h2 id=&quot;r8&quot;&gt;
Round 8: Performance&lt;/h2&gt;
PHP is no slouch and there are projects and options which make it 
faster. Even the most demanding PHP developer rarely worries about speed
 but &lt;strong&gt;Node.js&lt;/strong&gt; performance is generally better. Of 
course, performance is largely a consequence of the experience and care 
taken by the development team but Node.js has several advantages…&lt;br /&gt;

&lt;h3 id=&quot;fewer-dependencies&quot;&gt;
Fewer Dependencies&lt;/h3&gt;
All requests to a PHP application must be routed via a web server 
which starts the PHP interpreter which runs the code. Node.js doesn’t 
need so many dependencies and, while you’ll almost certainly use a 
server framework such as &lt;a href=&quot;http://expressjs.com/&quot;&gt;Express&lt;/a&gt;, it’s lightweight and forms part of your application.&lt;br /&gt;

&lt;h3 id=&quot;smaller-interpreter&quot;&gt;
A Smaller, Faster Interpreter&lt;/h3&gt;
Node.js is smaller and nimbler than the PHP interpreter. It’s less 
encumbered by legacy language support and Google has made a huge 
investment in V8 performance.&lt;br /&gt;

&lt;h3 id=&quot;perm-on&quot;&gt;
Applications are Permanently On&lt;/h3&gt;
PHP follows the typical client-server model. Every page request 
initiates your application; you load configuration parameters, connect 
to a database, fetch information and render HTML. A Node.js app runs 
permanently and it need only initialize once. For example, you could 
create a single database connection object which is reused by everyone 
during every request. Admittedly, there are ways to implement this type 
of behavior in PHP using systems such as &lt;a href=&quot;http://memcached.org/&quot;&gt;Memcached&lt;/a&gt; but it’s not a standard feature of the language.&lt;br /&gt;

&lt;h3 id=&quot;io&quot;&gt;
An Event-driven, Non-Blocking I/O&lt;/h3&gt;
PHP and most other server-side languages use an obvious blocking 
execution model. When you issue a command such as fetching information 
from a database, that command will complete execution before progressing
 to the next statement. Node.js doesn’t (normally) wait. Instead, you 
provide a callback function which is executed once the action is 
complete, e.g.&lt;br /&gt;

&lt;pre class=&quot; language-javascript&quot;&gt;&lt;code class=&quot; language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;// fetch records from a NoSQL database&lt;/span&gt;
DB&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;test&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toArray&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;finished&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;// process database information&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; recs&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;recs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39; records returned&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
In this example, the console will output ‘finished’ before ‘N records returned’ because the &lt;code class=&quot; language-undefined&quot;&gt;process&lt;/code&gt;
 function is called when all the data has been retrieved. In other 
words, the interpreter is freed to do other work while other processes 
are busy.&lt;br /&gt;

Note that situations are complex and there are caveats:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Node.js/JavaScript runs on a single thread while most web servers are multi-threaded and handle requests concurrently.&lt;/li&gt;
&lt;li&gt;Long-running JavaScript processes for one user prevent code running for all other users unless you split tasks or use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers&quot;&gt;Web Workers&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Benchmarking is subjective and flawed; you’ll find examples where 
Node.js beats PHP and counter examples where PHP beats Node.js. 
Developers are adept at proving whatever they believe!&lt;/li&gt;
&lt;li&gt;Writing asynchronous event-driven code is complex and incurs its own challenges.&lt;/li&gt;
&lt;/ul&gt;
I can only go from experience: my Node.js applications are noticeably
 faster than PHP equivalents. Yours may not be but you’ll never know 
until you try.&lt;br /&gt;

&lt;h2 id=&quot;r9&quot;&gt;
Round 9: Programmer Passion&lt;/h2&gt;
This may be stretching the &lt;em&gt;“general web development challenge”&lt;/em&gt; objective but it’s important. It doesn’t matter whether a technology is good or bad if you dread writing code every day.&lt;br /&gt;

It’s a little difficult to make comparisons but relatively few PHP 
developers are passionate about the language. When was the last time you
 read a PHP article or saw a presentation which captivated the audience?
 Perhaps everything has been said? Perhaps there’s less exposure? 
Perhaps I’m not looking in the right places? There are some nice 
features arriving in PHP7 but the technology has been treading water for
 a few years. That said, few PHP developers berate the language.&lt;br /&gt;

JavaScript splits the community. There are those who love it and 
those who hate it; few developers sit on the fence. However, response to
 Node.js has been largely positive and the technology is riding the 
crest of a wave. This is partly because it’s new and the praise may not 
last but, for now, &lt;strong&gt;Node.js&lt;/strong&gt; wins this round.&lt;br /&gt;

&lt;h2 id=&quot;r10&quot;&gt;
Round 10: The Future&lt;/h2&gt;
It doesn’t particularly matter which server-side language you use; it
 will continue to work even if the project is abandoned (yay 
ColdFusion!) Usage has possibly plateaued but many continue to use PHP. 
It’s a safe bet and support looks assured for another twenty years.&lt;br /&gt;

The ascent of Node.js has been rapid. It offers a modern development 
approach, uses the same syntax as client-side development and supports 
revolutionary HTML5 features such as web sockets and server-sent events.
 There has been some confusion regarding forks of the language but usage
 continues to grow at an exponential rate.&lt;br /&gt;

Node.js will inevitably eat into PHP’s market share but I doubt it 
will overtake. Both technologies have a bright future. I declare this 
round a draw.&lt;br /&gt;

&lt;h2 id=&quot;winner&quot;&gt;
The Overall Winner&lt;/h2&gt;
The final score: five rounds to &lt;strong&gt;Node.js&lt;/strong&gt;, four to &lt;strong&gt;PHP&lt;/strong&gt; and one draw. The result was closer than I expected and could have gone either way.&lt;br /&gt;

Node.js has a steep learning curve and isn’t ideal for novice developers but it wins this smackdown. &lt;em&gt;Just&lt;/em&gt;.
 If you’re a competent JavaScript programmer who loves the language, 
Node.js doesn’t disappoint. It feels fresher and offers a liberating web
 development experience — &lt;em&gt;you won’t miss PHP&lt;/em&gt;.&lt;br /&gt;

But don’t discount it. PHP is alive and there’s little reason to jump
 on the Node.js bandwagon because it looks faster, newer or trendier. 
PHP is easier to learn yet supports proficient professional programming 
techniques. Assistance is everywhere and deployment is simple. Even 
die-hard Node.js developers should consider PHP for simpler websites and
 apps.&lt;br /&gt;

My advice: &lt;em&gt;assess the options and and pick a language based on your requirements&lt;/em&gt;. That’s far more practical than relying on &lt;em&gt;‘vs’&lt;/em&gt; articles like this!&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/6506904348993146089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2015/11/php-vs-nodejs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/6506904348993146089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/6506904348993146089'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2015/11/php-vs-nodejs.html' title='PHP vs Node.js'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-4208083307692271939</id><published>2015-11-06T15:04:00.004+05:30</published><updated>2015-11-06T15:04:55.275+05:30</updated><title type='text'>How to Build Multi-step Forms in Drupal 8</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;ArticleCopy language-&quot;&gt;
    In this article, we are going to look at building a multistep 
form in Drupal 8. For brevity, the form will have only two steps in the 
shape of two completely separate forms. To persist values across these 
steps, we will use functionality provided by Drupal’s core for storing 
temporary and private data across multiple requests.&lt;br /&gt;
&lt;br /&gt;

&lt;br /&gt;

In Drupal 7, a similar approach can be achieved using the cTools object cache. Alternatively, there is the option of persisting data through the &lt;code class=&quot; language-undefined&quot;&gt;$form_state&lt;/code&gt; array as illustrated in this tutorial. &lt;br /&gt;

The code we write in this article can be found in &lt;a href=&quot;https://github.com/upchuk/d8-demo-modules&quot;&gt;this repository&lt;/a&gt;
 alongside much of the Drupal 8 work we’ve been doing so far. We will be
 dealing with forms quite a lot so I do recommend checking out one of the previous articles on Drupal 8 in which we talk about forms. &lt;br /&gt;

&lt;h2 id=&quot;the-plan&quot;&gt;
The plan&lt;/h2&gt;
As I mentioned above, our multistep form will consist of two 
independent forms with two simple elements each. Users will be able to 
fill in the first one and move to the second form where they can either 
go back to the previous step or fill it in and press submit. While 
navigating between the different steps, the previously submitted values 
are stored and used to pre-populate the form fields. If the last form is
 submitted, however, the data gets processed (not covered in this 
article) and cleared from the temporary storage. &lt;br /&gt;

Technically, both of these forms will inherit common functionality from an abstract form class we will call &lt;code class=&quot; language-undefined&quot;&gt;MultistepFormBase&lt;/code&gt;.
 This class will be in charge of injecting the necessary dependencies, 
scaffolding the form, processing the end result and anything else that 
is needed and is common to both. &lt;br /&gt;

We will group all the form classes together and place them inside a new folder called &lt;code class=&quot; language-undefined&quot;&gt;Multistep&lt;/code&gt; located within the &lt;code class=&quot; language-undefined&quot;&gt;Form&lt;/code&gt; plugin directory of our &lt;code class=&quot; language-undefined&quot;&gt;demo&lt;/code&gt; module (next to the old &lt;code class=&quot; language-undefined&quot;&gt;DemoForm&lt;/code&gt;).
 This is purely for having a clean structure and being able to quickly 
tell which forms are part of our multistep form process. &lt;br /&gt;

&lt;h2 id=&quot;the-code&quot;&gt;
The code&lt;/h2&gt;
We will start with the form base class. I will explain what is going on here after we see the code. &lt;br /&gt;

&lt;strong&gt;MultistepFormBase.php:&lt;/strong&gt;&lt;br /&gt;

&lt;pre class=&quot; language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * @file
 * Contains \Drupal\demo\Form\Multistep\MultistepFormBase.
 */&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;demo&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Form&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Multistep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Form&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;FormBase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Form&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;FormStateInterface&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Session&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;AccountInterface&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Session&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;SessionManagerInterface&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;PrivateTempStoreFactory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Symfony&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Component&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;DependencyInjection&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;ContainerInterface&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MultistepFormBase&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;FormBase&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * @var \Drupal\user\PrivateTempStoreFactory
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$tempStoreFactory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * @var \Drupal\Core\Session\SessionManagerInterface
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$sessionManager&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * @var \Drupal\Core\Session\AccountInterface
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$currentUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * @var \Drupal\user\PrivateTempStore
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$store&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * Constructs a \Drupal\demo\Form\Multistep\MultistepFormBase.
   *
   * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
   * @param \Drupal\Core\Session\SessionManagerInterface $session_manager
   * @param \Drupal\Core\Session\AccountInterface $current_user
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;PrivateTempStoreFactory &lt;span class=&quot;token variable&quot;&gt;$temp_store_factory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; SessionManagerInterface &lt;span class=&quot;token variable&quot;&gt;$session_manager&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; AccountInterface &lt;span class=&quot;token variable&quot;&gt;$current_user&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;tempStoreFactory&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$temp_store_factory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;sessionManager&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$session_manager&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;currentUser&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$current_user&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;tempStoreFactory&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;multistep_data&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ContainerInterface &lt;span class=&quot;token variable&quot;&gt;$container&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token variable&quot;&gt;$container&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;user.private_tempstore&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token variable&quot;&gt;$container&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;session_manager&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token variable&quot;&gt;$container&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;current_user&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}.
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buildForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; FormStateInterface &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Start a manual session for anonymous users.
&lt;/span&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;currentUser&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isAnonymous&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token global&quot;&gt;$_SESSION&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;multistep_form_holds_session&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token global&quot;&gt;$_SESSION&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;multistep_form_holds_session&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;sessionManager&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;actions&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;actions&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;actions&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;submit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;submit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#value&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Submit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#button_type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;primary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#weight&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * Saves the data from the multistep form.
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;saveData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Logic for saving data goes here...
&lt;/span&gt;    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;deleteStore&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;drupal_set_message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;The form has been saved.&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * Helper method that removes all the keys from the store collection used for
   * the multistep form.
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deleteStore&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$keys&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;age&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;location&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$keys&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$key&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$key&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
Our abstract form class extends from the default Drupal &lt;code class=&quot; language-undefined&quot;&gt;FormBase&lt;/code&gt; class so that we can use some of the functionality made available by it and the traits it uses. We are using dependency injection to inject some of the needed services:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot; language-undefined&quot;&gt;PrivateTempStoreFactory&lt;/code&gt; gives us a temporary store that is private to the current user (&lt;code class=&quot; language-undefined&quot;&gt;PrivateTempStore&lt;/code&gt;).
 We will keep all the submitted data from the form steps in this store. 
In the constructor, we are also immediately saving the &lt;code class=&quot; language-undefined&quot;&gt;store&lt;/code&gt; attribute which contains a reference to the &lt;code class=&quot; language-undefined&quot;&gt;multistep_data&lt;/code&gt; key/value collection we will use for this process. The &lt;code class=&quot; language-undefined&quot;&gt;get()&lt;/code&gt; method on the factory either creates the store if it doesn’t exist or retrieves it from the storage. &lt;/li&gt;
&lt;li&gt;The &lt;code class=&quot; language-undefined&quot;&gt;SessionManager&lt;/code&gt; allows us to start a session for anonymous users.&lt;/li&gt;
&lt;li&gt;The &lt;code class=&quot; language-undefined&quot;&gt;CurrentUser&lt;/code&gt; allows us to check if the current user is anonymous.&lt;/li&gt;
&lt;/ul&gt;
Inside the &lt;code class=&quot; language-undefined&quot;&gt;buildForm()&lt;/code&gt; 
method we do two main things. First, we start a session for anonymous 
users if one does’t already exist. This is because without a session we 
cannot pass around temporary data across multiple requests. We use the 
session manager for this. Second, we create a base submit action button 
that will be present on all the implementing forms.&lt;br /&gt;

The &lt;code class=&quot; language-undefined&quot;&gt;saveData()&lt;/code&gt; method is 
going to be called from one or more of the implementing forms and is 
responsible with persisting the data from the temporary storage once the
 multistep process is completed. We won’t be going into the details of 
this implementation because it depends entirely on your use case (e.g. 
you can create a configuration entity from each submission). We do, 
however, handle the removal of all the items in the store once the data 
has been persisted. Keep in mind though that these types of logic checks
 should not be performed in the base class. You should defer to a 
dedicated service class as usual, or use a similar approach.&lt;br /&gt;

Now it’s time for the actual forms that will represent steps in the process. We start with the first class inside a file called &lt;code class=&quot; language-undefined&quot;&gt;MultistepOneForm.php&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot; language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * @file
 * Contains \Drupal\demo\Form\Multistep\MultistepOneForm.
 */&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;demo&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Form&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Multistep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Form&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;FormStateInterface&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MultistepOneForm&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MultistepFormBase&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}.
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getFormId&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;multistep_form_one&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}.
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buildForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; FormStateInterface &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;buildForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;textfield&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#title&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Your name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#default_value&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#title&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Your email address&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#default_value&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;actions&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;submit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#value&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Next&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;submitForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; FormStateInterface &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;email&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setRedirect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;demo.multistep_two&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This form will look something like this:&lt;br /&gt;

&lt;img alt=&quot;Drupal 8 Multistep Forms 1&quot; src=&quot;http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/05/1431093446Screen-Shot-2015-05-08-at-15.53.01.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

In the &lt;code class=&quot; language-undefined&quot;&gt;buildForm()&lt;/code&gt; method we
 are defining our two dummy form elements. Do notice that we are 
retrieving the existing form definition from the parent class first. The
 default values for these fields are set as the values found in the 
store for those keys (so that users can see the values they filled in at
 this step if they come back to it). Finally, we are changing the value 
of the action button to &lt;code class=&quot; language-undefined&quot;&gt;Next&lt;/code&gt; (to indicate that this form is not the final one). &lt;br /&gt;

In the &lt;code class=&quot; language-undefined&quot;&gt;submitForm()&lt;/code&gt; method we save the submitted values to the store and then redirect to the second form (which can be found at the route &lt;code class=&quot; language-undefined&quot;&gt;demo.multistep_two&lt;/code&gt;).
 Keep in mind that we are not doing any sort of validation here to keep 
the code light. But most use cases will call for some input validation.&lt;br /&gt;

Since we’ve touched upon the issue of routes, let’s update the route file in our &lt;code class=&quot; language-undefined&quot;&gt;demo&lt;/code&gt; module and create two new routes for our forms:&lt;br /&gt;

&lt;strong&gt;demo.routing.yml&lt;/strong&gt;:&lt;br /&gt;

&lt;pre class=&quot; language-undefined&quot;&gt;&lt;code class=&quot;language- language-undefined&quot;&gt;demo.multistep_one:
  path: &#39;/demo/multistep-one&#39;
  defaults:
    _form: &#39;\Drupal\demo\Form\Multistep\MultistepOneForm&#39;
    _title: &#39;First form&#39;
  requirements:
    _permission: &#39;access content&#39;
demo.multistep_two:
  path: &#39;/demo/multistep-two&#39;
  defaults:
    _form: &#39;\Drupal\demo\Form\Multistep\MultistepTwoForm&#39;
    _title: &#39;Second form&#39;
  requirements:
    _permission: &#39;access content&#39;&lt;/code&gt;&lt;/pre&gt;
For more information about what is going on in this file you can read one of the previous Drupal 8 articles which explain routes as well. &lt;br /&gt;

Finally, we can create our second form (inside a file called &lt;code class=&quot; language-undefined&quot;&gt;MultistepTwoForm&lt;/code&gt;):&lt;br /&gt;

&lt;pre class=&quot; language-php&quot;&gt;&lt;code class=&quot; language-php&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
 * @file
 * Contains \Drupal\demo\Form\Multistep\MultistepTwoForm.
 */&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;demo&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Form&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Multistep&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Form&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;FormStateInterface&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token package&quot;&gt;Drupal&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Core&lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;Url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MultistepTwoForm&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MultistepFormBase&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}.
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getFormId&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;multistep_form_two&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}.
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buildForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; FormStateInterface &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;buildForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;age&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;textfield&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#title&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Your age&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#default_value&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;age&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;age&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;location&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;textfield&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#title&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Your location&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#default_value&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;location&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;location&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;actions&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;previous&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#type&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;link&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#title&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Previous&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#attributes&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;token string&quot;&gt;&#39;class&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;button&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#weight&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&#39;#url&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;token scope&quot;&gt;Url&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromRoute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;demo.multistep_one&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt;/**
   * {@inheritdoc}
   */&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;submitForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;array&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; FormStateInterface &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;age&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;age&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token this&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;location&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;location&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

   &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot;&gt; // Save the data
&lt;/span&gt;    &lt;span class=&quot;token scope&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;saveData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$form_state&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setRedirect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;some_route&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This one will look like this, again very simple:&lt;br /&gt;

&lt;img alt=&quot;Drupal 8 Multistep Forms 1&quot; src=&quot;http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/05/1431093453Screen-Shot-2015-05-08-at-15.53.23.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;

Again, we are extending from our base class like we did with the 
first form. This time, however, we have different form elements and we 
are adding a new action link next to the submit button. This will allow 
users to navigate back to the first step of the form process.&lt;br /&gt;

Inside the &lt;code class=&quot; language-undefined&quot;&gt;submitForm()&lt;/code&gt; 
method we again save the values to the store and defer to the parent 
class to persist this data in any way it sees fit. We then redirect to 
whatever page we want (the route we use here is a dummy one). &lt;br /&gt;

And that is pretty much it. We should now have a working multistep form that uses the &lt;code class=&quot; language-undefined&quot;&gt;PrivateTempStore&lt;/code&gt;
 to keep data available across multiple requests. If we need more steps,
 all we have to do is create some more forms, add them in between the 
existing ones and make a couple of adjustments. Of course you can make 
this much more flexible by not hardcoding the route names in the links 
and redirects, but I leave that part up to you.&lt;br /&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;
Conclusion&lt;/h2&gt;
In this article, we looked at a simple way to create a multistep form
 in Drupal 8. You can, of course, build on this approach and create 
highly complex and dynamic processes that involve not just forms but 
also other kinds of steps that leverage cross-request data. Thus, the 
purpose of this article has been as much about multistep forms as it has
 been about illustrating the power of the &lt;code class=&quot; language-undefined&quot;&gt;PrivateTempStore&lt;/code&gt;.
  And if you, like me, think that the cTools object cache is very 
powerful in Drupal 7, you’ll be very invested in its Drupal 8 
counterpart. &lt;br /&gt;

  &lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/4208083307692271939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2015/11/how-to-build-multi-step-forms-in-drupal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/4208083307692271939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/4208083307692271939'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2015/11/how-to-build-multi-step-forms-in-drupal.html' title='How to Build Multi-step Forms in Drupal 8'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-1759090370016882733</id><published>2015-11-06T14:39:00.000+05:30</published><updated>2015-11-06T14:39:04.707+05:30</updated><title type='text'>How to embed a latest article view in your newsletter</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;ol&gt;
&lt;li&gt;Create some article nodes&lt;/li&gt;
&lt;li&gt;Install &lt;a href=&quot;http://drupal.org/project/views&quot; rel=&quot;nofollow&quot;&gt;views&lt;/a&gt; and create a view called latest_articles&lt;/li&gt;
&lt;li&gt;Activate the core module PHP filter&lt;/li&gt;
&lt;li&gt;Goto admin/newsletters/templates/mail and edit the default template (or create a new one)&lt;/li&gt;
&lt;li&gt;Choose &quot;PHP code&quot; as Text format and paste the following code in your template:&lt;br /&gt;&lt;div class=&quot;codeblock&quot;&gt;
&lt;i&gt;&lt;b&gt;&lt;code&gt;&amp;lt;?php&lt;br /&gt;$view = views_get_view(&#39;latest_articles&#39;);&lt;br /&gt;$view-&amp;gt;set_display(&#39;default&#39;);&lt;br /&gt;print $view-&amp;gt;preview();&lt;br /&gt;?&amp;gt;&lt;/code&gt;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Done: goto admin/newsletters/create-send/new and send your newsletter&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/1759090370016882733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2015/11/how-to-embed-latest-article-view-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1759090370016882733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/1759090370016882733'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2015/11/how-to-embed-latest-article-view-in.html' title='How to embed a latest article view in your newsletter'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-8585947455387072724</id><published>2014-04-05T18:47:00.004+05:30</published><updated>2014-04-05T18:47:59.341+05:30</updated><title type='text'>Drush - Drupal Command Line interface</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Drush&lt;/strong&gt;&amp;nbsp;is a command line interface that allows to manage your Drupal web sites fast and easy. This scripting shell should be additionally installed on your hosting server in order to benefit from its features.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
First, you need to have a Drupal installation under your hosting account. It can be completed in several mouse clicks through&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;cPanel -&amp;gt;&amp;nbsp;Softaculous&lt;/strong&gt;.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Second, you need&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;SSH access&lt;/strong&gt;&amp;nbsp;to your account in order to run&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Drush&lt;/strong&gt;&amp;nbsp;commands.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
In this part of the Drupal tutorial we will show how to use&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Drush&lt;/strong&gt;&amp;nbsp;in order to backup and update your script, install and activate Drupal extensions, remove them and clear the script’s cache.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
In order to create a backup of your Drupal web site with&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Drush&lt;/strong&gt;&amp;nbsp;follow the steps listed below:&lt;/div&gt;
&lt;ol style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 18px; margin: 20px 20px 10px 0px; padding: 0px 0px 0px 20px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 2px 0px;&quot;&gt;Log in your account via SSH.&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 2px 0px;&quot;&gt;Navigate to the Drupal installation’s home folder.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 2px 0px;&quot;&gt;Run the following command:&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush archive-backup –destination=/home/&lt;/em&gt;&lt;/strong&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;cPuser&lt;em style=&quot;box-sizing: border-box;&quot;&gt;/backup/site.tar.gz&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Replace the&amp;nbsp;cPuser variable with your actual cPanel user. You can pick a different location for the backup and different backup file name.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Executing the command listed above will create an archive with all the web site files and a dump of your Drupal database.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
The output will be similar to the following one:&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Drupal version &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;7.22
Site URI &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;http://default&lt;/strong&gt;
Database driver &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;mysql
Database username &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;cPuser_drup709
Database name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;cPuser_drup709
Database &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;Connected
Drupal bootstrap &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;Successful
Drupal user &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;Anonymous
Default theme &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;bartik
Administration theme &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;seven
PHP configuration &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;/usr/local/php54/lib/php.ini
Drush version &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;6.0-dev
Drush configuration &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :
Drush alias files &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :
Drupal root &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;/home/cPuser/public_html/drupal
Site path &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;sites/default
File directory path &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : &amp;nbsp;sites/default/files
Temporary file directory path:/tmp
Archive saved to /home/cPuser/backupD/site.tar.gz&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
If you need to restore a backup of your web site use the following command:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush archive-restore /home/cPuser/backup/site.tgz&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
The output will be similar to:&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Archive restored to /home/cPuser/public_html/drupal &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ok]&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
To update the Drupal application execute the following command:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush pm-update&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Checking available update data … &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[ok]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Checked available update data for Block. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[ok]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Checked available update data for one project. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[status]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Name &amp;nbsp; &amp;nbsp;Installed Version &amp;nbsp;Proposed version &amp;nbsp;Message&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Drupal &amp;nbsp;7.20 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Update available&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Update information last refreshed: Thu, 06/06/2013 – 11:18&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Update status information on all installed and enabled Drupal projects:&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Code updates will be made to drupal core.&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;WARNING: &amp;nbsp;Updating core will discard any modifications made to Drupal core files, most noteworthy among these are .htaccess and robots.txt. &amp;nbsp;If you have made any modifications to these files, please back them up before updating so that you can re-create your modifications in the updated version of the file.&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Note: Updating core can potentially break your site. It is NOT recommended to update production sites without prior testing.&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Do you really want to continue? (y/n):&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&amp;nbsp;y&lt;/strong&gt;&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Project drupal was updated successfully. Installed version is now 7.22.&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Backups were saved into the directory &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ok]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;/home/cPuser/drush-backups/cPuser_drup709/20130606113109/drupal.&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;‘all’ cache was cleared in self &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[success]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;No database updates required &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [success]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;‘all’ cache was cleared in self &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[success]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Finished performing updates. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[ok]&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
The above command will also update the plugins.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
To install a chosen plugin you should download and enable it. Check the example listed below:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush dl addtoany&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Project addtoany (7.x-4.0) downloaded to sites/all/modules/addtoany. &amp;nbsp; [success]&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush en addtoany&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;The following extensions will be enabled: addtoany&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Do you really want to continue? (y/n): y&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;addtoany was enabled successfully. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[ok]&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;addtoany defines the following permissions: administer addtoany&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Your AddToAny settings are available under Configuration &amp;gt; System &amp;nbsp; &amp;nbsp;[status] &amp;gt; AddToAny&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Instead of AddToAny you can pick a different Drupal plugin or module. The skip the&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Do you really want to continue?&lt;/em&gt;&amp;nbsp;prompt modify the command in the following way:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush en -y addtoany&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
A chosen extension can be disabled and removed with two simple commands. Check the example:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush dis -y addtoany&lt;/em&gt;&lt;/strong&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;The following extensions will be disabled: addtoany&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Do you really want to continue? (y/n): y&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;addtoany was disabled successfully. &amp;nbsp; &amp;nbsp;&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush pm-uninstall -y addtoany&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;The following modules will be uninstalled: addtoany&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Do you really want to continue? (y/n): y&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;addtoany was successfully uninstalled.&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Often the Drupal web site administrators need to clear the script’s cache. It can be easily completed with the following command:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush cache-clear all&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;‘all’ cache was cleared in self &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[success]&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
If the webmaster prefers to clear different types of cache the options can be listed:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush cache-clear&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #666666; font-size: 12px; line-height: 18px; margin-bottom: 10px; overflow: hidden; padding: 14px; white-space: normal; width: 696px; word-break: break-all;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Enter a number to choose which cache to clear.&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[0] &amp;nbsp;: &amp;nbsp;Cancel&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[1] &amp;nbsp;: &amp;nbsp;all&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[2] &amp;nbsp;: &amp;nbsp;drush&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[3] &amp;nbsp;: &amp;nbsp;theme-registry&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[4] &amp;nbsp;: &amp;nbsp;menu&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[5] &amp;nbsp;: &amp;nbsp;css-js&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[6] &amp;nbsp;: &amp;nbsp;block&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[7] &amp;nbsp;: &amp;nbsp;module-list&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[8] &amp;nbsp;: &amp;nbsp;theme-list&lt;/em&gt;
&lt;em style=&quot;box-sizing: border-box;&quot;&gt;[9] &amp;nbsp;: &amp;nbsp;registry&lt;/em&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
To get help on the&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Drush&lt;/strong&gt;&amp;nbsp;commands run the following command:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush help&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
If you want to learn how to use a specific command enter the following line in the shell:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush help&amp;nbsp;&lt;/em&gt;&lt;/strong&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;command&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Replace the “command” string with the chosen one. For example:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;drush help archive-backup&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
More about&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Drush&lt;/strong&gt;&amp;nbsp;can be found in the official documentation of the project:&amp;nbsp;&lt;a href=&quot;http://drush.ws/&quot; style=&quot;box-sizing: border-box; color: #4290c5; text-decoration: none;&quot;&gt;http://drush.ws/&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/8585947455387072724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2014/04/drush-drupal-command-line-interface.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/8585947455387072724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/8585947455387072724'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2014/04/drush-drupal-command-line-interface.html' title='Drush - Drupal Command Line interface'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-3440640776615158172</id><published>2014-04-05T18:40:00.001+05:30</published><updated>2014-04-05T18:40:19.659+05:30</updated><title type='text'>Access Control in Drupal CMS</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
The access control list in the Drupal&#39;s admin panel -&amp;gt; People -&amp;gt; Permissions is quite self-explanatory.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
There you can modify the predefined permissions for the different user types (anonymous, authenticated and administrator).&lt;/div&gt;
&lt;figure class=&quot;media&quot; style=&quot;background-color: white; border: 1px solid rgb(211, 211, 211); box-shadow: rgba(0, 0, 0, 0.0784314) 0px 3px 3px; box-sizing: border-box; color: #666666; display: inline-block; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 18px; margin: 0px 0px 20px; padding: 9px; position: relative; text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; height=&quot;300&quot; src=&quot;http://www.siteground.com/img/knox/tutorials/uploaded_images/images/drupal-tutorial/drupal7/drpl2_2.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; display: block; margin: 0px auto;&quot; width=&quot;560&quot; /&gt;&lt;/figure&gt;&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
A typical use of the access control is when you want to make some parts of your site available only for registered users. The default access control rules are quite safe, but you might want to change them to satisfy better your needs. Spend some time playing with the permissions options to better understand what you can do.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/3440640776615158172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2014/04/access-control-in-drupal-cms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/3440640776615158172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/3440640776615158172'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2014/04/access-control-in-drupal-cms.html' title='Access Control in Drupal CMS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4530028210150333092.post-195193525935289194</id><published>2014-04-05T18:39:00.001+05:30</published><updated>2014-04-05T18:39:11.869+05:30</updated><title type='text'>Using Drupal Taxonomy to Post Content</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Now that we have created the vocabulary and we have added terms to it, we can use it when posting content on the web site.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;figure class=&quot;media&quot; style=&quot;background-color: white; border: 1px solid rgb(211, 211, 211); box-shadow: rgba(0, 0, 0, 0.0784314) 0px 3px 3px; box-sizing: border-box; color: #666666; display: inline-block; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 18px; margin: 0px 0px 20px; padding: 9px; position: relative; text-align: center;&quot;&gt;&lt;img height=&quot;300&quot; src=&quot;http://www.siteground.com/img/knox/tutorials/uploaded_images/images/drupal-tutorial/drupal7/7.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; display: block; margin: 0px auto;&quot; width=&quot;560&quot; /&gt;&lt;/figure&gt;&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Note that the tags option auto completes the vocabulary field with one of the terms we have created before.If you choose terms from the vocabulary they will be displayed as tags on the page you have posted them as shown below:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;figure class=&quot;media&quot; style=&quot;background-color: white; border: 1px solid rgb(211, 211, 211); box-shadow: rgba(0, 0, 0, 0.0784314) 0px 3px 3px; box-sizing: border-box; color: #666666; display: inline-block; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 18px; margin: 0px 0px 20px; padding: 9px; position: relative; text-align: center;&quot;&gt;&lt;img height=&quot;300&quot; src=&quot;http://www.siteground.com/img/knox/tutorials/uploaded_images/images/drupal-tutorial/drupal7/8.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; display: block; margin: 0px auto;&quot; width=&quot;560&quot; /&gt;&lt;/figure&gt;&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #666666; font-family: Arial, Tahoma, sans-serif; font-size: 14px; line-height: 23px; margin-bottom: 10px;&quot;&gt;
Note that the terms presented do not indicate their underlying structure to the reader. The vocabulary just displays all terms for this content item.The Drupal taxonomy provides a great way to manage the content sorting of your web site. Those are just basic examples and you can achieve amazing results extending the taxonomy vocabularies and terms for your web site.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://drupalforme.blogspot.com/feeds/195193525935289194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://drupalforme.blogspot.com/2014/04/using-drupal-taxonomy-to-post-content.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/195193525935289194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4530028210150333092/posts/default/195193525935289194'/><link rel='alternate' type='text/html' href='http://drupalforme.blogspot.com/2014/04/using-drupal-taxonomy-to-post-content.html' title='Using Drupal Taxonomy to Post Content'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>