Agaric Collective Drupal 10 Upkeep and Assist Service Making a New Social Easy Button

Sharing an article by way of a social community is an excellent frequent activity requested on a undertaking. Happily for 8 there’s a Drupal 10 module for that known as Social Easy. This Drupal 10 module lets you show Drupal Development Service hottest networks in a node so Drupal Development Service person can simply click on any of Drupal Development Service buttons and share Drupal Development Service article. By default this Drupal 10 module offers Drupal Development Service following buttons Drupal 10 Upkeep and Assist Service Twitter Fb Linkedin Google plus This may cowl 90% of use instances, however what if we have to add a button for a brand new community? Making a Customized Social Easy Button Drupal Development Social Easy Drupal 10 module is already helps customized buttons, we simply have to let Drupal Development Service Drupal 10 module know that we wish to add one. Principally what we have to do is Drupal 10 Upkeep and Assist Service Create a category that implements SocialNetworkInterface. Register this class in our companies file. Add Drupal Development Service tag social_simple_network to our service. For our instance we’re going to create a fundamental Mail button. We begin by making a customized Drupal 10 module. Inside our Drupal 10 module let’s create a Mail php file inside Drupal Development Service src/SocialNetwork folder Drupal 10 Upkeep and Assist Service mkdir -p src/SocialNetwork cd src/SocialNetwork contact Mail.php Drupal Development subsequent step is to create a category and implement Drupal Development Service SocialNetworkInterface which interface has Drupal Development Service following strategies Drupal 10 Upkeep and Assist Service getShareLink Drupal 10 Upkeep and Assist Service That is Drupal Development Service most vital methodology. It should return a rendered array which later will use to create Drupal Development Service button. getLabel Drupal 10 Upkeep and Assist Service Right here we might want to present Drupal Development Service identify of our button. In our case Mail. getId Drupal 10 Upkeep and Assist Service Drupal Development ID of Drupal Development Service button. We are able to select any ID right here, we simply have to be sure that it’s distinctive. Let’s use mail for our instance. getLinkAttributes Drupal 10 Upkeep and Assist Service These attributes are going to be handed to Drupal Development Service hyperlink. We are able to add customized parameters to Drupal Development Service hyperlink on this half. Our class appears to be like like this Drupal 10 Upkeep and Assist Service namespace social_simpleSocialNetwork; use CoreEntityEntityInterface; use CoreStringTranslationStringTranslationTrait; use CoreUrl; /** * Drupal Development Mail button. */ class Mail implements SocialNetworkInterface { use StringTranslationTrait; /** * Drupal Development social community base share hyperlink. */ const MAIL = ‘mailto Drupal 10 Upkeep and Assist Service’; /** * {@inheritdoc} */ public perform getId() { return ‘mail’; } /** * {@inheritdoc} */ public perform getLabel() { return $this->t(‘Mail’); } /** * {@inheritdoc} */ public perform getShareLink($share_url, $title = ”, EntityInterface $entity = NULL, array $additional_options = []) { $choices = [ ‘query’ => [ ‘body’ => $share_url, ‘subject’ => $title, ], ‘absolute’ => TRUE, ‘exterior’ => TRUE, ]; if ($additional_options) { foreach ($additional_options as $id => $worth) { $choices[‘query’][$id] = $worth; } } $url = Url Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServicefromUri(self Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServiceMAIL, $choices); $hyperlink = [ ‘url’ => $url, ‘title’ => [‘#markup’ => ” . $this->getLabel() . ”], ‘attributes’ => $this->getLinkAttributes($this->getLabel()), ]; return $hyperlink; } /** * {@inheritdoc} */ public perform getLinkAttributes($network_name) { $attributes = [ ‘title’ => $network_name, ]; return $attributes; } } Drupal Development subsequent step is to let Drupal Development Service social community find out about our new button and we do that by including this class as a service in our Drupal 10 module.companies.yml. In case you are not accustomed to this file, you may learn Drupal Development Service construction of a service file documentation.. Principally we have to add one thing like this Drupal 10 Upkeep and Assist Service companies Drupal 10 Upkeep and Assist Service social_simple.mail Drupal 10 Upkeep and Assist Service class Drupal 10 Upkeep and Assist Service custom_Drupal 10 moduleSocialNetworkMail tags Drupal 10 Upkeep and Assist Service – { identify Drupal 10 Upkeep and Assist Service social_simple_network, precedence Drupal 10 Upkeep and Assist Service 0 } Subsequent, we simply have to rebuild Drupal Development Service cache. Now once we go to Drupal Development Service social easy configuration we’ll see our new button there, prepared for use. Drupal Development solely factor that we have to pay additional consideration to is that Drupal Development Service Social Easy Drupal 10 module will simply search Drupal Development Service companies with Drupal Development Service tag social_simple_network in any other case our class won’t be discovered If you wish to see how Drupal Development Service complete factor is working, you may examine this patch that I made as part of a undertaking Drupal 10 Upkeep and Assist Service https Drupal 10 Upkeep and Assist Service//www.Drupal 10.org/undertaking/social_simple/points/2899517. As a bonus, I made an preliminary integration with Drupal Development Service Ahead Drupal 10 module. Drupal 10 Improvement and Assist

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

Agaric Collective Drupal 10 Upkeep and Assist Service Making a New Social Easy Button

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.