![]() package: the one where your module should be included (“custom”).description: enter a detailed description of your module, one to be published on the module list page.name: enter your Drupal 8 module's name.Now, here's how you structure the medatada in your “”: #7 Best Practice: Create a “.” to Notify Drupal About Your ModuleĪnd this is a recommendation that you'll find in any “How to create a custom module in Drupal 8 step by step” guide.īasically, this file, that stores metadata about your new custom module, notifies Drupal about your newly uploaded module. module” file that gets loaded on every HTTP request. #6 Best Practice: Keep the “Dot-Module” LightĪnd that because it's your “. Tip: if you're not that excited about the idea of having ALL the errors exposed and instead you want to get alerted only about those generated by your Drupal site, just run: tail -f /var/log/apache2/error.log This way, you'll get alerted about any error sneaking into your code as you're building the module. Remember to switch on the PHP error reporting before you plunge into the Drupal 8 module development process. #5 Best Practice: Set Drupal to Show All Future Errors As an alternative, use your module's name as a prefix. Word of caution: avoid naming the theming function “ block_.”, as this won't transfer any variable to your twig templates. #4 Best Practice: Add a “hook_theme” in Your “.module” FileĪ great practice when you're using Twig templates with custom blocks. Word of caution 2: make sure you don't go for a name that's already used by another core or contributed module that you'll be implementing in your project (for instance, instead of naming your module “ views_baz”, you might want to go for. Word of caution 1: make sure your module's machine name contains no upper-case letters, otherwise your hook implementations will go unnoticed by Drupal. You can find all these rules listed on Github. not to contain terms that are already taken (e.g.to stick to the “lower-case letters + underscores” formula.#3 Best Practice: Give Your Module a “Proper” Machine NameĪnd by a “proper name” I mean one that follows the golden rules for naming a module in Drupal: Yet, it's better to create a dedicated place this type of modules, so you don't have to rummage all your modules (those downloaded from here included) whenever you need to look for a custom one. Tip: you might be tempted to skip the “ /custom” folder and name your folder “ /sites/all/modules/E-shop” instead. In this case, you should name the new dedicated folder: “ /module/custom/E_shop”. #2 Best Practice: Create a Dedicated Place for Your Custom Modules … is one of the golden rules to follow when you develop a Drupal custom module. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |