Freelock Blog: Deploying blocks and content to other site environments

Deploying blocks and content to other site environments John Locke Sun, 04/16/2023 - 14:06 Image removed.

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.

Read more

mandclu: Creating Dynamic Tabs on Content Types

Creating Dynamic Tabs on Content Types Image removed.mandclu Fri, 04/14/2023 - 06:24 Towards the end of 2021 I had an idea: what if Drupal could expose content in a grid, similar to what users might be used to in database GUIs like Sequel Pro or Sequel Ace? I was able to put together a simple proof of concept, and the Autogrid module was born.I had originally wanted this to be available as a tab on relevant bundles (content types, taxonomy vocabularies, etc) but at the time I wasn't sure how to implement this, so I created a custom menu item where a user could manually choose a content entity type, then a bundle, and then see the grid. After all, as Seth Godin famously said in his book Linchpin, "Real artists ship."I kept wanting to come back to my original vision, however, so I recently decided to invest some time into making it work. It took some investigation, and IMore

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:

  1. Standardization in multiple projects
  2. Reduction in cognitive load
  3. 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!

Image removed. An example News node on a fresh Drupal starter

A 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:

  1. wrapContainerVerticalSpacing (20px)
  2. wrapContainerVerticalSpacingTiny (2px)
  3. wrapContainerVerticalSpacingBig (40px)
  4. wrapContainerVerticalSpacingHuge (60px)

LN Webworks: Drupal Features:The Essentials You Need to Know

Are You Wondering If Drupal Will Fit in With Your Business or Organization? Look No Further. This comprehensive Drupal guide has been composed by experienced Drupal experts to give a detailed introduction into this popular content management system. Due to Drupal's frequent iterations releases, this guide highlights key features essential for regular CMS users. What Makes a Good CMS? A good CMS serves as the cornerstone of your digital presence, so choosing one requires both technical and commercial considerations. Your CMS selection must address both current business challenges and opportunities while looking toward your long-term digital goals. As you evaluate a content management system, it's important to keep in mind the following aspects when assessing it: functional requirements of the CMS; users' technical skill levels and delivery channels; costs involved and associated with content delivery channels. An ideal CMS will meet all these needs and more while serving as the backbone of your digital strategy.

LN Webworks: The Power of Experience-led E-commerce: Combining Content and Commerce with Drupal

An E-commerce business must create a compelling and engaging shopping experience for attracting and retaining customers. To achieve this, E-commerce sites are increasingly turning to experience-led approaches, combining content and commerce to make shopping enjoyable for shoppers. When it comes to the experience-led approach, Drupal is an excellent choice for businesses. Drupal’s flexibility, scalability, and powerful CMS are tailor-made to engage and delight your customers. In this article, you will learn why Drupal is best for experience-led commerce and how Drupal Ecommerce Development Services can help your business stay ahead in the market.  Why use Drupal for Experience-led Commerce? Drupal has gained significant attention in recent years for its ability to deliver exceptional user experience for E-commerce businesses worldwide. Discover why Drupal commerce is the best fit for building Experience-led commerce: