vijaycs85
  • Member for 9 years, 4 months
  • Last seen this week
Views Data Export print feed icon in template file
0 votes

Another alternative (if you can't override the views-view.html.twig) would be to use a preprocess function: // mysite.module /** * Implements hook_preprocess_views_view(). */ function ...

View answer
How to display a node edit form in custom URL
1 votes

Create a new menu item in a custom module # mymodule.routing.yml mymodule.banner_settings_form: path: /admin/config/system/banner-settings/{node} defaults: _entity_form: node.edit # Copy ...

View answer
Field weight in display mode is not respected on custom entity
2 votes

After debugging the Drupal\Core\Field\FormaterBase on how the fields getting rendered, it seems the weights are getting applied to each field in Drupal\Core\Entity\EntityViewBuidler, but they are not ...

View answer
Circular dependency on base fields' module
1 votes

Since the dependency is purely on the reference field, we could add the target_type later. For example, setting the target_type at the bundleFieldDefinition wouldn't throw the install's error and set ...

View answer
Using a custom field as a sub-field in another custom field
0 votes

Basically, the question is how to use a custom field in another field as a property. In an entity a custom field is added by using BaseFieldDefinition::create(). However a property of a field type is ...

View answer
How can I restrict access to a static HTML page served from a subfolder of my site to authenticated users only?
0 votes

One of the options to achieve this is using drupal's private file system. Drupal core out-of-box provides a way to access private files in a secured URL. Here are the steps: upload the directory (e.g....

View answer
How can I create an entity reference field to list a subset of roles?
1 votes

Two parts to check here. Is it possible to reference user role (a config entity) Is there a way to restrict the available roles in the field level. reg #1, yes! the out-of-box Drupal core allows ...

View answer
How do I create content during site installation?
1 votes

There are few ways in Drupal 8 to manage site default content: Default content module allows to export/import content via drush and store the content in the structure similar to config in Drupal core....

View answer
How to display entity label using entity reference field checkbox form display
0 votes

I assume the context_question is your custom entity or coming from a contrib module? There are two options: Add label key to context_question entity definition under entity_keys so that Drupal\Core\...

View answer
How to copy/clone menu of a node when clone with Entity Clone module?
1 votes

Issue #2839833 has a proposal to add entity clone plugin to node entity to handle this special case. Alternatively, we could use the event. Luckily Entity Clone module dispatches an event before &...

View answer
How to update a field on menu_link_content (added using menu_item_extras module) entity from node form
2 votes

There are couple of problems here: The node form has the menu fields hardcoded. See menu_ui_form_node_form_alter() and menu_ui_form_node_form_submit() for more details. Turns out the root cause of ...

View answer
How to allow HTML attribute with namespace using filter
1 votes

One way to solve this problem is to have a custom filter which processes the linkname and convert to sc:linkname. <?php namespace Drupal\my_module\Plugin\Filter; use Drupal\Component\Utility\...

View answer
Hide a list of blocks from Panelizer in-place editor (IPE)
1 votes

One of the options is to extend the IPE controller to remove the unwanted blocks from display. Here are the code changes: Route subscriber: mymodule.route_subscriber: class: Drupal\mymodule\...

View answer
How to use term edit page instead of view page?
1 votes

There are a few ways we could achieve this: Option 1: Introduce a route subscriber in a custom module with below code: $route = $collection->get('entity.taxonomy_term.edit_form'); $...

View answer
Can not see test modules in module install page
0 votes

Test modules are under module_name/tests/ or module_name/tests/directory and can be enabled by TestDiscovery service. As ExtensionDiscovery::scan() calls TestDiscovery::getExtensions() method with $...

View answer
How to purge cached content every day via cache tag?
4 votes

Here is the code that flush cache on first hit of a day: public function build() { ... ... ... $this->handleCacheTag($build['#cache']['tags']); } protected function ...

View answer
How to get bundle label from entity
9 votes

If you are not sure about the $entity type, it can be: if ($entity->bundle()) { $bundle_type_id = $entity->getEntityType()->getBundleEntityType(); $bundle_label = \Drupal::...

View answer
How to override prepareTranslation method in Drupal\content_translation\Controller in drupal 8?
1 votes

You can use hook_entity_prepare_form() to override the values from prepareTranslation() on $form_state.

View answer
Date range field misses the minutes when they are the same
4 votes

Hope you are using core date module with end date. If you are, here is my field configuration in content type: Once have the field configured with custom date format, the display seems working as ...

View answer
Keep something in cache even after flushing the cache from the Drupal back-end (not drush)
Accepted answer
2 votes

For this use case, you might need to consider another storage instead of cache. warmer -> cache warmer -> storage -> cache storage could be either key value or entity or any other storage you ...

View answer
How to import config and content using config import and hook_update_N
0 votes

One of the workaround is to run database update (hook_update_N) before and after configuration import. In hook_update_N check if your configuration changes are available. In my case, I just need to ...

View answer
How do I enable developer/debug mode?
19 votes

Add the following line in the settings.php file. $config['system.logging']['error_level'] = 'verbose'; See Make developer tricks / tools for D8 more discoverable/obvious for more details.

View answer
Drush 8.1 Drupal 8 throws PDOException: SQLSTATE[HY000] [2002] on MAMP
11 votes

Make sure your database host setting is 127.0.0.1 instead of localhost.

View answer
#ajax form_set_error
Accepted answer
0 votes

You can try this one: //playground.module function playground_form_alter(&$form, &$form_state, $form_id) { switch($form_id) { case 'webform_client_form_1': global $user; if ...

View answer
Print the query which is built using db_select()
20 votes

Another option is: global $theme_key; $query = db_select('block') ->condition('theme', $theme_key) ->condition('status', 1) ->fields('block'); print strtr((string) $query, $query->...

View answer
How to bulk delete Orders in Drupal Commerce module
2 votes

Commerce Order Cleanup is another attempt on this front: Allows to cleanup the orders by various order properties like last changed, status.

View answer
Drupal 7 special chars not working in db_select
2 votes

It doesn't look like anything wrong with query. I'm using drupal 7 with basic setup and one node(nid=3) has 24/7 in title & body and one node(nid=4) has only in body. // Make sure to decode, if ...

View answer
How do I add classes to main menu ul and li?
2 votes

The way to get the main menu with items in all levels has been resolved in Drupal 8 - "Implement menu links as plugins", trying to build a menu tree To add class to ul and li, we got 3 ...

View answer
Select users with only one role
0 votes

You can try this one: $sub_query1 = db_select('users_roles', 'ur') ->fields('ur', array('uid')) ->condition('ur.rid', '3'); // Role 1 $sub_query2 = db_select('users_roles', 'ur') ...

View answer
Drupal 8 - "Implement menu links as plugins", trying to build a menu tree
Accepted answer
6 votes

You may need to render it as below: // Build the main menu links tree. if (!empty($vars['main_menu'])) { // Build links. $config = Drupal::config('menu_ui.settings'); $menu_enabled = ...

View answer