Having recently started work on learning the ropes with Magento 2, and finding all sorts of oddities, incongruities and banging-head-on-desk-ities, I decided to take a look at the blog of Alan Storm at alanstorm.com.
I should say that this is a spontaneous personal review and I am not paid by, sponsored by or an affiliate of Alan’s.
I have used Alan’s commercebug tool whilst working with Magneto v1 for years and his blog posts and answers on sites such as magento.stackexchange.com have always been a go-to for explanatory solutions rather than just instructions.
I was intrigued to see that Alan had written a book “No Frills Magento 2 Layout” and decided to purchase it. Alan has a great way of taking you through things with detailed explanations allowing you to understand WHY you are doing something. This e-book (pdf) comes with it’s own Magento 2 module for you to install. This allows you to use and reference files in the M2 file structure, add new files, modify things in accordance with the book and see the results first hand.
Whilst all code is shown in the book, it is great to look at it in your own editor and be able to make changes to see what happens. Making modifications also gets you used to the (pain-in-the-backside) process of endlessly clearing caches and static files to view your changes. If you are not used to doing this, then cache and static file issues can drive you insane with Magento 2. The nice thing here is that Alan explains why these files exist and in what conditions you need to clear them.
Here are some of the topics covered:
- XML layout files are explained, along with what they are actually controlling behind the scenes, and how they are different to what we might be used to in Magento 1.
- How blocks now work and how page frameworks are put together.
- How CSS and LESS files are used in the new Magento 2 structure.
- Using require.JS to specify dependencies and create JS modules/programmes.
Basically, the book covers everything you need to know to get started on developing your own front-end HTML layouts and theme in Magento 2.
I do have a couple of minor gripes. Firstly it is very difficult to copy the code from within the book to paste into your editor. This is down to the weird spacing often created in PDFs and the line numbers displayed next to the code which all come out when you copy stuff. However, I can type the code and there isn’t much of it at any one time. Typing also makes you actually look at it. Secondly, it is sometimes hard to find the original “core” Magento files referred to in the book but this might be down to the particular installation or version of M2 that I have. It was irritating trying to locate which vendor/magento folder I was looking for as M2 has a few of them in places.
Overall, I recommend this book, No Frills Magento 2 Layout, 100% if you are struggling with any aspect of understanding the puzzle that is Magento 2 module and theme creation. The inclusion of a test/example module is just brilliant.
Let me know if it helps you.