started you guys are really my my own
team back there won't even let me start
ok manifest errs yeah we're rolling flex
running hey we're from manifest I'm
Benji this is Gordon we proposed this
session not really thinking we were
gonna get it
here we are so got a little agenda here
it's not on the screen yes ok so um I'm
gonna kind of give you a backstory of
what we did as far as converting these
modules in into blocks pages forms
JavaScript and then I'm sure there will
be questions so we'll try to answer them
to the best of our ability so basically
what we had to do was take a Drupal 7
site that was packing like six and
poured it to six drilling sites and we
were given three months to do it
the site didn't actually use domain or
anything that you would normally use to
make a single install look like six
sites they used taxonomy and a bunch of
crazy custom code and on top of that we
had two subdirectory sites which made
things interesting as well anything I
mean that you can say I could I could
actually comment forever on this yeah um
it was pretty hard to work with because
we inherited this and you would read
code and be like I don't even know why
this works or if it's working and yeah I
guess that's almost we spent as much
time being what I like to call
archaeologists is anything else you know
diving into someone else's code I'm sure
no one in here has ever had that
experience before so yeah it's not only
simply just taking something reporting
it to a new platform it's trying to
understand why and of course the team
that we had to work with on the other
end of the content entry people couldn't
tell us why some functionality existed
or not or whether it was needed in the
new site there was a lot of legacy
systems I know how much you guys know
about what best practice for like we
used to say I think it was 20 20 modules
platform we had any custom modules that
was on top of the contribs
that had everything under the Sun right
like no types were being including
organic groups and there was clearly no
organic groups in the site but we had it
but we didn't want to turn it off
because we wasn't we weren't really sure
right where else what where else that
would manifest itself so has anybody
done this yet ported from v7 to da
well yeah so this is just time to give
you guys an idea of what the file
structure looks like and these are both
the same model it's a this is a module
that pulls data from Google to create a
trending content block it shows the four
highest trending articles on the site
and as you can see they're slightly
different
well everything's kind of split out into
more farm sounds and we'll get into that
but first thing you want to do when
you're starting is wait for the screen
to refresh let's start with a dot info
file which you have to do in d7 d 8 d 6
if you've ever had to do that but in
becoming a mo file and which stands for
yet another markup language as I know
most of you already know and you still
need a dot module file but it
technically doesn't do anything I mean
you can put functions in it if you want
to but you don't have to so just to give
you an idea of what that dot info it
looks like it's pretty similar syntax is
important the spaces would you get the
spaces wrong you're basically looking at
a white screen site and you don't get
any good error message that really tells
you where it is what's happened what
is you kind of just have to walk through
the file until you figure it out and as
you can see pretty similar you have the
same things you don't let your files
anymore
it was screaming again I didn't even
change that time okay blocks Orton and I
were talking earlier and really the only
D seven hooks that we've ever used or
hook block info and hook block you does
anybody ever use the D the other ones
the same pre-suit pre-safe that's a
that's a thing
use the alter ones yeah
configure that's when you're doing
configurations forms and stuff like that
I don't know yeah yeah I mean I've seen
it I've just I've had to write it yeah
and as you can see on the on the right
side is what you're looking at in
you're polite and that lives in a
controller or plugin is that a plug-in
it's a plugin source to lug in black
yeah I kind of seen that right there
and these you got to declare the
namespace and it's usually Drupal your
module name plugin block and you need
these what are those you can call they
use puts the injection
okay dependency injection as you can
tell I'm really great at this stuff or
it just won't work as I found out and
then when you the annotation is
basically like your hook block info
where you give it an ID you the admin
label in that new category and then you
have a class that's basically the name
of your file and extends the block base
and then you have a build function with
an array inside it
so I hope you guys can see this on the
right or on the left I'm sorry is your
Drupal seven hook block info and then on
the right is what that looks like in
your plug-in so here again the
annotation the part of the comments is
the syntax is particular it's another
way
it's each item has to be on its own line
is then with a comma and if you don't do
that then it's you're not going to be
able to get it to appear like in this
particular instance this is how it shows
up in the block list when you go to we
go to place to block on a page so if
anybody has any questions just jump in
with them we don't have to wait till the
end and this is basically this is that
same module I was talking about that
creates the training block so this is
hook block view it's calling and
a custom callback for a custom function
that actually builds the block
um
and then in Drupal 8 inside your build
function it's basically doing the same
thing but in this case I decided to
actually render it with the View mode so
that we the original module just had a
template and it printed the values in
the template so things like that are a
lot easier in Tripoli as far as like
you know print getting things to the
page at least I think so
six one half dozen yeah I guess the
level of comfortability yeah I mean if
you don't like twig you do like twig
yeah I don't know I like it it's a lot
easier than I like it a lot but in the
PHP template yes
just me so pages in d7 you used book
menu and usually use the custom fallback
to get things to the page in d8 you have
a routing file that creates the path you
have a controller which is basically
your page if you want to add something
to a menu you also do that with the ammo
or if you want to add something to the
local task you do that with the ammo
file as well and Gordon's going to go
for the driver things I still don't
understand it
oh yeah it's got its own slide okay I'm
trying to thing in Indy seven in your
hook menu if you had say a collection of
items that were dynamic you wanted to
create local tasks a menu type of local
task the equivalent is you'd run a for
each statement and run through a list of
items to be able to dynamically create
these things on the menu in d8 use a
driver function in the ammo file you
specify the name of the driver and then
in here now this particular example it's
not really doing anything dynamic this
is just kind of illustrative but in here
same thing we have for each statement at
the bottom that would dynamically create
the items for the local tasks in the
particular site we were using we were
building this for this is actually
something that part of a module that
creates HTML emails that we just emailed
to the client so they can drop it into
their email system
yeah the content admins they go in they
create this is not exposed to outside
users this is simply for content admins
they come in they throw a bunch of
articles into a node so they're pulls in
teasers then they want to save it out
and purely grab the HTML and they throw
it into whatever their email is
MailChimp whatever it is it's already
rendered HTML so it's basically a tool
for them to be able to blast out emails
without us having to interact with the
system through their API this was kind
of business rules driven it's not how we
would have intended to build that tool
cetera which a lot of the things we did
so as I said before in your dot mounting
file
this is hook menu where you have the
items array and you get the page of
title usually have the custom call back
and in this case it's in a file and the
menu call that yeah menu callback is
simply it's a callback for a menu item
something on menu or line it's you're
specifying you're creating a path ok the
menu system knows that this path exists
you can't then go to the menu system and
create the same path it's blocking it
out throwing it into the DB so it can't
be used it's defining a static not know
so extent of it
instantiated callback semantics sorry
you're mapping a function to a path
let's put it that way so basically
that's what you're doing here with this
Jamo file you're giving the page a path
you're not if you wanted to do the menu
thing you would do that in the menu yamo
the menu link gamal but you're telling
it which controller to use and giving it
a title and
giving permissions right here in this
channel
so this is the return array from that
custom call back and Drupal 7 and as you
can see it's doing quite a few things
here it's attaching CSS JavaScript it's
doing some settings for the JavaScript
itself does anybody ever mess with that
I recently just learned how to do this I
didn't even know it was a thing until I
was working on a project and had to do
it so basically you can create things in
PHP that can be passed to your
JavaScript files so that's what this
States data thing is here
just in case that wasn't large enough
for you
then I skipped you did okay that's what
happened you swiped left so this is
basically the same thing in Drupal 8 it
hasn't changed too much the only thing
that really has changed is now and we'll
get into this later we are calling the
JavaScript and CSS and with a library as
you can see on the I mean the first
thing in the attached already
so forms we've all done them right
altered them I think I've used all of
these and Drupal 7 they really haven't
changed too much and Drupal 8
some of the function names are different
they of course are in their own file as
you can see that source form form name
and then the the form name extends the
form base class and then within that
class you usually hit all of these these
functions here and this is slightly
different this is still the router club
but for a forum you under the defaults
you actually have a path to your forum
and you usually want a permission that's
a little stronger than access content
because you don't really want everybody
touching your forms especially when they
will determine whether you're training
blocks work or not
so as you can this is Drupal 7
everybody's done forms
a race just like everything else is in
Drupal and if you look at the Drupal 8
version it really hasn't changed much at
all really there's maybe one line that's
different
and if you look
our next slide this is just kind of an
aside variables aren't a thing anymore
in Drupal 8 in Drupal 7 you would use
variable get and variable set to to get
and set your variables but as you can
see on the right side for Drupal 8 it's
changed a bit and they all now live
there's no more variable table either
they now live in config we think right
yeah they do we were just looking for it
earlier and we couldn't remember if they
actually lived in code or in the table
and we found it in a table so they're
kind of hard to find but they're there
so JavaScript's I didn't have to do much
type of script in Drupal 7 other than
get it to the page and it was actually
pretty easy there were several different
ways to do it you could just declare the
scripts in your info file you can do use
Drupal at j/s you could attach them an
array and you could use libraries that
has anybody ever done that in Drupal 7
I've never tried it
other than installing a lot of course
madhouse yeah because he's a nerdy and
socially awkward so in Drupal 8 they
pretty much you're using libraries
there's not really a choice and you can
either put them in your module file
there's a module Yambol or a theme yamo
in a theme you can actually add them to
your data info file but in a module you
need to attach them someway
so this is kind of what a library looks
like in Drupal 8 so you can in most
cases I think it throws things in the
footer now right
by default yes what's though if you need
it in the header you have to tell it hey
I need this in the header by just
putting header true there you can
include files that live in your module
or theme and you can set the pendants
ease for those you can also hit external
external scripts I didn't put an example
in here but I had to actually do one as
the value of a div and that was just
ugly so I didn't put it in here and I
don't want people doing that but
so yeah and that info this is pretty
much all you had to do whenever just
including in Drupal 7
but for
in a theme this is how you do it in
Drupal 8 so you just add libraries and
then point at the library that you've
named in the ammo file and when I was
doing this I noticed this I didn't
notice that when we were building the
site but you can actually remove CSS
files I'm guessing now it you put that
in there yeah it's pretty cool because
usually you had to then you have to
write something and pre-process HTML and
rip everything out of the scripts array
and then I thought you had to read
Eclair the same one but it was empty
yeah good times that seems
counterintuitive yeah
so this is basically the same a couple
ways you can add these
you can either use Drupal at jeaious or
in a return rate add them to the attach
to rate this was in d7 and as you see in
that Drupal at jazz example they
actually had different scripts for
different environments
not sure why
so this is basically this hasn't changed
much other than there's actually
there we go so basically are attaching
the libraries now instead of actual
files
whoops questions
philosopher got any questions again
enough time you can redo it we could do
let's go back to that did you remember
to set the record yeah so my favorite
thing here is the hook page attachments
bite when you're specifying libraries
libraries aren't just simply about like
in the past you had to put J s and CSS
on the page in two different commands
libraries you specify in a library you
can specify CSS and j s in the same
library and just get them both on the
page with one fell swoop that's what I
like about so much cleaner that way yeah
as a back-end guy I don't want to type
that much I mean the front-end guys
don't have to copy too much from Stack
Exchange we just like put on recording
that we sound like the two of the
laziest people in the world but we like
to think of it as efficient not lazy so
you get more done that's right
see we got through this presentation so
efficiently there's time for questions
what did you find that you had to review
in the interiors of the module not just
because they were allowed to encoded in
the first place but because of the
changes in Drupal now first up because
this is being recorded and the developer
may be in the room we didn't say it was
coded in a lousy way same the the
biggest problem we really had was
functionality and what was determined to
be needed or not needed and nobody when
there was a lot of lack of knowledge
well a lot of things we were able to do
with out with out-of-the-box things with
Drupal and then some of the things like
Gordon said lack of knowledge people
didn't know how things were actually
created so we're like two weeks out from
launch and we're finding pages that are
created in a module and using JavaScript
that we didn't know about and then you
know figuring out oh how do I get this
to the page this is how I used to do it
so like having to learn this or yeah
they're one of the modules like the CSS
was playing a really major part some
nothing was actually working because the
CSS was
if it was a map and it was coming in but
like about that big because it wasn't
reading any of the CSS rules that it
needed and I figured it out when I added
it to the library and all of a sudden
the maps like so there were things like
that the variable variables and
configuration like finding the right
syntax to do all that stuff that's the
thing with like Drupal 7 has really good
documentation because it's been around
forever and Drupal 8 not so much like
you would find one instance that got you
exactly what you needed
whereas what seven like you know you
google something and the whole first
page will give you ten different ways to
do something this site we inherited the
guy the original architect was actually
a very sharp programmer I don't think
that Drupal was his first love but the
reason there was 80 custom modules he
wanted all of the module creation or the
content type creation to live in code
and in version control so it wasn't in
the day you know he didn't go and create
an article content type and then put all
the fields on it and to get it in code
he had written custom written some
instantiation rules to be able to create
it when you enable that module it's got
a new content type and that content type
has all those fields and stuff like that
so all that stuff was what we like to
call cruft you know that because we went
to d8 we put all that stuff built it
through the UI or through the migrate
module and then we jumped it into the
ammo files we have to worry about it
again until we wanted to add a new field
to one of those content types so that
got rid of a lot of custom modules we
went from 80 down to like 10 I think
we're down to 10 right now and like he
said we got a lot of our functionality
out of controls that have come a long
way now we started talking to the client
about making this migration over a year
ago a year ago a lot of those modules
hadn't been ported the DA yet and that's
that was a significant help yeah that
the community was able to do that in the
year because if we had been on the hook
to do a lot of that stuff we would have
had to go on
the original route the original
developer went was to create a lot of
custom modules or we would have had to
get into all of those controls and work
on porting those and that's that's a
serious undertaking to that we weren't
staffed for we did have to write some
custom migrations
- yeah we did we had to convert filled
collections to paragraphs and so there
was a patch that existed to be able to
do some of it so we had to pass the
module and then we had to write some
custom migration scripts to be able to
get stuff out of field collections and
into the paragraph and that was kind of
a trial and error sort thing I think I'd
run that in quarters like a dozen times
so so having the ammo files got us out
of a lot of that overhead going from six
sites living on a single Drupal instance
to actually making them six discrete
sites in a multi-site environment opened
up the pipeline to the database from the
code base to the database was no longer
this big it was now you know this big
because each site was talking to its own
database we had a lot of speed increases
just like our SEO team was pretty happy
with the performance of the site because
that used to be a big problem you know
certain pages were taking 30 seconds to
load ridiculous stuff like that a lot of
the custom code too was just dealing
with the way they built them the
multi-site too
because there were you know entire files
that were looking at the URL and saying
if it's this URL do this so we we got
rid of a lot of that stuff - I think we
were talking about - before because two
of the sites exist as sub directory
sites Drupal in a subdirectory they were
sim linking to the parent directory so
if you did an inspection or tried to
load something in Drupal sighs it wasn't
that you know because it was when it was
trying to think about something it was
going through all the directories and
finding each instance of it because of
the siblings so yeah it was I was not
pleasant so that was at the top of the
list I think for goals for the project
in general we actually proposed this
originally as a as a case study more so
as how to port a module so these were a
lot of things that we were going to talk
about glad I had some time to get it in
there it was a learning experience yes
put it that way
obviously re-architecting isn't
something that you can automate but it
is any of this stuff that could go in
the scripting module conversion
scripting and things like that there's a
panels on the file that's a good
question I don't know if the way they
were built it would be possible cuz they
weren't really felt like I'm not I'm not
talking about doing your whole setup but
are there pieces that you've learned
that maybe could go into the scripting
so that other people wouldn't have as
much to do as possible I I don't think I
can answer that question on the spot
definitely use console to scaffold the
new modules you know just to take care
of something that without any some of it
for you
I'm just looking at getting more sites
to be able to go over to d8 and part of
it is converting modules and if you can
get somebody that likes to just run the
script and do a few things that they
know and get it set up so that other
people can come in and handle more the
detail that might hello yeah
and the example module has a lot of
stuff missed yeah like I said if you're
gonna re architect it because there's a
whole bunch of changes obviously that's
almost impossible automate is that's a
case-by-case basis yeah we shot other
things that like the variables right I
don't know how much that script does
that but yeah I don't know II think that
would be something that would be
because I usually pull them from the
example module and and in a lot of cases
we were trying to change it because we
didn't have to deal with six sites on
one because yeah because I feel like in
some cases the modules themselves got a
lot smaller two-digit I mean I'm sure no
one's had this problem where you know
you've been giving an insurmountable
task with extremely tight turnaround
time and this was not the case it was
there was there was plenty of times
where we were maybe following the
previous architecture out the window we
wanted to do it differently but you know
maybe to meet a particular deadline say
okay this is working for now let's not
reinvent the wheel we will address it
later because you know after the initial
launch of course there's going to be a
maintenance window you know for us to do
stuff because I mean right now so this
launched about a month ago we're out of
the woods with bug fixes we're doing
feature enhancements now and there's and
but a lot of these things the account
team now is really excited because well
speed increases doesn't like this
they've known they're not at a point
where they say hey go back to the line
and say there's a lot of these features
that we would like to implement which
were not a possibility before Indy 7
with the kind of load times we're
talking about or the overhead that the
site had so we're in a better place now
and that was kind of the first step on
the journey was to be able to do that
Oh young man ultimately from d78
how much of the fat was trimmed and he
said he brought down the number of
customers from 80 to 10
it was mostly to rear contect area yeah
well yeah because we had all these other
we were able to put a lot of stuff in
the ammo and I think we didn't talk
about this but the yam the conflicts
that we have for the site because
they're six or seven sites we have six
or seven config directories living and
that was a little bit of a problem in
during development we had so many
developers in there that we had a little
bit of aggression occasionally because
somebody was pulling in the wrong yam
will file or something like that but
yeah yeah you get to the point where
you're not going to each site and
exporting the config your gret exporting
at one time and you're copying and
pasting it in all these different
directories and then certain of those
things actually have the theme in them
and that was a lesson learned by some of
the devs that you know I just I just
caused the entire thing to not be able
to run config import because that theme
is not enabled on this particular site
so it's there's a there was some
learning lessons there too but to answer
your question I don't have a hard number
about how much fat was trimmed but if
you want to say like certain pages were
taking 20 to 30 seconds to load and
we're now down to like 2 2.5 seconds per
page and this is kind of a coffee-table
book version of sites they're like four
and five Meg's per page you know a lotta
imagery a lot of high-res imagery so we
feel like that's a huge win in terms of
performance
a lot of a lot of them we were able to
consolidate - they had probably four or
five modules that were just doing
JavaScript so I was able to put a bunch
of those in the same module and they had
a lot of analytics I mean there was
probably four different reporting's
going on yeah for each site I think we
got it down to two now is it two or
three there again there was a there was
a shortcoming in knowledge from the
different teams about what are we
actually still collecting on do we need
this yeah we had probably 20 30 scripts
that didn't need to be there yeah an 87
they were loading in the head you know
it's not like now we have them
predominantly a footer except for Google
Analytics always wants you to have and
the hats that are no longer on yeah
they'll come back down yeah that's been
a lot of time making this work
here's another 10 seconds
all right well I guess as we say that my
company like um we can give you back
twenty minutes of your day it's a
win-win thanks for coming