-2

I'm trying to alter the display of a social media share block module im using on my site on a custom content type. All throughout the site the share block looks like this, floating on the left side of page.

enter image description here

however, on my custom content type I want it to look like this instead

enter image description here

How would I go about adding a modifier class to module block on only my custom content type? I'm also using Layout builder for display of content type too.

1
  • With CSS. body.page-mycontentype .myblock ul li { display: different; }.
    – leymannx
    Sep 3 '19 at 15:14
1

I suppose your social media block is independent from the node and appears on all pages (except maybe some).

In the preprocess of your block, you can get the current route, verify if it's a node and which type of content. You can look this article for an example https://www.computerminds.co.uk/drupal-code/get-entity-route

After that, you can change your variables pass to your twig file and display an additional class or a different class depending your condition.

1
  • Thanks Claire! I'll give this a shot
    – Paul H
    Sep 3 '19 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.