d8-contrib-modules / addthis Goto Github PK
View Code? Open in Web Editor NEWPort AddThis to D8
License: GNU General Public License v2.0
Port AddThis to D8
License: GNU General Public License v2.0
Abstract out the BasicButton and BasicToolbox settings forms so that they can be reused in the Field & Block implementations.
Hello,
I've try this module for drupal 8 (8.1.8) and when I create a addthis field I've go this fatal error :
Fatal error: Declaration of Drupal\addthis\Plugin\Field\FieldFormatter\AddThisFormatter::viewElements() must be compatible with Drupal\Core\Field\FormatterInterface::viewElements(Drupal\Core\Field\FieldItemListInterface $items, $langcode) in /modules/addthis/src/Plugin/Field/FieldFormatter/AddThisFormatter.php on line 39
There are several form/styling issues on the AddThis Admin page. (admin/config/user-interface/addthis)
Currently we are using a helper method in the AddThis.php class to provide the form elements for the AddThisBasicButton and AddThisBasicToolbox config options which are shared between formatter and block.
After talking to Kris yesterday, he suggested we take a look at a partial form or traits. He mentioned the form could be problematic because of how it gets pulled in and the fact we only need partial form elements that will be shared.
After adding addthis field to a content type and try to visit form display I get following error:
PHP Fatal error: Declaration of Drupal\\addthis\\Plugin\\Field\\FieldFormatter\\AddThisBasicButtonFormatter::viewElements() must be compatible with Drupal\\Core\\Field\\FormatterInterface::viewElements(Drupal\\Core\\Field\\FieldItemListInterface $items, $langcode) in /modules/contrib/addthis/src/Plugin/Field/FieldFormatter/AddThisBasicButtonFormatter.php on line 26
Fix:
$langcode
parameter to viewElements() method of 3 FieldFormatters that are implemented in this module.The Google Analytics integration with the AddThis module was modified to D8 constructs, but the integration has not been fully tested with the D8 Google Analytics module (currently only a -dev branch).
This needs to be tested and the implementation improved as needed to support this functionality.
Abstract out the Field Formatters for AddThisBasicButtonFormatter.php and AddThisBasicToolboxFormatter.php into the addthis_displays module.
We want to keep the basic module setup as:
In the Drupal 7 version of AddThis the block can be configured based on any FieldFormatter that is defined for AddThis. With the changes in D8, I was not able to reproduce this functionality.
Revise the way the global AddThis libraries are added to the page. Using hook_page_attachments() will break the aggregation. Investigate only loading this library when we are rendering an AddThis element to the page.
The hover menu on the "Share" button is currently broken. It is displaying in the middle of the screen instead of relative to the button. The formatting is broken as well.
Fix the rendering of AddThisBasicToolbox in the block and field to match the HTML in the D7 module. Ensure that it respects configuration settings and prints the proper markup.
TODO in modules/addthis/src/Services/AddThisScriptManager.php
private function getJsAddThisConfig() { }
Per @damontgomery's comment on our last PR:
So, the recommended way to access the language setting is to get a language handler service using dependency injection. The use is actually shown here, https://www.drupal.org/node/2133171
I think you'd actually want to inject Drupal\Core\Language\LanguageManager using language_manager as the service name or @language_manager as the argument to this service. Then you can assign this to $this->languageManager and get the language with the method $this->languageManager->getCurrentLanguage()
The AddThis class was created as a helper class in the D7 version of the module. This class has been significantly down-sized with the port to D8 since the new OO design allowed for better abstraction.
The Smart Layers API allows you to have more control over how AddThis functions on your website. For more information see: http://support.addthis.com/customer/portal/articles/1200473-smart-layers-api
Initial thoughts on how to do this and to discuss further with @nerdstein and @damontgomery :
Option 2:
The validation function used for the BasicToolbox form is currently in addthis.module. Since this is not a hook, it should not live in the .module file.
Revist the field implementations to use the new paradigm that was defined in the AddThisBlock. Instead of calling AddThis:: class to get markup, revise to take advantage of the renderElements that were created.
The Advanced AddThis Settings page is not accessible through the configuration menu.
D7 version of AddThis implemented a block that allowed users to chose a field formatter to render it. The block used the default field settings to control the rendering.
D8 implements blocks as plugins which gives more flexibility in its configuration. It would allow for more flexibility if we allow the block to be fully configurable instead of depending on a field formatter for the configuration and rendering.
Permissions for menu paths are currently set to "administer site configuration". This should be updated to a custom addthis permission.
There are currently no source, process, or destination plugins making it difficult to move existing data from d7 to d8 for this module.
The rendering of the AddThis elements does not look good OOTB. Need to investigate to see if this is caused by the RenderElement markup, Additions needed to the Twig Templates or some custom CSS that needs to be added and loaded.
D8 provides a robust URL class as part of core. Look at replacing AddThisWidgetJsURL.php class with the core URL class.
Driving Factors: All display logic should be handled in the theme layer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.