Automate the Little Things: ECA — Transcript
Full transcript
- 0:00and welcome to the magical world of
- 0:03events, conditions, and actions.
- 0:06Yay!
- 0:07All right. Kermit arm flails.
- 0:10Um
- 0:11this is the title slide and really
- 0:13quickly I will say
- 0:15if you have not hugged a sponsor today,
- 0:17it's probably because that would be
- 0:19awkward, but you can mentally give them
- 0:22a hug by giving them your email address,
- 0:25visiting their website, patting someone
- 0:28on the back,
- 0:29etc.
- 0:31My name is Ryan Price and I go by
- 0:34Liberator with one vowel missing on just
- 0:38about everywhere that you see
- 0:40uh screen names as long as I can get it.
- 0:43I have been doing Drupal for a real real
- 0:45long time.
- 0:47I started building websites when I was
- 0:48in high school
- 0:50for like the school newspaper and the
- 0:53photography class and stuff like that.
- 0:56So, uh I've been doing this for a
- 0:58minute.
- 0:59Uh I currently work at a place called
- 1:01ICF. We do a lot of consulting primarily
- 1:05for government contracts,
- 1:07but uh obligatory
- 1:10thing is come look us up.
- 1:12We don't always hire a lot of Drupal
- 1:14people, but we have a hire a lot of
- 1:15technologists, project managers,
- 1:18you know, soil reclamation people,
- 1:21things that the government uh the
- 1:23federal government employs. Uh come
- 1:25check us out.
- 1:27I uh like a lot of things, but mostly
- 1:30it's uh working with people in the
- 1:32community
- 1:34and bubbles.
- 1:36Um that's more ICF.
- 1:39Uh I also sometimes do this thing called
- 1:41the Drupal Easy podcast with my friend
- 1:43Mike. I was on the most recent episode,
- 1:46which is where I talk about integrating
- 1:49with a back end that we did on a pretty
- 1:51big project that's a CRM, and there's
- 1:54lots of complicated things. You could
- 1:55check this out sometime if you would
- 1:57like.
- 1:58Um the Drupal Easy podcast, when I'm not
- 2:00on it, is
- 2:01just as good, so check them all out.
- 2:05Um
- 2:06I want to talk a little bit about
- 2:08methods of improvised structures, like
- 2:12lashings.
- 2:13Um this is a raft that somebody built
- 2:15out of sticks and rope and milk jugs.
- 2:19Right? You can achieve
- 2:22boat without being a master boat
- 2:24builder.
- 2:26You can achieve code without being an
- 2:28absolute expert in writing code for
- 2:31Drupal, which can be quite complex.
- 2:35Um
- 2:36the technical definition of latching is
- 2:38to secure items together in a somewhat
- 2:40rigid manner.
- 2:43It also means that you can take things
- 2:46apart. They are non-permanent.
- 2:48It's fairly utilitarian. It's not really
- 2:51built for,
- 2:52you know, usability. It's built for
- 2:54function. It is always improvised,
- 2:58and it takes advantage of reusable
- 3:01materials. The pieces I could use to
- 3:03build one lashing, I could take apart
- 3:04and I could build a completely different
- 3:06structure the next day.
- 3:08And there is a method to it. There's
- 3:09there's good ways and bad ways of doing
- 3:11it, and there's um
- 3:14sort of like, you know, best practices
- 3:16that can be learned when you're when
- 3:18you're doing this kind of improvised
- 3:20um structures,
- 3:22and you can,
- 3:24you know, gain that knowledge by talking
- 3:26to other people, inspecting what other
- 3:28people have built.
- 3:30On the other hand, there is other means
- 3:32of doing improvised construction like
- 3:34duct tape. These are the kinds of
- 3:36improvisations that we don't like
- 3:39because they create technical debt.
- 3:42At some point in the future, a person is
- 3:44going to have to come back and replace
- 3:46this
- 3:48fix.
- 3:49Um it's not going to last forever. It's
- 3:51going to leave sticky residue behind and
- 3:53it's going to cause problems even if it
- 3:55solves one today.
- 3:57It's not built in an in a
- 4:01a reversible way, right?
- 4:05Um duct tape, non-permanent, it's still
- 4:08utilitarian, it's still improvised, but
- 4:09it does not use reusable materials and
- 4:12it is not often methodical.
- 4:14Sometimes it can be methodical,
- 4:17but these things are more like novelties
- 4:19than an actual camera case that you
- 4:21would use every day.
- 4:23It's fun. It might get you a lot of
- 4:25comments at parties.
- 4:27Um
- 4:28but you're not going to mass produce
- 4:29these things either, right?
- 4:32Um ECA is the lashing
- 4:34and I would say um custom code is a
- 4:37little bit more like
- 4:39a manufactured product that does
- 4:41something pretty well.
- 4:43Um
- 4:44but it doesn't have those disassemblable
- 4:46pieces.
- 4:47Right?
- 4:48ECA is like this version of the tripod
- 4:52instead of this version of the tripod.
- 4:56Um we haven't really talked about what
- 4:57ECA is, but I feel like you must know a
- 4:58little bit about it if you're in this
- 5:00room.
- 5:01Um
- 5:02the idea of ECA is you are trying to
- 5:06describe the thing that you would like
- 5:08to happen rather than explicitly state
- 5:10it.
- 5:12Um so this is the building a sandwich
- 5:13argument. Um I shouldn't have to tell
- 5:15you all the steps on how to build a
- 5:17sandwich in order to just say, "Please
- 5:19give me a sandwich."
- 5:21It's a little bit more maintainable to
- 5:23have something like this because
- 5:27while it can take a little bit of time
- 5:28to learn how to create it and integrate
- 5:31it into your systems,
- 5:34if Drupal goes from Drupal 11 to Drupal
- 5:3712,
- 5:38if the uh you know, email module that
- 5:41you're using goes from version two to
- 5:42version three and something about that
- 5:44underlying API changes,
- 5:46your ECA models probably don't care that
- 5:50the underlying modules are getting
- 5:51upgraded
- 5:53as long as the model can still be
- 5:55imported into your site,
- 5:58it will continue to work. It is
- 6:01resilient to change
- 6:03in a way that normal code may not be.
- 6:07And there is something that I call the
- 6:09phone loophole, which is
- 6:11even if you are not the one who created
- 6:14one of these business logic rules, I
- 6:17might be able to
- 6:19walk you through fixing it on the
- 6:20telephone, but
- 6:23usually if you're trying to debug
- 6:24something in a code editor, and I can't
- 6:27see the editor, and I can't tell you
- 6:29line numbers, and I can't tell you
- 6:30exactly what function names and variable
- 6:33names there were,
- 6:35I I'm not able to talk you through
- 6:37fixing that over the phone, but in ECA,
- 6:40there's shapes, there's words, there's
- 6:43sort of self-documenting bits in there
- 6:46that would allow me, let's say that
- 6:48there's very quickly I've realized my
- 6:51email is getting sent to the wrong email
- 6:53address,
- 6:54and I'm on vacation with my family, but
- 6:58man, I really need you to fix that email
- 6:59address right now.
- 7:01I could probably talk you through
- 7:02changing the email address over the
- 7:04phone.
- 7:05Whereas inside of code, well, now we got
- 7:07to do a deployment, we got to run it
- 7:09through the linter, and we got to run it
- 7:11through the, you know, CI/CD system.
- 7:15That's not something that I can
- 7:17easily walk somebody through.
- 7:21And yeah, changing business logic
- 7:23without a deploy, you just get exactly
- 7:25the thing that you need, you hit the
- 7:27save button, and you move on with your
- 7:29life, and um
- 7:32you know, in order to get ECA to work in
- 7:34a production context, there's going to
- 7:37be some other tricks that we have to
- 7:38employ in order to make that a little
- 7:41bit easier, and we'll talk about those
- 7:42at the end.
- 7:45Uh
- 7:46I feel like I wrote this presentation,
- 7:49and now that I got here, I'm like, I
- 7:50feel like I've already made the case to
- 7:51you about why is EC ECA cool?
- 7:54But um I'll I'll say these things
- 7:56anyway.
- 7:57Drupal, the whole point of why are we
- 7:59using Drupal as a CMS
- 8:02instead of creating our own custom
- 8:03software is because we care about the
- 8:05functionality more than the purity of
- 8:08the code, right? There is lots
- 8:10underlying good things about the way
- 8:12that Drupal is architected, but if we
- 8:14could build it from scratch,
- 8:16would we include, you know, so many
- 8:19different ways to send an email? No, of
- 8:22course we wouldn't. That would be a lot
- 8:24of duplication of work. But because
- 8:25we're working with open source,
- 8:27um we're just going to focus on the
- 8:28features that we need for the project
- 8:30that's in front of us.
- 8:32Um you know, Dries is famous for saying
- 8:35that uh Drupal is about using the
- 8:36internet to eliminate the middle man.
- 8:39And that's I think something that uh
- 8:41custom business logic that is written
- 8:43without code can help you get there.
- 8:46Um the programmer is like one of those
- 8:48middle men.
- 8:49And um you know, not knowing how to code
- 8:52can be as bad as just having a really uh
- 8:55gatekeepery developer who doesn't want
- 8:58to allow you to make changes to things.
- 9:00So, I believe it is possible
- 9:02um for clients to demand, you know,
- 9:05low-code and no-code solutions to some
- 9:08of their problems, maybe not all.
- 9:10Or it is possible for programmers to go
- 9:13to their clients and say, you will
- 9:15reduce your maintenance burden
- 9:18by having me
- 9:19spend this time working on business
- 9:23logic in ECA versus business logic
- 9:26that's baked into a code that we must
- 9:27deploy in order to change.
- 9:31That's the
- 9:32theory part. This is the more practical
- 9:35part.
- 9:36So, uh we're going to go through a
- 9:37couple steps with ECA models. We're
- 9:38going to take one apart. We're going to
- 9:40modify one. We're going to build a new
- 9:42one.
- 9:42We're going to take something that folds
- 9:45several ECA actions together. And then
- 9:48we're going to talk about also fun ways
- 9:50that you can trigger models
- 9:52inside of your site.
- 9:54So, the deconstruct step. What do I mean
- 9:57by deconstruct? It's not to actually
- 9:59take down the Rube Goldberg machine into
- 10:01its principal parts, but
- 10:04instead to talk about what the principal
- 10:06parts are good for and try to be able to
- 10:08recognize that there's a tube structure
- 10:11followed by a tube structure followed by
- 10:13a tube structure followed by some
- 10:15dominoes followed by a can that's going
- 10:16to hit the next piece that's falling
- 10:18down the table, right?
- 10:21So, how do we do that with an ECA model?
- 10:23This is a
- 10:25medium complexity ECA model
- 10:27and it
- 10:29has some distinct parts.
- 10:32You can see on the far left side over
- 10:35there.
- 10:36Those little circles are what we call
- 10:38the events. And it's sort of if you were
- 10:41going to read this in English, you could
- 10:43say when this event happens
- 10:45and then you see number two, if this
- 10:47condition is met
- 10:48then number three, do one of these
- 10:50things.
- 10:52Um
- 10:53in this particular case, the the events
- 10:56are what if a node gets inserted or a
- 10:58node gets updated.
- 11:00After we do that, we have to do a little
- 11:02bit of setup.
- 11:03But then on step two there, you see
- 11:06there's some question marks inside of
- 11:09this little box. And so that means
- 11:12I'm going to try to make a decision at
- 11:14this point and I'm either going to go in
- 11:16one direction or I'm going to go in the
- 11:17other direction and then I'm going to do
- 11:18some some activities.
- 11:20Um
- 11:23All of the things you see in ECA, these
- 11:24little shapes kind of do have a meaning.
- 11:28Um the one that you will only use at
- 11:30very certain special times is this
- 11:32little diamond. It's really kind of like
- 11:34a connector between other pieces, but it
- 11:36doesn't have any functionality in and of
- 11:38itself.
- 11:40Um the most The thing you'll be using
- 11:42the most is these circles and these
- 11:43squares, and these are events and these
- 11:44are actions.
- 11:46And all all the context that starts on
- 11:49one side
- 11:50moves down the chain, and everything
- 11:52that this event knew about, this action
- 11:55can act on, and this action can act on,
- 11:57and this action can act on.
- 11:59And they all pass their properties along
- 12:02the further to the right you go. And
- 12:06we kind of organize left to right
- 12:08partially because we're left to right
- 12:09language speakers,
- 12:10but you could do top to bottom, you
- 12:12could do other sorts of um
- 12:15workflows here. It's not really set in
- 12:17stone like that.
- 12:19So, uh some other examples, if you're
- 12:21asking about event, what's an event?
- 12:22Before I leave for work, condition is if
- 12:25there are dark clouds in the sky, the
- 12:27action would be bring the umbrella from
- 12:28the hall.
- 12:30Right?
- 12:31And then another event could be after I
- 12:33leave for work, if today is not Friday,
- 12:36and if the time is before 8:45, get out
- 12:39my credit card and purchase coffee.
- 12:42Right?
- 12:43These could be a way of thinking about
- 12:46things that you have to do. So, my my
- 12:49recommendation before you just start
- 12:51diving into ECA is
- 12:53think about some of the steps and some
- 12:55of the information you're going to have
- 12:57to collect before you ever start
- 13:00clicking on mouse buttons. Um if you're
- 13:02just learning, you know, have fun, play
- 13:05around,
- 13:06dive into the sandbox, but when you
- 13:08start doing this in a more real way, if
- 13:11you don't know all the pieces and parts
- 13:13you're going to need,
- 13:14it could lead to frustration.
- 13:17Um here's an example of an ECA model
- 13:19that says, "After 20 minutes of
- 13:21inactivity, remind the user that their
- 13:23shopping cart is empty." And so, the
- 13:27event in this case is an order update
- 13:30event, and that event can get fired by
- 13:34basically a cron job.
- 13:36And then, the cron job can say, "All
- 13:38right, I now am going to be acting on a
- 13:40particular order.
- 13:42I'm going to then look inside of the
- 13:45order items, which in this case is the
- 13:48name of a Drupal field,
- 13:50and I'm going to load all the
- 13:52information from that order items into a
- 13:55variable,
- 13:56and then, um where did I get that field?
- 13:59The field was a field on this commerce
- 14:03order entity.
- 14:05So, you'll see these kind of screens and
- 14:07sidebars all over ECA,
- 14:09and learning how to read their
- 14:11structure,
- 14:12um sometimes, in order to make the thing
- 14:14at the top make sense, you have to go
- 14:16all the way to the bottom of the form to
- 14:17fill out some field, and then kind of
- 14:19come back at the top.
- 14:20Um this is not a wizard. It's not asking
- 14:24you like for all the steps that you're
- 14:25going to need in between.
- 14:28But, um there usually pretty decent
- 14:30documentation about what each field is
- 14:32supposed to do.
- 14:34So, um it's it's not super hard to
- 14:38uh figure out. Once you Once you've
- 14:40built a handful of models, these things
- 14:42start making a lot more sense. So, it's
- 14:45one reason why I think coming to a
- 14:46session can can help you
- 14:48learn something like this.
- 14:50Um other things we can do is we can
- 14:52actually modify an existing
- 14:54ECA
- 14:56model, and
- 14:58um you might see
- 15:00a when I'm building a user profile form,
- 15:02a whole bunch of conditions.
- 15:05Well, I'm not really sure what is all
- 15:06going on here, but I know that the
- 15:08message is wrong. I know I need to
- 15:10modify this message. This is what I was
- 15:11saying. This is something I could talk
- 15:12you through over the phone. Not creating
- 15:14a brand new ECA model from scratch, but
- 15:16just click on that thing that says
- 15:18display message, type some different
- 15:20text in the text box, make sure you
- 15:22leave all the things inside of square
- 15:23brackets where they were and then hit
- 15:25save.
- 15:26You have now officially saved a change
- 15:29to an ECA model.
- 15:32Um so, let's show you what one actually
- 15:34looks like. I'm going to get out of
- 15:36this.
- 15:38And we're going to go over here. So,
- 15:39this is our ECA
- 15:41um administration screen.
- 15:43Um
- 15:44you can see at the top we have the
- 15:46ability to add a new model. So, when you
- 15:48very first load this up,
- 15:50you know, there are no models by default
- 15:52in ECA unless you've already imported
- 15:54them using like a recipe or another
- 15:56module or something like that.
- 15:58Um
- 16:00then you can see your models and you can
- 16:01see a list of events which this model
- 16:04reacts to.
- 16:06So, this one says here views bulk
- 16:09operations. We'll talk about that in a
- 16:10minute. This one says when someone
- 16:12inserts a new entity.
- 16:14This is when somebody logs in.
- 16:17And this is when somebody updates an
- 16:18entity. And then these are a thing that
- 16:20are called custom event and we'll again
- 16:22talk about those in a little bit.
- 16:24Um but you can get a real quick overview
- 16:26here of
- 16:28what these models are all intended to
- 16:29do. You can give them version numbers.
- 16:32This matters if you
- 16:34are going to be tracking these things
- 16:36over time. That can probably help. Um
- 16:39just like you would do, let's say, with
- 16:40the revision log message on your nodes,
- 16:43you might want to update the version
- 16:45number to give yourself a clue of like,
- 16:47"Okay, well, on, you know, the the
- 16:49French site we're on version 1.1 and on
- 16:52the English site we're on version 1.2.
- 16:54So, there's clearly something different
- 16:56before I go modify one of these things."
- 16:58And then you can enable and disable
- 17:00them.
- 17:01And um
- 17:02some other really cool bits in here of
- 17:03like, you can clone something, so you
- 17:05can make a copy and then you can modify
- 17:07the copy, play around with that a little
- 17:09bit,
- 17:10and either make a brand new model or
- 17:12disable the old one to keep it around
- 17:15while you're playing around with the new
- 17:16one.
- 17:17Um export them. They're very very easy
- 17:19to export from one site to another.
- 17:21And
- 17:22if you are into building recipes, if you
- 17:24went to the other sessions about
- 17:26building recipes, they're really really
- 17:28easy to integrate into recipes. This
- 17:31button I think is probably still
- 17:33not like 100% of what one might wish
- 17:36when they see a thing that says export
- 17:38as recipe, but
- 17:40it The difference between export and
- 17:42export as recipe right now, as of today,
- 17:44is pretty similar
- 17:47as far as what's the end product, what
- 17:49you get. But it it is a a bundle, a
- 17:51little tar file that contains
- 17:55all of the XML and all of the YAML that
- 17:58is needed in order to
- 18:00create this model on some other site or
- 18:03check it into your code repository if
- 18:05that's what you need to do.
- 18:07And delete. So, that's a little tour of
- 18:10the admin screen, but let's go ahead and
- 18:12I'm going to talk a little bit about
- 18:14what this site is, my demo site here.
- 18:17This is
- 18:19a Pacific Northwest Drupal Meetup
- 18:21directory site. And so, we have
- 18:25some groups in here. Where are my
- 18:27groups?
- 18:28Groups.
- 18:30These are my groups. I have a group for
- 18:31Seattle, a group for Portland, and a
- 18:33group for Vancouver.
- 18:35If you don't know groups,
- 18:36users can become a member of a group
- 18:39and by becoming a member of a group, you
- 18:41can get permissions over some of the
- 18:44content and activities that are related
- 18:46to that group if you're a member versus
- 18:47not being a member. It's going to be
- 18:49important in a second.
- 18:51And then finally,
- 18:53for an individual group, you can also
- 18:55attach pieces of content. So, I might
- 18:58look under Seattle and look at nodes,
- 19:01and I should see at least one node.
- 19:04Seattle meetups are both virtual and in
- 19:06person. There's my article that's about
- 19:08that.
- 19:10If I look at this
- 19:12node here and I edit it,
- 19:15um, I have also set up a group field so
- 19:18that I can see that this belongs to a
- 19:20group and, um, just to get started I'm
- 19:22going to go ahead and I'm going to
- 19:23remove this from the Seattle group so I
- 19:26can show off
- 19:27a model that I made.
- 19:30Um,
- 19:32we'll come right back to this in a
- 19:33second.
- 19:35So, I'm going to go to my content
- 19:39screen.
- 19:41I have made a special view on my site
- 19:44that shows me all my content and then
- 19:47whether or not it belongs to a group.
- 19:49Oh, that's funny. I feel like this one
- 19:51should say Vancouver, but maybe I've
- 19:52already deleted it from Vancouver.
- 19:54Let's check.
- 19:58Okay, this is not currently in any
- 19:59groups. Okay, so currently no content is
- 20:01in a group because this meetup field is
- 20:04blank. So, I'll show you really quick. I
- 20:06want to be able to add this content to
- 20:08Vancouver.
- 20:10And this looks exactly like regular
- 20:12views bulk operations, but this is
- 20:13actually special ECA only views bulk
- 20:16operations. Um, this is something that I
- 20:19hope will get fixed at some point in the
- 20:20future is that the ECA version of views
- 20:23bulk operations will be compatible with
- 20:26the regular one. Right now,
- 20:28if you want to do this, you kind of have
- 20:29to have two separate screens.
- 20:31Um, but this was a a case that I
- 20:33actually came across in a real client
- 20:35project was
- 20:37there was no action inside of the little
- 20:40drop down to say add to group, remove
- 20:43from group,
- 20:44um,
- 20:45for for the groups module. And rather
- 20:48than sit down and write custom code, I
- 20:50said, "Well, I would love to learn more
- 20:52about ECA.
- 20:54I'm going to check this out." So, you
- 20:56can make, uh, these little special
- 20:57actions and I can hit apply
- 21:00and then it asks you, "Are you sure?"
- 21:02Just like a regular VBO. And then now it
- 21:05says, "Your content belongs to
- 21:07Vancouver, right? And same thing with
- 21:10Seattle.
- 21:11You hit apply. You say that's okay.
- 21:14And you're now your content belongs to
- 21:15Seattle, but the problem on my side is
- 21:18I don't have one for Portland.
- 21:20Is this big enough? Can we make it
- 21:22bigger?
- 21:23Bigger would be good. Okay.
- 21:30Better?
- 21:31Yeah. Okay. Only two options.
- 21:33Seattle, Vancouver, so we're going to
- 21:35We're going to fix that.
- 21:39Um I'm going to go to, sorry, workflow.
- 21:43Under configuration workflow ECA.
- 21:46And to start, I'm going to
- 21:49clone my Seattle model.
- 21:52And then I'm going to edit the clone.
- 21:54And the first thing we're going to do is
- 21:55go up to this sidebar under the general
- 21:57tab. And we don't have anything
- 21:59selected, right? As soon as I select
- 22:01something, this sidebar is contextual.
- 22:03It'll show whatever I've just clicked
- 22:05But to start, I want to give this thing
- 22:07a meaningful name. And I don't want it
- 22:09to be called add to Seattle clone. I
- 22:11want it to be called
- 22:13add to Portland.
- 22:18Um these little ID fields, they all get
- 22:21random uh letters and numbers and
- 22:23characters in them.
- 22:26If you watch Jürgen, who's the creator
- 22:28of ECA, um do his screencasts,
- 22:31you will see him typing meaningful names
- 22:33into these.
- 22:35I think this is a personal preference
- 22:36thing.
- 22:37I have done it, and it actually, in my
- 22:39opinion, makes
- 22:40these things easier to use, particularly
- 22:43once you get them out of Drupal into the
- 22:45XML files.
- 22:47Um so, my recommendation is
- 22:51if you are the kind of person who likes
- 22:53to wipe down your shower after you take
- 22:56a shower,
- 22:58use this field. If you're the kind of
- 23:00person who leaves your towels on the
- 23:01floor,
- 23:02just hit save.
- 23:04Right?
- 23:06Um
- 23:08this I can give this a version number if
- 23:10I would like. I can say this is an
- 23:11active and executable. And I can
- 23:13actually add extra documentation like
- 23:16created for PMW
- 23:19summit
- 23:20presentation, right?
- 23:23Whatever we're going to say here.
- 23:25Um a lot of times down here you see this
- 23:27thing extension properties.
- 23:29I have not used this a lot.
- 23:31This tool is actually a tool that's
- 23:34called BPMN or business process modeling
- 23:37notation.
- 23:39And as far as I understand it was
- 23:40originally created to map out activities
- 23:44that would be carried out in fact
- 23:46factories or like supply chain
- 23:48activities
- 23:49to show how goods and services move
- 23:52through a process.
- 23:54But you can just as easily use it to
- 23:56have data and objects move through a
- 24:00process
- 24:01as long as you trigger them correctly.
- 24:03Um and the the language itself comes out
- 24:07as XML.
- 24:09And that XML is portable to other kinds
- 24:11of languages, but because this is very
- 24:15very Drupal-y,
- 24:16you can't just go interpret them
- 24:18somewhere else. You could edit them in
- 24:19other places, but you'd be missing some
- 24:21of the Drupal stuff like the token
- 24:24browser.
- 24:25Right?
- 24:26If you've seen this before, you know
- 24:28what it is.
- 24:29Um
- 24:30so having this
- 24:32editor inside your Drupal site, it's
- 24:34completely free. It It while it is
- 24:36branded, this does not require you to
- 24:39have a membership or an API key or
- 24:41anything. You can do 100% of this inside
- 24:43your Drupal site.
- 24:44But there are other editors that will
- 24:47edit BPMN for you if you need them for
- 24:49some reason.
- 24:51Um and so the way that this works is as
- 24:55I click on one of these things, I can
- 24:57move it around
- 24:58and the arrows will follow me.
- 25:01If I don't want those arrows anymore,
- 25:03I can hit the little trash can and they
- 25:05go away.
- 25:07If I want to bring them back, I can hit
- 25:09the arrow and I can click on something.
- 25:11If you are clicked on a box and you just
- 25:14click on another box,
- 25:16it assumes that you want those to to be
- 25:18connected already.
- 25:20So, um it's pretty useful like that.
- 25:23And then um some other things you can do
- 25:25is if you click on one of these things,
- 25:26there's this little dash line.
- 25:29This is just for a little bit of
- 25:30documentation
- 25:31to say,
- 25:32you know, um my
- 25:35first
- 25:37model. And you can just leave yourself
- 25:40some documentation inside of of these
- 25:42models to let you know what's going on.
- 25:46Uh
- 25:46that's pretty much a good tour. So,
- 25:48let's talk about what this model
- 25:49specifically does.
- 25:51Um you saw the end product, which was a
- 25:54creates a drop-down inside of a Views
- 25:56Bulk Operation. In order to get there, I
- 25:59need to have an event.
- 26:01So, what event is that going to be?
- 26:05We're going to use a template. And right
- 26:07now what I'm going to do, I'm going to
- 26:08unlink the template. And I'm probably
- 26:09going to just open up
- 26:11my um other model in a separate tab
- 26:15so we can refer back to it.
- 26:17So, we'll we'll pretend we're going to
- 26:19um
- 26:20edit this again. So, this this model
- 26:22here, I'm going to get rid of you. Thank
- 26:24you.
- 26:25Thank you for your service. Okay.
- 26:27Um
- 26:29what what event do I want to use? I
- 26:31always need to go to this template well.
- 26:34This is the the workflow of ECA as it
- 26:38stands right now is
- 26:40I know I need an event and actually I
- 26:41can, if I want,
- 26:44put all of the circles and boxes and
- 26:46diamonds that I need and all the arrows
- 26:48that I need without ever having to dive
- 26:51into the sidebar, right? I can visually
- 26:54map it out as I've sketched it on paper,
- 26:56I can sketch it in this tool to make
- 26:59sure the workflow is what I need it to
- 27:00be,
- 27:02and reason about it while it's here on
- 27:04the screen before I ever really start
- 27:07configuring stuff.
- 27:09And uh
- 27:10I do, again,
- 27:12this may be a personality dependent.
- 27:15I would recommend that you do this. I
- 27:17realize that certain brain types might
- 27:20want to work in a different way. They
- 27:22might want to work from right to left.
- 27:23They might want to
- 27:25get the leftmost one and the rightmost
- 27:26one and leave a bunch of question marks
- 27:28in the middle. You know, there's not
- 27:29really a wrong way to eat a Reese's in
- 27:31this case.
- 27:34So, um again, clicking on the event
- 27:37and then we're going to pull up the
- 27:38template. This dialogue here
- 27:40contains a lot of things.
- 27:43It also will contain new things as you
- 27:45add new capabilities to ECA.
- 27:48So, um
- 27:50this is one reason why I say getting
- 27:52your getting your thoughts organized
- 27:53before you dive in here,
- 27:55um you could very easily,
- 27:58you know, uh pick something that sounds
- 27:59good and it's not the one that you need.
- 28:01So, doing a little bit of homework
- 28:03on um the ECA guide, we'll show in a
- 28:05minute,
- 28:06is probably going to get you pretty far.
- 28:08So, in this case, I know that this is
- 28:11VBO
- 28:12and I know that this is execute a views
- 28:15bulk operation, but then you see here
- 28:17there's two different ones. One of them
- 28:19says multiple at once and one of them
- 28:21says one by one.
- 28:23In my experience, one by one is the one
- 28:25you want.
- 28:27But now, it's going to ask me some more
- 28:29questions. It's going to say, "Hey,
- 28:32uh what is what is your VBO called?"
- 28:35This is kind of particular to the action
- 28:37that I'm in right now, but
- 28:38when we were looking at the
- 28:41I'm also going to pull up my screen
- 28:42really quick. Give me a second here.
- 28:44Come to.
- 28:45All right. When I was looking at this
- 28:47screen,
- 28:49this box down here contains some words,
- 28:53and we have add content to Vancouver,
- 28:55add content to Seattle. So, in this case
- 28:57then I'm going to say
- 29:00add content to Portland.
- 29:03Right?
- 29:08And then, do you want to have this show
- 29:11up only on a certain view or a certain
- 29:13view display? You can restrict that in
- 29:14this case, but
- 29:16I don't need that.
- 29:17Um I'm going to connect that to the
- 29:20action,
- 29:21which I have named add content to
- 29:23Seattle.
- 29:24And again, uh we can remove this link,
- 29:27and then we'll add it right back again.
- 29:29So,
- 29:31whenever this action whenever this event
- 29:33fires, the following action will do
- 29:34something.
- 29:35Add content to Seattle. What am I going
- 29:37to do with it?
- 29:38I'm going to group,
- 29:41and then it is uh group add content
- 29:45node.
- 29:46And then it's going to ask you a bunch
- 29:48of questions.
- 29:50Which type of group content is this? Is
- 29:52it articles? Is it basic pages? Or is it
- 29:55any kind of content?
- 29:57What's the group ID?
- 30:00This is currently in this exact case
- 30:04one of the sticky parts, but in this
- 30:06case I just have to know
- 30:08that the Portland group is got a certain
- 30:11ID, which I have to go find.
- 30:14Um
- 30:15Where's that little GR thing?
- 30:18Hello group. Where are you? Portland.
- 30:21Portland is number two.
- 30:23So, we're going to type two in this box.
- 30:25That's all I need to do
- 30:27um pretty much is
- 30:29that is group ID number two. What is the
- 30:31ID of the entity that I would like to
- 30:33add
- 30:35to the group?
- 30:36I'm going to get that from my context.
- 30:38So, where's my context? Back here
- 30:40on my event.
- 30:42If you look under
- 30:44the template right here, after you click
- 30:47this button to to apply the template,
- 30:50now it's going to give you a little bit
- 30:51of a description.
- 30:53And almost always it's going to name
- 30:55some tokens in this list. So, it says
- 30:57here, event, the event, session user,
- 31:00the user that dispatched the event,
- 31:03entity, the entity of the event,
- 31:06and then entity type is the entity of
- 31:09the event.
- 31:11An entity of the event under the name of
- 31:13its entity type.
- 31:15We might be able to work on this
- 31:16documentation.
- 31:18Um but you see there's a bunch of
- 31:20different tokens that are available and
- 31:22they all have these little square
- 31:23brackets.
- 31:24The one that I'm looking for here is
- 31:26this thing, entity.
- 31:28Okay, so I'm going to grab that and then
- 31:30come back
- 31:31to my action and I'm going to say, what
- 31:33is the entity ID? That's not what I was
- 31:36trying to do.
- 31:41All right, I just know that's a square
- 31:42bracket entity. That's not very hard.
- 31:47Okay.
- 31:48This This is the entity that I want and
- 31:50just real quick I'm going to go check my
- 31:52example to make sure I did this the
- 31:53right way.
- 31:55Oh, I did this the wrong way. It's got
- 31:56to be down here.
- 31:58All right, excuse me.
- 32:00Um
- 32:02I don't know why this one versus this
- 32:04one, but it's different.
- 32:10How did I get here? Trial and error.
- 32:13Um That's not the same token.
- 32:16I think you're on the wrong path. Did it
- 32:17have more things?
- 32:19Event. Oh, event entity? In this case,
- 32:22event entity and entity are equivalent.
- 32:24Okay.
- 32:26But good eye. Thank you. Only from
- 32:29troubleshooting all my EC2 instances and
- 32:31going like, wait, I still don't have it.
- 32:32Yeah.
- 32:33Um there's this little box down here
- 32:35that says replace tokens.
- 32:37Nine times out of 10, do not check this
- 32:39box.
- 32:40If you're sending an email, you may need
- 32:42to check this box in my experience,
- 32:45but start with this box off.
- 32:48If it doesn't work,
- 32:49try it on.
- 32:51That's That's what I say.
- 32:53Um and then there's this last thing here
- 32:56which says um group content value. So, I
- 32:58think we do have to put something in
- 32:59there.
- 33:01Uh in this case, no, we don't.
- 33:04That's in a different box. Okay.
- 33:06So, in this case, the the top line of
- 33:08this is very very simple.
- 33:09Get an action, give it a a name, and
- 33:12you'll learn in a second this name is
- 33:13actually very important.
- 33:15And then um figure out what I want to
- 33:18act on, which group do I want to act on,
- 33:21and then this is basically just pass
- 33:23through.
- 33:24There's nothing really to to do in this
- 33:26case.
- 33:27Um so, this is this is the action
- 33:30itself,
- 33:31but the problem with Drupal is
- 33:35What happened?
- 33:36Oh, I'm in Okay, this this place.
- 33:39The problem with Drupal is Drupal has
- 33:41permissions.
- 33:43So, just because I've stated I would
- 33:46like this action to appear,
- 33:48because it's Views Bulk Operations,
- 33:50Views Bulk Operations has to have an
- 33:51access check.
- 33:53I'm going to walk through this a little
- 33:53bit faster, but there is a particular
- 33:57event that you can do that says Views
- 33:59Bulk Operations access check. You have
- 34:01to do this in certain cases with with
- 34:03ECAs of
- 34:05There's one one event that feeds another
- 34:07event. There's one event that decorates
- 34:09another event. There's one event that
- 34:12chains onto another event.
- 34:14Um
- 34:15So, this is special thing called uh VBO
- 34:18access.
- 34:19And um
- 34:21in order to make this work, I have to
- 34:22have the exact same name here. So, right
- 34:24now it says Seattle, I need it to say
- 34:25Portland.
- 34:29Come back.
- 34:30Can't see you.
- 34:33Okay, great.
- 34:34That's super fun. All right, add count
- 34:36to Portland. These those two need to be
- 34:38exactly the same or it won't work.
- 34:40After that, I'm going to do an action
- 34:42called get current user. You don't
- 34:43always have to do this,
- 34:45but I think just in my debugging state,
- 34:48I had this in here and I didn't take it
- 34:50away.
- 34:51So, current user is
- 34:54can be either the user who clicked the
- 34:56button or the user who's logged in right
- 34:58now, or you can define some other user
- 35:00if you need to. Um the user who is the
- 35:02author of the node that you care about
- 35:04for some reason, right?
- 35:06So,
- 35:07there's a good There's a good
- 35:08distinction, right?
- 35:10Am I trying to get
- 35:12the permission based on the author of
- 35:14the node, or am I trying to get the
- 35:15permission based on the user who's
- 35:17logged in right now? In this case,
- 35:19the user I care about is the user who's
- 35:21looking at this view. So, I mean the
- 35:23user who's logged in.
- 35:25But, deciding which user you want inside
- 35:27of an ECA can be
- 35:29part of the battle here, right?
- 35:33Um get the current user. Now, I'm going
- 35:36to load the groups from that user.
- 35:38And again, this is something that is a
- 35:39little bit sticky because
- 35:41when I get this group relationship, I
- 35:43need to say that it's a group
- 35:44relationship, and
- 35:47I need to very specifically say
- 35:50I need it to be a group relationship of
- 35:52the type meetup,
- 35:54and I need to say for you people that
- 35:57are part of group number two.
- 36:00If I don't have this in here, it will
- 36:02not appear. So,
- 36:03um this particular one, if you have more
- 36:05than three or four or five groups on
- 36:07your site,
- 36:09this is going to get
- 36:11exponentially harder as you add more
- 36:13groups if you let people create as many
- 36:15groups as possible. If you only have
- 36:16five groups on your site and you have,
- 36:18you know, the library group, the finance
- 36:21group, and the uh math group,
- 36:24just adding a couple of things like this
- 36:26is not going to be that hard.
- 36:28Um but but the way this is right now, it
- 36:31probably would be better as a custom
- 36:32module because I have to keep plugging
- 36:33these ID numbers in.
- 36:36Hard kind of hard coding them, right?
- 36:39Um
- 36:40the last step is
- 36:42grant access. When you do this grant
- 36:44access, you just have to say yes.
- 36:46Um in the middle here,
- 36:49there's one more thing we have to do,
- 36:51but I'm going to go ahead and save just
- 36:52to show you what I'm talking about
- 36:55because I feel like I've been talking a
- 36:56lot
- 36:57without showing you that
- 37:00I think I'm going to flush the cache.
- 37:04Come back.
- 37:13In my experience with with the views
- 37:14based one, I had to flush the cache.
- 37:20And did I forget to save at the top? I
- 37:22noticed the box at the top still says
- 37:24channel. Is that maybe
- 37:30Uh this part this one here this doesn't
- 37:32really matter.
- 37:34But um
- 37:36It still has that same activity ID that
- 37:39you made to the VBO ad sale.
- 37:45Which one? This one? Yeah. Yeah. So is
- 37:48that because you customized it in your
- 37:49other one and so now it's not working?
- 37:51Yeah. I don't I again I don't think this
- 37:54is matters in this case.
- 37:56Um but yes, this was one I was playing
- 37:58around with seeing if the names would
- 38:00actually conflict with each other.
- 38:02I don't think they conflict with each
- 38:03other. I think this is name spaced
- 38:05inside of the individual model. I don't
- 38:07think they reach to other models.
- 38:09So I can really call this anything I
- 38:11want.
- 38:14But in this case this this um this
- 38:17circle here has to have the exact same
- 38:19string
- 38:21as this circle here
- 38:23or they will not talk to each other. And
- 38:25save.
- 38:26Go back over here.
- 38:28Let's flush our cache one more time.
- 38:32And then we're going to reload. We're
- 38:34going to hope that it works.
- 38:37Okay, there's one other thing that's
- 38:37possible, which is
- 38:39I could not be a member of the Portland
- 38:41group, but as there's only one user on
- 38:43my site, I don't think that's the case.
- 38:46We're going to check.
- 38:49Portland
- 38:51We're going to go to members.
- 38:56Yeah, I mean, I'm I'm a member, right?
- 38:57There's only me. So,
- 38:59should work.
- 39:03I did this with Vancouver and Seattle
- 39:05already.
- 39:08Well,
- 39:09this is awesome.
- 39:11Live demos. I can't add it to Portland.
- 39:14I can't add it to Portland. I've done
- 39:15all the right steps.
- 39:17There's probably something small
- 39:20that we're missing out.
- 39:23All right, anyway, the last little bit
- 39:24of this
- 39:26after I loaded the user and I say yes, I
- 39:27want to grant
- 39:29there's one condition that I had to do,
- 39:30which was
- 39:32um
- 39:34when I loaded this, I loaded my my group
- 39:38relationship, which is like a special
- 39:40kind of a database record
- 39:42into a variable and I called it group
- 39:43rel.
- 39:45And then when I got to here, I just said
- 39:49does this actually have a value, right?
- 39:51In in the PHP code, I would put the you
- 39:54know,
- 39:55bang empty
- 39:56or um exists, right? If this has a
- 40:00value, I'm going to proceed. If it does
- 40:02not have a value,
- 40:04I'm just going to stop executing, right?
- 40:06There is no sort of like fail condition
- 40:08in this case.
- 40:10But if I did put a fail condition, maybe
- 40:11it would tell me why it's not showing up
- 40:13on the screen.
- 40:15I know with VPL and regular actions, you
- 40:17have to define them. Oh, you know what
- 40:18else? You You might be saying the right
- 40:21thing right now.
- 40:22Uh you have to go to structure.
- 40:26Where did you go structure? I'm going to
- 40:28check my view.
- 40:30And I'm going to go look at group. I
- 40:31might have to turn it on
- 40:34in order to make it work.
- 40:39Look at that.
- 40:40Okay.
- 40:42So, inside of views here, this
- 40:45um little thing. This is like I said,
- 40:47this is right now this is a special ECA
- 40:49bulk operation
- 40:51and it doesn't smoosh in well with the
- 40:53regular VBOs.
- 40:56But,
- 40:58now I can go back to content.
- 41:01Go back to groups.
- 41:04And it should be there.
- 41:06Yay! All right.
- 41:08Teamwork.
- 41:11Um so, yeah. Now I can officially take
- 41:13this and one click add something to
- 41:16Portland
- 41:18from the screen. And I could obviously,
- 41:20if I had a thousand nodes on my site, I
- 41:22could do it that many more times.
- 41:25Um you've been seeing some of these uh
- 41:28things here that say mail has been sent.
- 41:31That's That's another model that I have
- 41:33set up here
- 41:34which is
- 41:38um
- 41:40uh send email to users of a given role.
- 41:45I have node unpublish. I think this is
- 41:47what I'm thinking about, node unpublish.
- 41:50All right?
- 41:51Whenever I
- 41:52edit a node,
- 41:54check to see if that node is unpublish,
- 41:57load up its comments, and try to send an
- 41:59email to everybody that left a comment
- 42:01on that node.
- 42:02Right? Um so, my other examples, I'm
- 42:05going to go back to the slideshow here.
- 42:08And we'll see
- 42:10a couple of other things. Oh, yeah,
- 42:11there's my thing. If I unpublish a node,
- 42:13it would notify all the commenters. When
- 42:14I save a node, if it's unpublished, send
- 42:17a message to all the commenters. But,
- 42:19what does that sending a message to each
- 42:21commenter actually mean? It means I got
- 42:22to load a list of all the comments, get
- 42:24one item off of the list, and send an
- 42:26email to that author.
- 42:29So, in this case,
- 42:31this is the
- 42:33sort of before of the before and after
- 42:35model.
- 42:36You can see whenever I save a node, the
- 42:38template that I have used is
- 42:41update content entity.
- 42:43I'm going to do a condition. If you see
- 42:45a um
- 42:47If you see a little uh
- 42:50text above an arrow,
- 42:53usually that means we're checking for
- 42:55something, right?
- 42:57And oh, this one it got removed.
- 43:00Um
- 43:02I think it's something like
- 43:04uh
- 43:06value, check for a value, right? Compare
- 43:09two values, compare field value,
- 43:12field value changed.
- 43:14I think it's going to be something like
- 43:15that. Field value change. Then we have
- 43:17to figure out which field are we dealing
- 43:20with? We're dealing with the status,
- 43:21right? So, we're going to have to put
- 43:23something in here that says the status.
- 43:25Well, how do I find that out? I'm going
- 43:27to go to the token browser.
- 43:29In my token browser, I can find things
- 43:31about content.
- 43:33Uh is it content types or No, it's
- 43:36content, right? No, it's
- 43:39This is one of those times when they use
- 43:40the word node where everybody else in
- 43:41Drupal uses content.
- 43:44Inside of node, something something
- 43:46something,
- 43:47published status, right?
- 43:51This should be what I should be putting
- 43:53in.
- 43:54This thing really does not want to copy
- 43:56and paste today.
- 44:00Okay, great.
- 44:02While I'm doing a demo is when you
- 44:03decide to do this. Published
- 44:06status.
- 44:07Okay?
- 44:10So, that's in there and then I can
- 44:12choose
- 44:13do I want to check this that it's true
- 44:15or check this that it's false, right?
- 44:17Um and I think all I really want to say
- 44:19is has this value changed?
- 44:22And then I might have to check again
- 44:23later like
- 44:24is the current value the value that I
- 44:26care about, right? I might have to do
- 44:28this two times
- 44:30in order to really get all the logic
- 44:31that I need in here. Compare a condition
- 44:34just for published?
- 44:35It might There might be.
- 44:38Cuz I don't think you have that.
- 44:40Just look.
- 44:43Status. Yeah.
- 44:45It could be status, right?
- 44:50Yeah, sometimes when you're doing these
- 44:51comparisons, you really just have to do
- 44:53like compare.
- 44:55Or is accessible is new. You can do is
- 44:57new.
- 44:58Original field has value.
- 45:03So,
- 45:04a lot of the things that you want are in
- 45:06here.
- 45:07It is possible to extend ECA too if you
- 45:09find something's just not working the
- 45:10way you really want it to.
- 45:12These are fairly easy to create. Um
- 45:14we're not planning on going into that
- 45:16today.
- 45:17But um
- 45:19yeah, something like compare fields,
- 45:20right?
- 45:22Um a cool thing you can do here, when I
- 45:24say here I I said load comments,
- 45:26it's because this is going to actually
- 45:29load up
- 45:31all of the comments, no matter how many
- 45:32there are.
- 45:34My next action, what I'm going to do is
- 45:35I'm just going to get
- 45:37one item from the list. So, uh the
- 45:42uh load a single entity. Where did it
- 45:44go? Sorry.
- 45:45Load a single entity.
- 45:48My comments CID. Where did it Where did
- 45:50the thing go that I'm talking about?
- 45:58Right place. In the right place.
- 46:02All right. Well, this is the advanced
- 46:04example.
- 46:06I thought this was what I was thinking
- 46:08of.
- 46:13My comment CID. So, where's my comment
- 46:15coming from? My comment is coming from
- 46:17over here.
- 46:20I feel like this is broken. I There's no
- 46:22names in here. I think this is not what
- 46:23I want.
- 46:25I apologize, everyone.
- 46:27I confused myself.
- 46:32Great.
- 46:33This is what you want.
- 46:37I bet you this is going to have the
- 46:38thing that I want. Look at that. Okay.
- 46:40Comparing values, is the status equal to
- 46:42unpublished?
- 46:45That was the thing I was looking for
- 46:46load comments. Okay, here we go. Get the
- 46:48first comment.
- 46:50Uh yep. Okay.
- 46:56Pardon me. Unprepared presenter over
- 46:58here.
- 46:59Um
- 47:01Let's go back to the beginning.
- 47:03If the node is saved, if it is
- 47:05unpublished, load all of the comments.
- 47:08With this action, I can get an item off
- 47:09of a list.
- 47:12Which item do I want to get off of the
- 47:13list? Which list am I acting on? I'm
- 47:15acting on the comments list.
- 47:18And what am I going to do? I'm going to
- 47:19take the first item. I'm going to take
- 47:20the last item. I'm going to get a
- 47:22specific index key.
- 47:24I'm going to get some other value or
- 47:27going to get something that was defined
- 47:28by a token. This case, I'm just going to
- 47:30take the first thing off the list. Let's
- 47:31do with the first thing off the list.
- 47:33And I can load up the contents of that
- 47:35comment, and I can decide to send an
- 47:36email to that author.
- 47:38If I know I'm only going to have a few
- 47:40of these, I could really just repeat
- 47:41this again, right? Get another comment.
- 47:44Load that comment and email the author.
- 47:46Get a third comment, load that comment
- 47:48and email the author. But obviously,
- 47:49this is not sustainable. This is not how
- 47:52we do things, right?
- 47:55So, we can take all of these
- 47:58and say, "We don't need you."
- 48:01We can instead, where it says here, get
- 48:03first comment,
- 48:05grab all of these and scootch them over
- 48:07a little bit.
- 48:09And now we get to hit
- 48:12this magical other button here.
- 48:16And this is what is called a gateway.
- 48:19The gateway exists
- 48:21for when you need to point to some bit
- 48:24of the code or you need to create a
- 48:27branch at some arbitrary point.
- 48:30The gateways themselves don't really do
- 48:32anything. They can't accept the
- 48:33templates.
- 48:34But,
- 48:36if I want the next action after email
- 48:38author
- 48:39to be
- 48:41go back to this point,
- 48:43the gateway is the way that I
- 48:47grab
- 48:49that thing.
- 48:51See if we can do this.
- 48:53Like that.
- 48:55Right?
- 48:57So, now when I'm finished with this
- 48:59action, I'm going to go back to this
- 49:00point and then instead of get the first
- 49:02comment, it's going to be
- 49:03get the next comment, right?
- 49:09Does that make sense?
- 49:11All right.
- 49:12Somewhere in my slideshow I have a good
- 49:13screenshot of what this really looks
- 49:15like.
- 49:17Here we go. We're going to name the
- 49:18model.
- 49:19We're grabbing events.
- 49:21We're giving them templates.
- 49:24Make sure you name things correctly.
- 49:26Check out your templates.
- 49:31And then keep keep moving on, right?
- 49:34This is kind of a recap of what we were
- 49:36just talking about. Email the author.
- 49:40And I I made a whole bunch of
- 49:42transitions, y'all. This looks really
- 49:44nice.
- 49:47Um so so this was the Willie Wonka
- 49:49moment. I pressed all the buttons except
- 49:51for one,
- 49:52and that was the gateway.
- 49:54So, in this case, now
- 49:57I drop my gateway down here.
- 49:59And when you get to that load comment,
- 50:02since it can only grab one,
- 50:04you just tell it go to the gateway
- 50:06and go back to the beginning.
- 50:10And don't forget to hit the save button.
- 50:13If you don't hit the save button, it
- 50:14doesn't get applied, and you can spend a
- 50:16lot of time going through your site, and
- 50:19nothing happens. Don't forget to add it
- 50:21to your view if you're doing the bulk
- 50:22views bulk operation, right?
- 50:25Um these are the things that can really
- 50:26get you.
- 50:27Right? Yep.
- 50:28So,
- 50:29do I
- 50:30understand correctly that this would
- 50:31actually send
- 50:33the number of emails that get sent would
- 50:34be the number of comments
- 50:35The number of emails that get sent is
- 50:36the number of comments. So, a good
- 50:38example of something like this, uh I
- 50:40worked on an intranet site, and we were
- 50:42doing task tracking, right? Uh customer
- 50:45support request comes in over the phone,
- 50:47somebody fills out a little uh piece of
- 50:50content somewhere, and says, you know,
- 50:53"Customer would like 30 chairs delivered
- 50:55to room 235 on this date."
- 50:58Somebody, please leave a comment to say
- 50:59that you acknowledge this request.
- 51:01Somebody comes by, and they leave a
- 51:02comment.
- 51:04But, if at a some later date, somebody
- 51:06comes by and updates what the request
- 51:08says,
- 51:10everybody who's left a comment needs to
- 51:12get notified.
- 51:14Right? That's a use case for I need to
- 51:17email all the commenters.
- 51:20Especially if it gets removed. Right?
- 51:22That's That's the unpublished version
- 51:24here. Yeah. Follow up from that. Did
- 51:26anything have to change in the the
- 51:28little action for loading the comment to
- 51:31indicate that you're loading some
- 51:33specific index, or just that gateway
- 51:35automatically handles that? When you do
- 51:37that load next uh load an item off of
- 51:39the list action, one of the choices was
- 51:42remove the item from the list
- 51:44and load one.
- 51:45So, it's modifying the list as every
- 51:49time. And when it gets to there are no
- 51:51more items in the list, it will just
- 51:52stop executing.
- 51:56So, some of the things are weirdly
- 51:57implicit about how ECA
- 52:00um handles
- 52:01the especially things like lists.
- 52:07Uh so, yeah, I was saying we got to
- 52:08check some more things about the node
- 52:09being unpublished, but I think I kind of
- 52:11did show that. Okay.
- 52:13Um
- 52:14other things that you can do, uh this is
- 52:17a game that my 6-year-old likes to play
- 52:19sometimes. It's called LightBot, and
- 52:21it's about getting a robot to move
- 52:24along a track, and he can only do five
- 52:28things, but with these five things you
- 52:29can be very expressive.
- 52:31Um
- 52:33and so, if a 6-year-old can understand
- 52:35how to do a repeated procedure and store
- 52:38that inside of a register somewhere,
- 52:41I bet your clients could figure it out
- 52:42as well, right?
- 52:45Um
- 52:46and basically what this person is saying
- 52:48is whenever you drop this procedure into
- 52:50this thing,
- 52:52I can do that action again and again and
- 52:54again.
- 52:55Um
- 52:56and that was that was sort of where the
- 52:58loop
- 52:59entered into our last example there.
- 53:05Um
- 53:07Another thing that you can do
- 53:10inside of ECA, and you will see this in
- 53:12a lot of the examples, is
- 53:14you can abstract out
- 53:17whatever thing that you want to do at
- 53:19the end of your loop
- 53:21and put it
- 53:22in another part of your canvas.
- 53:25And now this might have its own chain
- 53:27that you want to follow, but if you try
- 53:29to insert this into your normal
- 53:31flowchart, it would just get completely
- 53:34unyieldy, and you wouldn't be able to
- 53:36follow what's happening.
- 53:37So, just like the little robot here,
- 53:42think about
- 53:44um
- 53:44basically, you know, creating functions
- 53:48inside of your models and breaking out
- 53:51bits of functionality to make them
- 53:53easier to to follow the the path
- 53:55visually.
- 53:59It's like inception. Okay.
- 54:01Um some other examples that I saw that
- 54:04were really cool. This was from
- 54:05DrupalCon Portland. Um John, who is not
- 54:08in this room, but is at the conference
- 54:10today somewhere,
- 54:11um showed this off and he talked about
- 54:16uh basically when he wanted to
- 54:20uh look at these
- 54:23work slips, like, you know, work
- 54:24activities that needed to be done, he
- 54:27wanted to make sure that two of them
- 54:28were not happening at the same time.
- 54:31And so, at the top here,
- 54:33you've got
- 54:34load the slip
- 54:36and then load the start date and the end
- 54:39date into each their own variable, and
- 54:42then try to figure out how they have
- 54:44conflicts. But how are we going to try
- 54:45to figure out how they have conflicts?
- 54:47There's a There's an action in ECA which
- 54:49says, "Load all of the contents of a
- 54:51view." But what are the arguments to
- 54:53that view? It's these two variables.
- 54:56Right? So, I can say um you know, node
- 55:00contextual argument number one, start
- 55:02date, contextual argument number two,
- 55:04start date. If that returns anything,
- 55:08I'm going to check, does it have at
- 55:09least one value? If it has at least one
- 55:11value, I'm going to do something, which
- 55:14I think in this case is invalidate the
- 55:16form.
- 55:18I'm going to do it another thing in
- 55:19tandem with that, which is
- 55:22I would also like to get Unix timestamps
- 55:24for those dates, and then I would like
- 55:27to make sure that
- 55:28this event is not longer than 3 days by
- 55:31doing some simple math.
- 55:36So, again, uh that's what we just did. I
- 55:38was pointing at it instead of using the
- 55:40red boxes, but there you go.
- 55:45Um another person who's here at the
- 55:47conference let me use this action.
- 55:50And this is an activity
- 55:53that basically has to check and see if
- 55:56a certain amount of fields have changed.
- 55:59So, whenever I get new content, I want
- 56:02to send an email, but also
- 56:05we're going to group all of the things
- 56:06that have to do with this content type
- 56:08sort of into one model.
- 56:10So, this this actually in some people's
- 56:12sites could be a totally separate model.
- 56:14In this case, they've kept them together
- 56:15because if you want to export this and
- 56:19version it
- 56:20and uh you know, install it on your dev
- 56:22site, install it on your stage site, you
- 56:24can keep all of the things related to
- 56:26this one model in one
- 56:28zip file, right?
- 56:31So, this is now totally separate um
- 56:33model, basically. And it says, "If one
- 56:36of the ABCs changes, I would like to
- 56:38send an email
- 56:39and show a message on the screen. If one
- 56:41of these DEF fields changes, I want to
- 56:44show a different message on the screen
- 56:45and I want to send an email to a
- 56:46different kind of user."
- 56:48And so on, right? These can get really
- 56:51complicated and really big.
- 56:53Um
- 56:55but
- 56:56if you're able to figure out how to
- 56:58break them down visually,
- 57:00it at least lets you start figuring out
- 57:03where is the place where I need to go
- 57:04make the change or where is the place
- 57:05where I need to add some new activities.
- 57:09And then um we talked about those custom
- 57:10events, those little named functions.
- 57:12You can do those in here as well, right?
- 57:16Um what are some of the cool ways you
- 57:17can trigger ECA? These local operations
- 57:19we talked about quite a bit.
- 57:21Um that's what it looks like.
- 57:23Um inside of Drupal Commerce, there's
- 57:25lots and lots of events that get fired
- 57:27off. User added item to cart. User, you
- 57:30know, uh
- 57:32changed the cart from
- 57:34this status to that status. An item is
- 57:37getting ready to be shipped. There's so
- 57:38many things you can do. User used the
- 57:40coupon.
- 57:41Right?
- 57:42Um inside of web forms
- 57:45a reason why you might want to have an
- 57:46ECA is uh
- 57:49to to modify a web form. If it's already
- 57:52been submitted, maybe I don't want the
- 57:55the attendees to be able to fill out
- 57:57certain fields, and I don't want the
- 57:59judges of the contest to be able to fill
- 58:01out other fields. So, I can actually use
- 58:03ECA
- 58:05uh form actions to enable and disable
- 58:08fields based on your user role.
- 58:10Right?
- 58:12Um some other really cool things that
- 58:13exist is this Drupal remote dashboard.
- 58:15This basically lets one Drupal site send
- 58:18a web hook to another Drupal site
- 58:19saying, "Hey,
- 58:21this module has a security update and
- 58:23needs to be updated.
- 58:25I want to notify you, sort of mothership
- 58:27site, security updates are available."
- 58:33All right. Um
- 58:35things that are coming down the road,
- 58:36recipes are out there. Being able to
- 58:38stick ECA models inside of recipes along
- 58:41with all of the content types and all of
- 58:43the fields and all of the permissions
- 58:44that you would need and even some sample
- 58:46content to be able to demonstrate it
- 58:49is
- 58:50uh right around the corner.
- 58:53And then
- 58:55uh there are some really good examples
- 58:56showing artificial intelligence being
- 58:58used inside of ECA.
- 59:00So, if you can uh if you're in the world
- 59:03where you're trying to get artificial
- 59:04intelligence to do something, let's say
- 59:07um provide alt text on images.
- 59:10Well, I could then create a view that
- 59:12says, "Load up every image that does not
- 59:16contain alt text."
- 59:18Now,
- 59:19use ECA to load one image, determine if
- 59:23that image is owned by any nodes,
- 59:26load the title of that node.
- 59:29Load that into the context for the AI.
- 59:31Load the image into the context for the
- 59:33AI and try to generate a meaningful alt
- 59:36text for this image
- 59:38inside of my ECA.
- 59:40It is possible to do this kind of stuff.
- 59:43Um also integrating with outside APIs,
- 59:46um like we said, webhooks. If you need
- 59:48to send or receive something, um it's
- 59:50pretty easy to do those kinds of things
- 59:52inside of ECA if you're so motivated.
- 59:55Um
- 59:56and also if you have a backend API that
- 59:59you need to access,
- 1:00:01um there's there's I believe ways that
- 1:00:04you can go and fetch things with like a
- 1:00:06curl request and stuff that's already
- 1:00:08exists. You don't have to write custom
- 1:00:10code to do that kind of thing.
- 1:00:11So go fetch something from this API,
- 1:00:14uh parse the JSON data, look at one of
- 1:00:16the values, decide if I need to make
- 1:00:18some action, maybe on a cron job, maybe
- 1:00:20when somebody hits a button on my site.
- 1:00:23Um
- 1:00:24one thing I
- 1:00:27started specifying with ECA and the
- 1:00:30client decided they were going to take
- 1:00:32their money overseas,
- 1:00:34um was for a game engine.
- 1:00:37So
- 1:00:38uh
- 1:00:39I kind of got the idea originally
- 1:00:40because if you've ever looked at any
- 1:00:43game engines, they all use these visual
- 1:00:45editors to begin with.
- 1:00:46And the client started telling me,
- 1:00:48"Well, they have an online game.
- 1:00:50And let's say that there's a series of
- 1:00:53four of these online games. If you play
- 1:00:55all four games,
- 1:00:57I would like to give you a badge."
- 1:00:59Well, how do I know that you've done
- 1:01:01that?
- 1:01:02Right? I'm going to have to store some
- 1:01:04information about that you have played
- 1:01:06the game
- 1:01:07in an activity table somewhere.
- 1:01:10And I'm going to have to store your
- 1:01:11user,
- 1:01:13you know, the entity ID of the game, and
- 1:01:16the date that you played it, right?
- 1:01:19How How am I going to find that
- 1:01:21information? I could use ECA, load up a
- 1:01:25a view for all of the games that this
- 1:01:27user has ever played, and now compare it
- 1:01:29to a list of
- 1:01:31you know, games that I care about in
- 1:01:33order to make this badge.
- 1:01:35But,
- 1:01:36they didn't just have four games. They
- 1:01:38had
- 1:01:3950 or 60 games. And they didn't want to
- 1:01:42just do one kind of promo. They wanted
- 1:01:44to do
- 1:01:45essentially an infinite number of
- 1:01:46different kinds of promos. And I said,
- 1:01:49"You're going to be on the phone with
- 1:01:50your programmer every single day. You're
- 1:01:52going to be deploying new code every
- 1:01:55single day. Or
- 1:01:56I can teach you how to make ECA rules,
- 1:02:00and you can create the business logic
- 1:02:02yourself."
- 1:02:04Uh and so, this was a thing we were
- 1:02:07planning on
- 1:02:08building out this whole system for them.
- 1:02:10And like I say,
- 1:02:12they took their money elsewhere, but I'm
- 1:02:13pretty sure they still did something
- 1:02:15very similar to that after we designed
- 1:02:17it for them.
- 1:02:20Um
- 1:02:21Places to go to learn about ECA.
- 1:02:24The ECA guide, especially the library
- 1:02:26page. There are some really good
- 1:02:28examples. Um Anytime that I want to, you
- 1:02:32know, create a model for something, I go
- 1:02:34look here first.
- 1:02:36Um
- 1:02:38Also, pretty much everything on the
- 1:02:40library has a video attached to it, a
- 1:02:42YouTube video
- 1:02:44of Jürgen or one of the other
- 1:02:45contributors building out the model. So,
- 1:02:48you can kind of watch it be constructed
- 1:02:50in real time.
- 1:02:52Um If you do have people updating ECA in
- 1:02:56production, you have to have a way to
- 1:02:57get those changes out of production and
- 1:03:00back into your site. But, if a deploy
- 1:03:02happens before you're able to hit the
- 1:03:03button,
- 1:03:05you've now actually reverted your
- 1:03:06configuration. So, you might need to get
- 1:03:08something like the config ignore module
- 1:03:10or the config read only module
- 1:03:13to allow you to say,
- 1:03:15"You know what? All of the
- 1:03:17configurations that belong to ECA
- 1:03:20actually don't
- 1:03:22overwrite those whenever I do a config
- 1:03:24import. Leave them alone. I've also done
- 1:03:27this with web forms before. If I wanted
- 1:03:30the client to be able to edit web forms,
- 1:03:31I could go and say,
- 1:03:33"Please import all of my config except
- 1:03:35web forms by using a tool like this."
- 1:03:38And then we're able to set everything
- 1:03:39else into read-only mode so that even if
- 1:03:41they try to go to the site information
- 1:03:43screen and try to change the name of the
- 1:03:45site, it will say, "No, you're not
- 1:03:47allowed to change configuration. Sorry."
- 1:03:51Um how do I run ECA on cron? There's
- 1:03:54some good examples in the library
- 1:03:57um to talk about how to do schedule
- 1:03:58publishing.
- 1:04:00Um Views bulk operations is a separate
- 1:04:02project, but it is
- 1:04:04an official separate project, just not
- 1:04:05part of the ECA core.
- 1:04:07Um
- 1:04:09you saw some of those little status
- 1:04:10messages I was showing to sort of debug
- 1:04:13my my email sending, that's the mail log
- 1:04:16module.
- 1:04:18Um we talked about commerce just a
- 1:04:20little bit, but um that's a separate
- 1:04:22download.
- 1:04:24Uh Web forms one is a separate download,
- 1:04:26but can be very useful like I was
- 1:04:28saying.
- 1:04:30And the the events they provide are
- 1:04:31things like if a form's being validated,
- 1:04:34um when it's getting saved, um you can
- 1:04:37display custom messages, you can
- 1:04:38validate fields, and you don't have to
- 1:04:41mess around with form API in web form,
- 1:04:43which everybody knows is just no fun.
- 1:04:46Um being able to do the resource
- 1:04:47conflicts
- 1:04:49um that one I said that John did at uh
- 1:04:51DrupalCon Portland, highly recommend
- 1:04:53that talk, it's a good one.
- 1:04:55Uh workflow allows you to modify and
- 1:04:59react to changes in workflow states.
- 1:05:01Cache, uh
- 1:05:03this is where it gets really deep and
- 1:05:04you can do crazy stuff with cache. Like
- 1:05:06I want to flush the cache whenever
- 1:05:08somebody, you know, saves a certain page
- 1:05:10or updates some field. Um
- 1:05:13being able to do things with users and
- 1:05:15logins, redirect them after they've
- 1:05:16logged in. If you log in and you're this
- 1:05:18status, I want to take you to that
- 1:05:19screen. If you log in and you're this
- 1:05:22role, I want to take you to another
- 1:05:23screen.
- 1:05:25Um organic groups we showed in my
- 1:05:27example today.
- 1:05:29And then um there's a whole other thing
- 1:05:32called context, which lets you actually
- 1:05:35like show blocks,
- 1:05:37um block visibility rules, or you know,
- 1:05:40enable enable disable menu items,
- 1:05:43um play around with taxonomy terms based
- 1:05:46on what's available at the time. So,
- 1:05:49there's a lot a lot a lot to cover in
- 1:05:51here, and I was trying to just give you
- 1:05:53a nugget to get me started.
- 1:05:56Um so,
- 1:05:58get to lashing everybody.
- 1:06:00Let's build bridges.
- 1:06:03That was my thing, and I do have a copy
- 1:06:05of these slides, and if somebody wants
- 1:06:06to see
- 1:06:07um specifics
- 1:06:09of something that I did, I'll be up here
- 1:06:12for a little bit. And then I'm going
- 1:06:13back to Portland.
- 1:06:14So, thanks everybody. Thanks.
About this transcript
This page contains the full transcript of Automate the Little Things: ECA by Pacific Northwest Drupal Summit, generated from the public captions YouTube serves with the video. The transcript has 10,814 words across 1,839 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.