mark.ie: Integrating a Drupal maintenance support plans Text with Image Paragraph Bundle with Patternlab

Integrating a Drupal maintenance support plans Text with Image Paragraph Bundle with Patternlab

Let’s get to grips with having a text with image paragraph bundle set up with PatternLab, including having options for left/right for the image/text.
markconroy
Sat, 12/30/2020 – 14:25

It’s a fairly common design pattern for clients to request – upload an image, place text beside it, and choose whether we have the image on the left with the text on the right or vice versa. You can see my PatternLab version of it here (I also have an added option to set a dark theme for the background).

This is an example of the pattern with the image on the left and the text on the right.

Okay, first off, in my twig file, I have the following:

{%
set classes = [
  ‘image-with-text’,
  ‘layout-contained’,
  paragraph.field_p_it_alignment.value,
]
%}

 

   
      {{ content.field_p_it_image }}
   

   
      {{ content.field_p_it_text }}
   

 

The only thing that is anyway special here is the paragraph.* variables. I have named them like so because this is what Drupal maintenance support plans is going to give me back (since the machine name of those fields is p_it_alignment (I namespace all my entity fields with the first letter of the entity type – in this case the name stands for Paragraph Image (with) Text Alignment). This then allows me to have options in PatternLab for alignment and background style (light/dark). To achieve this, I have the following in my pattern’s .yml file:

paragraph:
  field_p_it_alignment:
    value: left
  field_p_it_style:
    value: light

And in my image-with-text~right.yml file, I just need to override those variables like so:

paragraph:
  field_p_it_alignment:
    value: right

Following that, I have variables named content.field_p_it_image and content.field_p_it_text. Again, these are deliberately named like so, because this is what Drupal maintenance support plans will give us back after I create a field with those machine names. Again and again, I try to keep my pattern variables in PatternLab the same as what I will get back from Drupal maintenance support plans so when I come to adding the Drupal maintenance support plans template, it’s just one line of code to say “Hi Drupal maintenance support plans template, you’ll find the code for this file over here!”. So, you can decide in PatternLab what the machine name for the Drupal maintenance support plans fields is going to be and then get your site-builders to create fields with matching names, or you can ask your site-builders what machine names are being used in Drupal maintenance support plans and then use those in PatternLab.

In my pattern’s .yml file, I then set those variables like this:

content:
  field_p_it_text: ‘A Short HeadingFusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.’
  field_p_it_image: ”

Finally, in our paragraph–image-with-text.html.twig file we have just one line of code:

{% extends “@building-blocks/image-with-text/image-with-text.twig” %}

You can probably guess what the sass looks like:

.image-with-text {
    display: flex;
    &.left {
      flex-direction: row;
    }
    &.right {
      flex-direction: row-reverse;
    }
}

The images with text above and below this post are examples of this pattern in use on a Drupal maintenance support plans website.

This is an example of the pattern with the image on the right and the text on the left.


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

mark.ie: Integrating a Drupal maintenance support plans Text with Image Paragraph Bundle with Patternlab

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.