The Drop Times: TDT Partners with Drupal Camp Asheville 2023
LN Webworks: Drupal Website Personalization: The 6-Step Approach to Success
The Drop Times: 5 YouTube Videos to Start with Drupal
Opensource.com: Preserving the open web through Drupal
Drupal updates create opportunities for everyone to participate in the open web.
Just because I share content online doesn't mean I want to share control over it. My website is a perfect example of what I mean. I take photos nearly everywhere I go: To date…
The Drop Times: 7 Reasons Why Top Universities Use Drupal
The Drop Times: Good Design Can Be Measured: Jill Moraca | DrupalCamp NJ
Zyxware Technologies: Celebrating Drupal's New Recognition as a Digital Public Good
Freelock Blog: Deploying blocks and content to other site environments
If you have a current Drupal site (built in Drupal 8 or later) you no longer need to entirely rebuild your site -- ever again. That doesn't mean it couldn't use a freshening up now and then.
We have several clients revamping their home pages, along with key landing pages. As part of this refresh, they are getting new designs in place, new messaging, new content. And they would like to launch the new design, and content, all at once.
#! code: Drupal 10: Using Parameter Converters To Create Paths For Custom Entities
Drupal's path system gives authors the ability to override the path of an item of content. Whilst the internal path of a page might be "/node/1" the external path can be anything you want, and can be set when editing the item of content.
The addition of the Path Auto module makes this change of path easy for your users by using patterns and automatically generating paths based on the data contained within the content item. You might want to use a path that contains the type of entity being presented, what category it was added to, and even the title of the item of content.
This system creates powerful search engine friendly URLs that can add keywords to the paths that Drupal uses to find content.
When building custom entities there are a few things you need to do in order to add Path Auto functionality. It must contain a 'canonical' link that points to the entity and be a fieldable entity with a field called 'path'. A canonical link always points to the basic path of the content entity, which would be "/node/1" for all content type entities.
Outside of the Path Auto module there are a number of internal classes called parameter converters that implement the core \Drupal\Core\ParamConverter\ParamConverterInterface interface and are used to convert an argument within a path into an entity object. This object is then passed upstream to the form or controller that will be using the entity.
Without the parameter converter in place you would have to accept a value to the form or controller that you would then have to convert into an entity of some kind. This can add a lot more code to the those classes that wouldn't be needed as they need to know how to load the entity and also what to do if the entity doesn't exist.
In this article I will create a content entity and then show how to generate custom paths to that entity in via a custom parameter converter class.
The Drop Times: 7 Reasons Why Drupal Is the Best for Travel Agency Websites
Drupixels: Automatic Entity Label: Automatically generate entity titles in Drupal
Drupixels: First 5 Drupal modules to install to make your life easy
mandclu: Creating Dynamic Tabs on Content Types
LN Webworks: Drupal Features:The Essentials You Need to Know
Dropsolid Experience Cloud: Mautic for Developers: connecting Drupal content to Mautic email marketing
LN Webworks: The Power of Experience-led E-commerce: Combining Content and Commerce with Drupal
clemens-tolboom starred cosmologicon/pyjam
Code for my Python game jam entries (PyWeek)
Python 7 Updated Apr 2
The Drop Times: Drupal Is Now a Digital Public Good
Gizra.com: How We Theme in Gizra with PEVB and a Composable Approach
Theming is hard. It’s usually the most time-consuming part in our work. Writing a DB query or baking logic into a Drupal hook is the easy part. The main challenge is making an element look like the design and appear correctly on different devices and browsers.
Our main goals remain the same as from this post:
- Standardization in multiple projects
- Reduction in cognitive load
- Optimization for rewrites
All the code examples in this post are inside our Drupal-starter. You can install it locally, and see all the elements under the Style guide page - https://drupal-starter.ddev.site:4443/style-guide. The Drupal-starter code base is used as the starting point of our projects, so you’ll find it very mature!
An example News node on a fresh Drupal starterA quick reminder is that for theming, we’re using the Pluggable entity view builder module, known as PEVB.
Back to our problem - we don’t want to theme the same things over and over again. This sounds trivial, but I’m sure many are doing that. We have! Here’s an example of two different twig files:
<div class="flex flex-col gap-y-3 md:gap-y-5"> {{ title }} {{ body }} </div> <div class="flex flex-col gap-y-3 md:gap-y-5"> {{ author }} {{ teaser }} {{ date }} </div>The cards’ contents differ but the wrapper classes are the same. Also, the chances of changing the gap on one twig file and forgetting the other are high. At least for us, on bigger projects, updating the gap on only some files was a common thing.
Let’s think of the designer for a moment. Should the gap between items be 20px or 24px? The answer, for us, is “whatever works best as long as it’s consistent™.” If one card is 20px, then all cards should be the same. To deal with that, we have a limited set of trait methods:
- wrapContainerVerticalSpacing (20px)
- wrapContainerVerticalSpacingTiny (2px)
- wrapContainerVerticalSpacingBig (40px)
- wrapContainerVerticalSpacingHuge (60px)