Drupal

Inline View Modes

New Drupal Modules - 27 November 2016 - 1:11pm

The Inline View Modes module will allow for content authors to select a View Mode to render an entity with when adding entity references.

Initial development of this module happening at https://github.com/himerus/inline_view_modes.

Categories: Drupal

DataSmith: Inconsistent nofollow handling in Drupal input formats

Planet Drupal - 27 November 2016 - 11:18am
Inconsistent nofollow handling in Drupal input formats The Problem

Working on setting up commenting, which is highly suggested for sites who's content appears on Drupal Planet, I came across a bit of a confusing situation in regard to URLs in content. When using the "Limit allowed HTML tags and correct faulty HTML" filter, one of the option is to add rel="nofollow" attributes to anchor tags. However, in the default Plain Text format, the "Convert URLs into links" filter does not provide that option. So if a user types in an HTML anchor, nofollow gets added. But if they type in a plain URl, it gets converted to an HTML anchor without the nofollow.

To illustrate, if I allow anchor links to be entered as html and set the option to add rel=nofollow and I also enable the filter to convert URLs to links, if a user enters:

www.nytimes.com Another NY Times link

The output HTML in the comment is:

https://www.nytimes.com
Another NY Times link

For commenting, I really want to tighten permissions down as far as I can to avoid potential security risks, so the Plain Text format with the "Display any HTML as plain text" filter is the best choice1. However, for usability I do want URLs converted to links. But I also want those links set to nofollow for link fraud prevention2.

By playing with format filter configurations and ordering I was able to make a solution that works (albeit a little janky-ly), but it sure feels like this is an area where a core patch could improve the situation. If I have time one day maybe I'll work on that3.

Solution

The solution I came up with is to set the following filters on the input format (the order is significant):

  1. Display any HTML as plain text
  2. Convert URLs into links
  3. Convert line breaks into HTML (i.e.
    and

    )

  4. Limit allowed HTML tags and correct faulty HTML

Then for the allowed HTML tags, I allowed <a href hreflang> <p> <br> and checked the `Add rel="nofollow" to all links` option.

The result is that user entered HTML is rendered as plain text, then URLs and line brakes get converted to HTML, and finally the Limit allowed HTML filter double checks the markup and adds `rel="nofollow"` to anchor tags.  So given a user input comment like in the screen shot below, the resulting HTML is:

www.nytimes.com
<h2>This should not be displayed as an h2 element.</h2>
<a href="If" rel="nofollow">www.example.com">If this is a link to example.com and not www.nytimes.com, you've failed.</a>
Comment preview showing the user entered comment, the resulting comment, and the help text.

Now, this solution is not perfect. Mostly, it's hinky to set up and I hate that I have to allow any HTML, even if user input is first stripped to plain text. Secondly though, it's also a user experience problem. As you can see in the picture above, the help text says that no html is allowed and that the anchor, break, and paragraph tags are allowed.

Footnotes

1. using the core commenting facility at least. Add on tools like Disqus obviate the issue but I don't want to go that route. I also don't want to require (or even allow) users to register before commenting. And yes, I do require approval of comments before they are visible, but I don't want to have to remember to add rel=nofollow in links.

2. Yes. I want to eat my cake and have it too.

3. I was put on this earth to achieve certain things. At this point I'm so far behind I'll never die.

Barrett Sun, 11/27/2016 - 13:18 Tags Add new comment
Categories: Drupal

Drupal Modules: The One Percent: Drupal Modules: The One Percent — Sticky Navigation (video tutorial)

Planet Drupal - 27 November 2016 - 9:39am
Drupal Modules: The One Percent — Sticky Navigation (video tutorial) NonProfit Sun, 11/27/2016 - 11:39 6

Here is where we look at Drupal modules running on less than 1% of reporting sites. Today we'll consider Sticky Navigation, a module which allows you to easily ensure your navigation remains within the viewport.

Categories: Drupal

Extended Entity Access for Routes

New Drupal Modules - 27 November 2016 - 6:32am

Simplify per-bundle entity access checking for routes. Example: _entity_access: <ENTITY_TYPE>[:<BUNDLE>].<OPERATION>.

From the developer perspective, this module - just improvement of existing access_check.entity service. Default implementation - \Drupal\Core\Entity\EntityAccessCheck - overridden and empowered with possibility to verify entity bundle, if it specified. That's all.

Categories: Drupal

Surveypal

New Drupal Modules - 26 November 2016 - 6:04am

This module allows you to integrate Surveypal to your site. This means you can show your Surveypal surveys on your Drupal website using your personal API key.

Categories: Drupal

Surveyal

New Drupal Modules - 26 November 2016 - 3:29am
Categories: Drupal

Justin Winter: shasum Checksum function

Planet Drupal - 25 November 2016 - 4:00pm
##New PHPStorm Version released today.##
Categories: Drupal

Drupal Modules: The One Percent: Drupal Modules: The One Percent — Field Display Label (video tutorial)

Planet Drupal - 25 November 2016 - 10:00am
Drupal Modules: The One Percent — Field Display Label (video tutorial) admin_gg Fri, 11/25/2016 - 12:00 5

Here is where we look at Drupal modules running on less than 1% of reporting sites. Today we'll consider Field Display Label, a module which allows you to set different field labels for your creation and display pages.

Categories: Drupal

TimOnWeb.com: JQuery.cookie in Drupal 7

Planet Drupal - 25 November 2016 - 8:06am

A quick tip for all Drupalistas outhere: if you want to use jQuery.cookie in your project, you actually don't have to download and install the library. jQuery.cookie is a part of Drupal 7 and can be included as easy as typing: 

  1. drupal_add_library('system', 'jquery.cookie');

Wondering to ...

Read now

Categories: Drupal

Back to school

Dries Buytaert - 25 November 2016 - 7:58am

Last week I presented at the University of Antwerp, my alma mater. I was selected to be the 2016/2017 ambassador of the alumni and was asked to talk about my career and work. Presentations like this are a bit surreal because I still feel like I have a lot to learn and accomplish. Deep down I'll always be searching for something more. I want my life and career to be meaningful and creative, and full of laughter and friends. This presentation was very special as it was attended by my parents, friends from high school and college, professors whose classes I attended 20 years ago and the university's rector or chancellor, Herman Van Goethem. It was great to laugh and catch-up with old friends and family, and it felt meaningful to share some of my lessons learned to a group of young students.

The university's rector or chancellor, Herman Van Goethem, introducing me. My parents sitting on the front row. Me with some of my friends from high school that I hadn't seen in 20 years!
Categories: Drupal

Back to school

Dries Buytaert - 25 November 2016 - 7:58am

Last week I presented at the University of Antwerp, my alma mater. I was selected to be the 2016/2017 ambassador of the alumni and was asked to talk about my career and work. Presentations like this are a bit surreal because I still feel like I have a lot to learn and accomplish. Deep down I'll always be searching for something more. I want my life and career to be meaningful and creative, and full of laughter and friends. This presentation was very special as it was attended by my parents, friends from high school and college, professors whose classes I attended 20 years ago and the university's rector or chancellor, Herman Van Goethem. It was great to laugh and catch-up with old friends and family, and it felt meaningful to share some of my lessons learned to a group of young students.

The university's rector or chancellor, Herman Van Goethem, introducing me. My parents sitting on the front row. Me with some of my friends from high school that I hadn't seen in 20 years!
Categories: Drupal

Ixis.co.uk - Thoughts: Social Media Cards: Metatag and semantic data

Planet Drupal - 25 November 2016 - 5:41am

One requirement for our new Drupal 8 site was to implement the necessary markup to provide enough semantic data for services like Twitter, LinkedIn and Facebook to grab the appropriate node data (title, body and image) when sharing posts.

The Twitter developers documentation states that "with Twitter Cards, you can attach rich photos, videos and media experience to Tweets that drive traffic to your website. Simply add a few lines of HTML to your webpage, and users who Tweet links to your content will have a "Card" added to the Tweet that's visible to all of their followers." Facebook have a similar feature and corresponding documentation, as do LinkedIn.

Fortunately with the Metatag module enabling this functionality in Drupal 8 was a relatively painless task! All that was required was to install and enable the Metatag and Metatag: Twitter Cards modules (we're using 1.0-beta10 at the time of writing) and configure some basic, content-global settings.

Essentially, we ensure the card type is set to "Summary card" and that the description uses the [node:summary] token. We also want to provide an image for the summary card. We could provide the "Image URL" in the Twitter card setup which defines the twitter:image meta tag, however Facebook and LinkedIn use Open Graph for cards and we’d also have to provide the og:image metatag too.

This would cause two meta tags to be present in the header containing the same image URL, wasting bandwidth. Luckily, Twitter will fall back to the Open Graph tag if the twitter:image tag is not present so we only have to configure og:image tag.

We also configured several other Open Graph meta tags to support Facebook and LinkedIn.

We have only configured a subset of the tags available, but this gave us the basic card functionality we were after.

There are tools available to aid in development - allowing you to validate the meta tags and how they will render on social networks.. Your site has to be publicly accessible for these to work.

There are plenty of other guides available if you want more details about what you can do with the Metatag module, try these links:

Categories: Drupal

UC Mailchimp Pane

New Drupal Modules - 25 November 2016 - 5:33am

Mailchimp Checkout Pane for Ubercart. The module is compatible with Mailchimp 3.x and 4.x.

Categories: Drupal

Cheeky Monkey Media: The Secret to Branding DrupalCon: A Stunning Example of a Brand and Web Style Guide

Planet Drupal - 24 November 2016 - 2:33pm
The Secret to Branding DrupalCon: A Stunning Example of a Brand and Web Style Guide chris Thu, 11/24/2016 - 22:33

Cheeky Monkey Media has been involved in the design and creation of the Drupal Association's North American DrupalCons since 2015.

  • DrupalCon Los Angeles in 2015 was inspired the work of Shepard Fairey and his propaganda/street art stylings.
  • DrupalCon New Orleans in 2016 was inspired by the rich French history and wrought iron that is so prevalent in New Orleans.
  • The upcoming DrupalCon in Baltimore in 2017 draws on the work of Edgar Allan Poe, and has a mysterious, almost moody edge to it.

Events of this scale take months of planning and preparation. The process and relationships between planning groups are key. The trick, however, is keeping all the moving pieces and deliverables (from the pins that get handed out to the signage guides the attendees to the website that handles all the registrations) consistent and on brand. That’s where our secret resource, the brand and web style guide, comes in.

Categories: Drupal

Lullabot: Past, Present, and Future of Drupal with Dries Buytaert and Matthew Tift

Planet Drupal - 24 November 2016 - 1:00pm
Matt and Mike talk with Drupal project lead Dries Buytaert and senior developer Matthew Tift to talk about the history of Drupal, what's currently going on, and what the future holds.
Categories: Drupal

Cision Feeds

New Drupal Modules - 24 November 2016 - 12:19pm

This module is extending the current Feeds module with a new fetcher and parser plugin for Cision feeds.

Dependency

Feeds module.

Categories: Drupal

Persist payment controller_data

New Drupal Modules - 24 November 2016 - 9:04am

This is a small utility addon for Payment. It simply makes the $payment->controller_data persistent. This reduces boiler-plate code in downstream payment controller implementations.

At some point this functionality may become part of the main payment module - see #2824638: Persist $method->controller_data.

Categories: Drupal

qed42.com: Implementing #autocomplete in Drupal 8 with Custom Callbacks

Planet Drupal - 24 November 2016 - 8:29am
Implementing #autocomplete in Drupal 8 with Custom Callbacks Body

Autocomplete on textfields like tags / user & node reference helps improve the UX and interactivity for your site visitors, In this blog post I'd like to cover how to implement autocomplete functionality in Drupal 8, including implementing a custom callback

Step 1: Assign autocomplete properties to textfield

As per Drupal Change records, #autocomplete_path has been replaced by #autocomplete_route_name and #autocomplete_parameters for autocomplete fields ( More details -- https://www.drupal.org/node/2070985).

The very first step is to assign appropriate properties to the textfield:

  1. '#autocomplete_route_name':
    for passing route name of callback URL to be used by autocomplete Javascript Library.
  2. '#autocomplete_route_parameters':
    for passing array of arguments to be passed to autocomplete handler.
$form['name'] = array( '#type' => 'textfield', '#autocomplete_route_name' => 'my_module.autocomplete', '#autocomplete_route_parameters' => array('field_name' => 'name', 'count' => 10), );

Thats all! for adding an #autocomplete callback to a textfield. 

However, there might be cases where the routes provided by core might not suffice as we might different response in JSON or additional data. Lets take a look at how to write a autocomplete callback, we will be using using my_module.autocomplete route and will pass arguments: 'name' as field_name and 10 as count.

Step 2: Define autocomplete route

Now, add the 'my_module.autocomplete' route in my_module.routing.yml file as:

my_module.autocomplete: path: '/my-module-autocomplete/{field_name}/{count}' defaults: _controller: '\Drupal\my_module\Controller\AutocompleteController::handleAutocomplete' _format: json requirements: _access: 'TRUE'

While Passing parameters to controller, use the same names in curly braces, which were used while defining the autocomplete_route_parameters. Defining _format as json is a good practise.

Step 3: Add Controller and return JSON response

Finally, we need to generate the JSON response for our field element. So, proceeding further we would be creating AutoCompleteController class file at my_module > src > Controller > AutocompleteController.php.

<?php namespace Drupal\my_module\Controller; use Drupal\Core\Controller\ControllerBase; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Drupal\Component\Utility\Tags; use Drupal\Component\Utility\Unicode; /** * Defines a route controller for entity autocomplete form elements. */ class AutocompleteController extends ControllerBase { /** * Handler for autocomplete request. */ public function handleAutocomplete(Request $request, $field_name, $count) { $results = []; // Get the typed string from the URL, if it exists. if ($input = $request->query->get('q')) { $typed_string = Tags::explode($input); $typed_string = Unicode::strtolower(array_pop($typed_string)); // @todo: Apply logic for generating results based on typed_string and other // arguments passed. for ($i = 0; $i < $count; $i++) { $results[] = [ 'value' => $field_name . '_' . $i . '(' . $i . ')', 'label' => $field_name . ' ' . $i, ]; } } return new JsonResponse($results); } }

We would be extending ControllerBase class and would then define our handler method, which will return results. Parameters for the handler would be Request object and arguments (field_name and count) passed in routing.yml file. From the Request object, we would be getting the typed string from the URL. Besides, we do have other route parameters (field_name and Count) on the basis of which we can generate the results array. 

An important point to be noticed here is, we need the results array to have data in 'value' and 'label' key-value pair as we have done above. Then finally we would be generating JsonResponse by creating new JsonResponse object and passing $results.

That's all we need to make autocomplete field working. Rebuild the cache and load the form page to see results.

PURUSHOTAM RAI Thu, 11/24/2016 - 21:59
Categories: Drupal

Apachesolr Views Rendered Entity

New Drupal Modules - 24 November 2016 - 4:26am

By default the Apachesolr Views module renders fields that are in the Solr-index.
This module adds a Views row plugin for 'Rendered entity'.
That way you can leverage modules like Display Suite for presenting your search-results.

The code is a straight copy from this issue:
https://www.drupal.org/node/2111363

Categories: Drupal

Favorite Widget

New Drupal Modules - 23 November 2016 - 11:21pm

This project uses jQuery Favorite Widget plugin that allows users to put content to their favorites that are stored in a cookie.

For Drupal, there are modules available that allows you to reach this functionality such as Flag. This module however is useful when you want to provide this functionality:

Categories: Drupal

Pages

Subscribe to As If Productions aggregator - Drupal