Categories
CMS Drupal Mastering Development

twig : getting the value of src attribute in drupal 8

I am having hard time with getting the value of YouTube video thumbnail url In order to use it as background image in template I got video content type I got a field called ‘field_url_vid2’ (machine name) It is core media remote video field The output format is thumbnail In twig : Gives me the […]

Categories
CMS Drupal Mastering Development

Custom block disable caching?

I’ve created a custom module to show On This Days in a block but they are not changing each day until I flush the caches. I call the entity: public function build() { $query = \Drupal::entityQuery(‘node’); $query->condition(‘status’, 1); $query->condition(‘type’, ‘on_this_day’); $query->condition(‘field_filter_date’, ‘-‘ . date("m-d"), ‘CONTAINS’); $entity_ids = $query->execute(); … and then return from the build […]

Categories
CMS Drupal Mastering Development

Drupal security update 7.73

Part of Drupal security update 7.3 (https://www.drupal.org/project/drupal/releases/7.73) below information is mentioned, If you are using jQuery’s AJAX API for user-provided URLs in a **contrib or custom module**, you should review your code and set "jsonp: false" where this is appropriate. Drupal 7 sites should also pass such URLs through the new Drupal.sanitizeAjaxUrl() function. Whether we […]

Categories
CMS Drupal Mastering Development

How to convert full site in html static file in Drupal 8? or Is there any API for Drupal 8?

I have tried Static Generator Module but that also doesn’t convert the full site in html page. Also i have tried Tome module giving issue while creating user as below error. The website encountered an unexpected error. Please try again later. Drupal\Core\Entity\EntityStorageException: Failed to create config directory ../content in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). Drupal\Core\Config\FileStorage->write() […]

Categories
CMS Drupal Mastering Development

How to convert full site in html static file in Drupal 8? or Is there any API for Drupal 8?

I have tried Static Generator Module but that also doesn’t convert the full site in html page. Also i have tried Tome module giving issue while creating user as below error. The website encountered an unexpected error. Please try again later. Drupal\Core\Entity\EntityStorageException: Failed to create config directory ../content in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). Drupal\Core\Config\FileStorage->write() […]

Categories
CMS Drupal Mastering Development

how to migrate multiple taxonomy terms with entity lookup plugin

Im using the code below to migrate a taxonomy term with multiple values and I get this error below. is there a way to migrate multiple taxonomy terms with this plugin? : InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded with an array of values. in [error] /var/www/html/docroot/core/lib/Drupal/Core/Database/Connection.php:744 field_states_operating_in: – […]

Categories
CMS Drupal Mastering Development

Module listing page leading to php timeout

I am noticing that when I open the Modules listing page – admin/modules/ it leads to php timeout. There was no problem in listing out all the modules with drush. On opening the Modules listing Form in the core. \Drupal\system\Form\ModulesListForm I traced the problem to the following loop in the form. $form[‘modules’][‘#tree’] = TRUE; foreach […]

Categories
CMS Drupal Mastering Development

How to display a search form on add/media/externalsource?

I want to fetch images from an external source and upload it to the Drupal media library as media entity. So I have created a custom media source plugin for this. namespace Drupal\my_module\Plugin\media\Source; use Drupal\media\MediaInterface; use Drupal\media\Plugin\media\Source\OEmbed; /** * Implementation of an oEmbed external source. * * @MediaSource( * id = "oembed:external", * label = […]

Categories
CMS Drupal Mastering Development

Is there a way to get the controller class from a Request object or any other service class?

Background: My controller class holds some not so easy logic to receive some data from a route parameter but in a block plugin I need this data. As this block will only be rendered on this specific route I would like to simply get the controller of the route from within of this block plugin […]

Categories
CMS Drupal Mastering Development

Is there a way to get the controller class from a Request object or any other service class?

Background: My controller class holds some not so easy logic to receive some data from a route parameter but in a block plugin I need this data. As this block will only be rendered on this specific route I would like to simply get the controller of the route from within of this block plugin […]