New answers tagged

0

THANK YOU Clive. I implement patch from this two files, this MetatagViewsFormatter.php and this MetatagFormatter.php from here Provide field formatter to output meta tags on-page, e.g. for use with Views (D9) and it works! Now I have in views metatag field this options:


1

Even this is an old post, I'm still struggling with this use case in many projects. As depicted in previous answers and comments the solution is both, a combination of path alias (core) and a path processor plugin. The Translate Views Path module provides the proper path processor plugin, so you can go and add the path alias for your language using % ...


0

thanks for your help. I'll try that. I've actually found a workaround using a contextual filter to identify a specific path component rather than using a query parameter. This does what I want but I'd be interested to solve the original problem


3

If you want to compare the left part of the field list you need the raw database value from the entity. You find the entity in the row variable of views-view-fields.html.twig : {% if row._entity.field_status.value == 'new' %} See Access row value in template_preprocess_views_view_fields(&$variables)


0

I managed to solve my problem using this module: https://gist.github.com/StryKaizer/ae1cb9abc4844a9e7ac12317a9d84a78


1

No, I don't think you can turn off twig debugging for only some parts of the site. It's either on or it's off. Anyway, you are risking a lot of trouble making changes to a live site. It's much better to set up a local development environment and make your code changes locally. One cross-platform tool for this is Lando but there are many others as well. ...


0

following the error-message you probably just use an array with a single value as second argument, e.g {{ drupal_block('xx', {qParam: qParam} ) }}


0

So I figured it out using a custom widget and the Form Options Attributes module, although now that I think of it I could have probably achieved the same thing in the form alter since I am just loading the term via the key which I had access to before. Anyway, I searched the code base of how the Check boxes/radio widget was built and copied that and modified ...


0

You just need to change #action in the form. so function mymodule_form_alter(&$form, $form_state, $form_id) { if($form_id == 'view_exposed_form' && $form['#id'] == 'views-exposed-form-articles-page-1') { $form["#action"] = "THE_PATH_YOU_WANT_TO_REDIRECT"; } }


1

For Views rendering fields you can add the cache metadata to the field, so that it can be used already for the cached rows and then bubble up to the rendered view and block. /** * Implements hook_preprocess_views_view_field(). */ function mymodule_preprocess_views_view_field(array &$variables) { // target specific view and field $variables['#cache']...


0

You can add a backend class for the block, then add a cache context on language to that block. First, you need to get the config key for the view block. I believe it is views.view.[BLOCK_ID]. You can get the block ID in the advanced section of the view. Next, you add a custom class to the block. Here is how that is done for the system branding block. /** * ...


0

this worked for me in Drupal 8 https://www.drupal.org/project/views/issues/1907940 function utility_views_pre_view(\Drupal\views\ViewExecutable $view, $display_id, array &$args) { $view->getStyle()->options['grouping'][0]['field'] = 'field_category'; }


0

this worked for me in Drupal 8 function utility_views_pre_view(\Drupal\views\ViewExecutable $view, $display_id, array &$args) { $view->getStyle()->options['grouping'][0]['field'] = 'field_category'; }


0

Has anybody tried these approaches for a D9 site?


2

Follow the steps and let me know if you face the same issue Click on the "advanced" tab. Click on add under "contextual filters". Choose Content:nid. Under "when the filter variable is not available, choose "provide default value". From the drop down menu select "content id from url". Scroll all the way down to ...


0

I have tried to replicate the case as follow. 1.Added following structure in views-view-table--articles.html.twig <div class="example-template"> {% for row in rows %} {% set titletxt = '' %} {% set viewnod = '' %} {% set editnode = '' %} {% for key, column in row.columns %} {% for field in column.fields %} ...


1

Add "view content" & "edit content" link in view as follow Then put views-view-table--articles.html.twig file in your theme's template directory and get fields as follow. <div class="example-template"> {% for row in rows %} {% set titletxt = '' %} {% set viewnod = '' %} {% set editnode = '' %} {% for key, ...


1

We ended up creating a custom module that overrides the taxonomy overview form. I pasted our code here in case this helps someone else out. In our case we needed to add a field called Acronym, a field called Type and we also added the Status. You can adjust as needed. Our custom module was called mc_taxonomy and this was in the mc_taxonomy.module file. <?...


0

With hook_views_pre_build() you could set the view mode programmatically in a Drupal 9 view. /** * Implements hook_views_pre_build(). */ function YOUR_MODULE_views_pre_build(ViewExecutable $view) { if ($view->rowPlugin instanceof EntityRow && $view->rowPlugin->getEntityTypeId() === 'node' && $view->rowPlugin->...


Top 50 recent answers are included