Inhalt abgleichen
Drupal.org - aggregated feeds in category Planet Drupal
Aktualisiert: vor 28 Minuten 7 Sekunden

OSTraining: How to Change the Default Text Strings in Drupal 8

15. März 2018 - 16:55

Drupal 8.5 is available now, and we covered some of the key new features.

However, some smaller, but very useful features arrived with 8.5. For example, it's now much easier to translate the default text.

A few years ago, we explained how to translate the default text in Drupal 7. The process was painful! Let me show you how much easier it is in Drupal 8.5.

Matt Glaman: Another AWESOME MidCamp!

15. März 2018 - 11:00
Another AWESOME MidCamp! mglaman Thu, 03/15/2018 - 04:00

 MidCamp 2018 has come and gone. This was the regional Drupal camp's fifth year, and my fourth time attending (missed year one ????). The amazing group of organizers behind the conference makes it one of my favorites. MidCamp is a human first event -- everything is about accessibility.

PreviousNext: Bare Templates: Removing Unnecessary Markup in Twig files

15. März 2018 - 10:48

In most of the projects we build, the HTML markup provided by core just gets in the way. There is way too many wrapper divs. This can cause issues when trying to create lean markup that matches what is produced in a generated styleguide.

In this post, I'll introduce you to the concept of bare templates, and how you can remove unnecessary markup from your Twig templates.

by Pasan Gamage / 15 March 2018

In Drupal 8, a couple of themes are shipped by default to serve a common set of end user needs.

Among them are:

  • Bartik: A flexible, recolourable theme with many regions and a responsive, mobile-first layout.
  • Seven: The default administration theme for Drupal 8 was designed with clean lines, simple blocks, and sans-serif font to emphasise the tools and tasks at hand.
  • Stark: An intentionally plain theme with almost no styling to demonstrate default Drupal’s HTML and CSS.
  • Stable: A base theme. Stable theme aggregates all of the CSS from Drupal core into a single theme. Theme markup and CSS will not change so any sub-theme of Stable will know that updates will not cause it to break.
  • Classy: A sub-theme of Stable. Theme designed with lot of markups for beginner themers.

But in an actual business scenario the requirements and expectations of a client towards the look and feel of the website is far more distinct than the themes that are provided in Drupal core.

When building your site based upon one of these themes it is common to face issues with templating during the frontend implementation phase. Quite often the default suggested templates for blocks, nodes, fields etc. contain HTML wrapper divs that your style guide doesn’t require.

Usually the most effective way is to build themes using the Stable theme. In Stable, the theme markup and CSS are fixed between any new Drupal core releases making any sub-theme to less likely to break on a Drupal core update. It also uses the verbose field template support for debugging.

Which leads us to use bare templates.

What is a bare template?

A bare template is a twig file that has the minimum number of HTML wrappers around actual content. It could be simple as a file with a single content output like {{content.name}}

Compared to th traditional approach, bare templates provide benefits such as:

  • Ease of maintenance: With minimum markup the complexity of the template is much lesser making it easy to maintain.
  • Cleaner Markup: The markup will only have the essential or relevant elements where as in traditional approach there are a lot of wrappers leading to a complex output.
  • Smaller page size: Less markup means less page size.
  • Avoids the need for markup removal modules: With bare markup method we do not need to use modules like fences or display suite. Which means less modules to maintain and less configuration to worry about.
Our Example

We need to create a bare template for type field and suggest it to render only field name and field_image of my_vocabulary taxonomy entity. This will avoid Drupal from suggesting this bare template for other fields belonging to different entities.

Field template

Let's have a look at field template which resides at app/core/themes/stable/templates/field/field.html.twig

{% if label_hidden %} {% if multiple %} {% for item in items %} {{ item.content }} {% endfor %} {% else %} {% for item in items %} {{ item.content }} {% endfor %} {% endif %} {% else %} {{ label }} {% if multiple %} {% endif %} {% for item in items %} {{ item.content }} {% endfor %} {% if multiple %} {% endif %} {% endif %}

As you see there is quite a lot of div wrappers used in the default template which makes it difficult to style components. If you are looking for simple output, this code is overkill. There is however, a lot of valuable information is provided in the comments of field.html.twig which we can use.

{# /** * @file * Theme override for a field. * * To override output, copy the "field.html.twig" from the templates directory * to your theme's directory and customize it, just like customizing other * Drupal templates such as page.html.twig or node.html.twig. * * Instead of overriding the theming for all fields, you can also just override * theming for a subset of fields using * @link themeable Theme hook suggestions. @endlink For example, * here are some theme hook suggestions that can be used for a field_foo field * on an article node type: * - field--node--field-foo--article.html.twig * - field--node--field-foo.html.twig * - field--node--article.html.twig * - field--field-foo.html.twig * - field--text-with-summary.html.twig * - field.html.twig * * Available variables: * - attributes: HTML attributes for the containing element. * - label_hidden: Whether to show the field label or not. * - title_attributes: HTML attributes for the title. * - label: The label for the field. * - multiple: TRUE if a field can contain multiple items. * - items: List of all the field items. Each item contains: * - attributes: List of HTML attributes for each item. * - content: The field item's content. * - entity_type: The entity type to which the field belongs. * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. * * @see template_preprocess_field() */ #} The code Building the hook.

We will be using hook_theme_suggestions_HOOK_alter() to suggest the two fields to use our bare template when rendering.

It is important to note that only these two fields will be using the bare template and the other fields (if any) in that entity will use the default field.html.twig template to render.

my_custom_theme_theme_suggestions_field_alter (&$hooks, $vars){     // Get the element names passed on when a page is rendered.     $name = $vars['element']['#field_name'];     // Build the string layout for the fields.     // :::     $bare_hooks = [         'taxonomy_term:my_vocabulary:teaser:name',         'taxonomy_term:my_vocabulary:teaser:field_logo',     ];     // Build the actual var structure from second parameter     $hook = implode(':', [         $vars['element']['#entity_type'],         $vars['element']['#bundle'],         $vars['element']['#view_mode'],         $vars['element']['#field_name'],     ]);     // Check if the strings match and assign the bare template.     if (in_array($hook, $bare_hooks, TRUE)) {         $hooks[] = 'field__no_markup';     } }

The hook key field__no_markup mentioned in the code corresponds to a twig file which must reside under app/themes/custom/my_theme/templates/field/field--no-markup.html.twig

Debugging Output

In order to see how this is working, we can fire up PHPStorm and walk the code in the debugger.

As you can see in the output below, the implode() creates the actual var structure from the second parameter. We will use this to compare with the $bare_hooks array we created  fields specific to content entity types that we need to assign the bare template.

Note: As best practise make sure you pass a third argument TRUE to in_array(). Which will validate the data type as well.

 

Bare Template Markup

The following is the contents of our bare template file. Notice the lack of any HTML?

{# /** * @file * Theme override to remove all field markup. */ #} {% spaceless %} {% for item in items %} {{ item.content }} {% endfor %} {% endspaceless %}

Bare templating can be used for other commonly used templates as well. To make it render a minimal amount of elements.

Conclusion

We can always use custom templating to avoid getting into complicated markups. And have the flexibility to maintain the templates to render for specific entities.

Resources Tagged Style Guides, Twig

Amazee Labs: Launching Kinderregion

15. März 2018 - 10:04
Launching Kinderregion

We’re super excited! The new Kinderregion website has finally launched and brings their motto of Great parents need great tips for trips to life. 

It showcases a wide variety of exciting activities for kids. Families living in Switzerland can now plan a fun day for the whole family by browsing the site. Built on the same framework as Zurich Tourism, Kinderregion showcases highly engaging content that is structured, helpful and of interest to the user. 

Nicole Blum Thu, 03/15/2018 - 09:04 The idea

By building Kinderregion on the same framework as Zurich Tourismus, the new site would have to to offer highly valuable content in a structured and appealing manner. The events section should benefit from the main site’s interactive features such as instant filters and an interactive map based on React. As Kinderregion is a content heavy website, we would need to allow content editors to easily change the front page and the menu. Similarly, we would need the ability to deploy code and configuration changes without losing the customisations done by the client. Just as with zuerich.com, our idea to solve this was using the Panels ecosystem.

The most challenging part of the project

Creating something complex on a tight budget can be tricky. We were, however, able to solve this by re-applying certain existing elements throughout the entire site. Along the way, our team learned a bunch of new things and strengthened their skill sets even more. One highlight being how to override existing styling when working with the sub-template.

The Result

We implemented Kinderregion as a subsite of the main Zurich Tourism website, based on the Domain module. This allows us to share mission content across both websites and most importantly, benefit from the infrastructure that the Zurich Tourism Website already provides. We also added to the permission system and the reactive events filter section on the Landing pages.

The same layout used for zuerich.com is applied to Kinderregion, and is based on the "Panels suite". It is built using "Panels everywhere", which enables us to export the site layout and it’s domain-specific variants to features. Following the same logic, the home page is based on a panel page with different variants for each domain. The mega menu is composed of mini panels, loading into specific menu items through the use of the menu mini panel module. The consistent use of panels for all of these different areas allows the content editors to easily update the front page and makes it possible for us to deploy code and configuration changes, without losing the customisations done by the client. Hence, the sites heavy content is displayed in a coherent and captivating manner.

We loved collaborating with Zurich Tourism again on this new project and also really enjoyed working alongside the creative agency Rosarot Ideennetz throughout the process. All input and guidance has been super valuable and highly appreciated.   

Agiledrop.com Blog: AGILEDROP: Our blog posts from February

15. März 2018 - 3:09
You have already seen what Drupal blogs were trending in the previous month, and now it is time to look at all our blog post from February.    The first blog post in February was What can Drupal agencies expect in 2018 by our Commercial director Iztok. He looked at the technology trends and how they are changing, how can those changes influence on Drupal agencies and what can we expect in the future. What are the conclusions from Drupal Business Survey, including responses from 200 different Drupal agencies? Iztok did a SWOT analysis based on digital agency reports from 2017 and outlooks… READ MORE

MTech, LLC: Drupal 8 Contrib Upgrade Status

14. März 2018 - 22:13
Drupal 8 Contrib Upgrade Status

One of the things I constantly get asked about in the Drupal 8 migrate space is when will migrate be ready for use. With the API being marked stable in 8.5.0, now is a good time to consider upgrading. Upgrading a D6 or D7 site should be ready, especially if you have mainly core modules in use. However, what about when your site used a contrib module or two or ten?

Lucas Hedding Wed, 03/14/2018 - 14:13

roomify.us: Tutorial: equipment library reservations with Drupal 8 & BEE

14. März 2018 - 17:51
BEE makes it easy to quickly implement all kinds of booking & reservation use cases. We've created a new video that walks through setting up BEE to take reservations for an equipment library.

Fuse Interactive: Drupal 8 and iMIS - A SAML Story

14. März 2018 - 17:19
Drupal 8 and iMIS - A SAML Story In the summer of 2017, Fuse started work on a new website for the BC Pharmacy Association (BCPhA). This new website was to be built in Drupal 8 and was part of BCPhA’s overhaul of their digital strategy. Among the various requirements of the build, was an integration with an existing third-party system BCPhA used to manage their members. This system had been in use by BCPhA for a while and their existing website integrated into this system. John Wiebe Wed, 03/14/2018 - 08:19

Mediacurrent: How to Make the Most of Your DrupalCon BOF Experience

14. März 2018 - 16:56

DrupalCon Nashville is coming up and that means another chance to create deeper connections with the Drupal community by attending or facilitating Birds of a Feather sessions (BOFs). The DrupalCon team has summarized what a BOF is on the DrupalCon website:

Birds of a Feather sessions (or BOFs) are informal gatherings of like-minded individuals who wish to discuss a certain topic without a pre-planned agenda. BOFs allow groups to meet and discuss issues and talk out ways to move the project forward. Have fun and learn! BOFs exist to provide attendees with an inclusive, informal environment in which to share ideas freely. BOFs can be serious, and a great way to gather the people you’ve been working remotely with on a project in a space to deep dive on a topic, but they can also be fun as well. Knitting BOF? Why not?!

At this point, you might think BOFs sound interesting, but why would you consider attending a BOF at DrupalCon?

Since regular DrupalCon sessions are recorded and BOFs are not, consider attending BOFs you find interesting in preference to a session - you can always watch the recording later! BOFs are great subjects for blog posts, so take notes and write about them.

  1. BOFs are not presented lecture style and allow for a high-level of interactivity between the facilitators and other participants. The facilitator generally kicks off the topic and framework for the discussion, allowing everyone to discuss the ideas.
     
  2. Due to the interactivity, there is a chance to meet and get to know others in a way that you might not be able to do in a DrupalCon session.
     
  3. Some BOFs are focused on discussions around and determining best practices. These are great ways to look into your processes and know what you are doing well and what you can do to improve. Organizations looking for the value in sending you to DrupalCon can’t ask for more than the opportunity for immediate process improvements post-DrupalCon.
     

Let’s shift gears to BOF planning and facilitation. Why would you want to host a BOF? One reason is that you may have been one of the 900+ session proposal submitters that were not selected - turn your lecture style idea into a BOF discussion! Another reason to host is that you can ensure that a topic you have a passion about has DrupalCon representation, drawing in participants with similar interests. A BOF is also a great way to practice public speaking and prepare for a future DrupalCon session opportunity!

If you are interested in facilitating a BOF, here are some tips to make sure you get the most out of it and ensure that participants have the opportunity for a positive experience.

  1. As a first step, check out the DrupalCon suggestions: How to Run a Successful BOF
     
  2. Plan your BOF with a clear and concise abstract on what you want to discuss. You are marketing your session against others sessions happening at the same time so make sure to attract participants.
     
  3. Submit your idea as soon as possible! The BOF schedule fills up quickly! There is nothing wrong with pulling together an informal BOF in a hallway or lunch table if spaces fill up.
     
  4. When the BOF begins, introduce yourself and clearly state the topic and format for the BOF so participants know how it will work.
     
  5. Have a brief topic discussion to kick off the BOF. This can be an example of your personal experience around the topic, including successes and challenges. This helps make participants comfortable and gives them time to think about questions and ideas to contribute. Keep it brief so you have time for others to participate.
     
  6. After the short introduction discussion, start by asking an icebreaker question to get participant involvement going. It is a good idea to have a list of related questions and discussion items ready in case you need to keep the conversation moving. Many times, the BOF will take off organically and there will be no need to rely on those techniques.
     
  7. Remember, you are the facilitator. It is your job to help give everyone a chance to be involved and to guide the BOF back to the topic if it gets off track a bit.
     
  8. End the BOF by thanking everyone for coming and consider offering some resources or related research to continue the conversation.
     

If you are interested in submitting a BOF idea at DrupalCon Nashville, BOF scheduling opens on March 14th, 2018. Visit https://events.drupal.org/nashville2018/birds-feather for submission details. Remember that the Code of Conduct is in effect at BOFs and throughout DrupalCon events. We hope to see you at a BOF at DrupalCon Nashville!

Additional Resources
Mediacurrent to Present 7 Sessions at Drupalcon Nashville | Mediacurrent Blog
Drupalcon: Not Just for Developers | Mediacurrent Blog 

Lucius Digital: Login without password most secure | Wait.. what?

14. März 2018 - 16:36
Never having to remember your Drupal passwords again, how great would that be? It appears the working without passwords even is the most secure option. But how is that possible?

ComputerMinds.co.uk: Class naming for Javascript development in Drupal

14. März 2018 - 16:33
Class naming for Javascript development in Drupal Steven Jones 14th Mar 2018

We've settled on what we think is a best practice for class naming for Javascript in Drupal – let me explain what I mean and then talk you through our reasoning.

Read more

Jacob Rockowitz: My three mistakes in regards to the Contribute module and Drupal

14. März 2018 - 15:38

Figuring out how to improve the sustainability of Drupal needs to be an ongoing discussion with a gradually evolving approach. It is important that Drupal and every Open Source project has an ongoing discussion about sustainability where everyone can share their views and experiment with new ideas and approaches.

The Contribute module is an experiment that ignited a discussion. It is important to recognize what works and what doesn’t, acknowledge and learn from mistakes, and continue to have this discussion. Sure, there will be varying opinions and results, but the discussion must always be permitted to happen.

My first mistake: The Contribute module is definitely not a technical dependency

The Webform module doesn't depend on the Contribute module to function properly. Honestly, I did not expect that adding this dependency would be so disruptive. This was my first mistake... adding any new dependency is disruptive especially if someone is managing a large multisite installation.

Conceptually, the Contribute module's message is for the broader Drupal community. This message is originating from my work on the Webform module, therefore it should have stayed in the Webform module. In time, I hope this message gradually works its way through the Drupal core issue queue and reaches the entire Drupal community.

My second mistake: Not fully thinking through my approach

How people interact and communicate in online communities is interesting (to say the least). The truth is people say and act in ways that they would never do in person. I am a born and raised New Yorker, which requires a thick skin to defend yourself, yet at the same time you need empathy to get along with so many different groups of people.

My first mistake...Read More

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules

 

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules

 

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules

 

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules

 

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules

 

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules

 

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules

 

ADCI Solutions: 10 free Drupal modules for integration with Social Media Networks

14. März 2018 - 13:03

Social media integrations make your website more captivating and user-friendly. No matter who you are - a plastic surgeon, a psychologist, an owner of an online store, or a real estate consultant - there should be an integration with social media on your site.

We have collected 10 free Drupal modules allowing to implement an integration with Instagram, Twitter, Facebook and other social networks.

 

Check the modules