Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

1

Considering the first option, it is simple : add a contextual filter of type "ID: Content" with the following configuration : WHEN THE FILTER VALUE IS NOT AVAILABLE > provide a default value > content id from url Go all the way down in the "more" section, expand it and check "exclude". Then click apply And save the views That's it !


0

There's a bug in core that shows a link to the same language when your label field (title/name) isn't translatable. See https://www.drupal.org/project/drupal/issues/2447821


0

You can use pathauto module. After installing the pathauto module, please configure the path of article content type from here admin/config/search/path/patterns. Note: To use pattern require token module. Then use like following pattern: categories/[node:field-token-of-term-reference-field]/[node:title]


0

Piggybacking off How to set views pager item size programmatically? and looking at PagerPluginBase. To change values if ($disable_pager == FALSE) { $view->pager->setOffset(0); $view->pager->setItemsPerPage($items_per_page); } Now to answer your question How can the pager be disabled in above code? I believe you can disable it by ...


0

Try using template_preprocess_views_view_fields If you still can't access that field there then: Ditch views_view_field Add a "custom text field" (their field_name will be nothing). In template_preprocess_views_view_fields programmatically add view to this "custom text field". /sites/all/themes/THEMENAME/template.php function ...


0

register it with hook_views_data_alter() in mymodule.views.inc Something like this: /** * Implements hook_views_data_alter(). */ function mymodule_views_data_alter(&$data) { $data['node_field_data']['my_custom_taxonomy_validation_argument'] = [ 'help' => t('Hello world'), 'real field' => 'title', 'argument' => [ 'title' =...


1

The "connected" exposed sorting criteria is implemented in the Facets module and Search API. Here's a tutorial that can help get you started: Creating a Faceted Search View in Drupal 8 using the Search API Modules Before you start testing new modules maybe the "ordinary" Exposed Sort criteria in Views can help. Create only one Page display, but add all 3 ...


2

Entity reference fields store the ID of the referenced entity. They don't store anything else about the referenced entity. You have an Entity reference towards nodes and the data that the ER field stores is the node ID. That is why when you add a filter for that ER field you get the "number" options, because the ID is a number/integer. But there is a way ...


0

As @seb alluded to in his comment on the original post, you need to make sure the export display has the same exposed filters as the display you attach it to. If it does, it should automatically inherit the current exposed filter values when the user hits the export button.


1

Yes, query alter helps. Views flexible pager might serve as an inspiration for the code changes. Do contribute back if you find a solution, it has been requested before. This problem is usually "solved" by creating different Views displays, as many as you have Groups, and filter each field value in its own display. Then show all 3 displays one after ...


0

You can programmatically alter the contextual filter value of "january" to "01 - 12" in hook_views_pre_view /* * Implements hook_views_pre_view() */ function mymodule_views_pre_view(ViewExecutable $view, $display_id, array &$args) { // Modify contextual filters for my_special_view. $account = \Drupal::currentUser(); if ($view->id() == '...


0

I am the maintainer of Charts, and it's definitely designed for plotting data stored in your database. I recommend using Views. This is a good tutorial: https://www.ostraining.com/blog/drupal/create-charts-with-views/ [The documentation page on Drupal.org seems to have some broken link issues - I will work to fix this]. If you want to plot data in a non-...


0

I researched this for a while, then I found a sample implementation in modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementEmbedForm.php: $form['view'] = [ '#type' => 'view', '#name' => 'test_view_embed', '#display_id' => 'embed_1', '#arguments' => [25], '#embed' => TRUE, ]; In that file it is used in FormBase::...


0

It took me a while to find out how to do it in Drupal 8, and since this post is one of the first google hits I'll add the solution here: function MODULE_form_node_NODETYPE_alter(&$form, FormStateInterface $form_state, $form_id) { ... $form['my_embedded_view'] = [ '#type' => 'view', '#name' => 'my_view_name', '#...


0

You don't need two Views Display for that, you can do that one with one Page Display. Create Views of type Taxonomy term and add Page Display Add Filter for Food Vocabulary Add the Parent Relationship. It is called Taxonomy term but look at the Description The parent term of the term. This can produce .... If you Require it the results will only show ...


0

In the "Custom Text" field, {{ name }} is only available to render the "Product Name" field inside the "Custom Text" field (in the view UI), not in a twig template. You should try to access your fields in the twig template like this {{ row.content.name }} (check the available fields using devel/kint).


0

I think this is a bug in Profile2 module. I recreated your issue on a test installation and the same results happened. After I inspected the database itself I found that the machine name was not changed in the table profile but correctly changed in profile_type table. What you could try is to manually change the machine name in the profile table and see ...


-1

OK, I found the problem. In my routing file, I was missing: options: no_cache: TRUE That fixed it.


0

This types of matching (list Taxonomy siblings) is usually done through Has Taxonomy term ID Contextual filter, but your case is a bit more indirect. You're not showing related content on other node pages. You want to list some content on User pages, but the matching is not done between the listed content and the user (because you don't have Taxonomy on ...


1

You do not have to write any code to achieve that. Just go to the views edit page, add a contextual filter named as Has taxonomy term ID and select Provide default value, see screenshot for more options However, you can also do it pragmatically function HOOK_views_query_alter($view, $query) { $term = menu_get_object('taxonomy_term', 2); if ($term &...


0

You don't need additional modules to create different Taxonomy term pages, in D7 nor D8. Taxonomy Display and Taxonomy Views Integrator modules save steps in certain cases, but you can recreate their functionality with configuring different Views for different cases. You can reuse the existing Taxonomy term Views (this lists nodes based on the taxonomy ...


2

Exposed filters do create/update the page URL. You can construct a link with a combination of values for your Exposed filters and the Views results will react to it by displaying the "correct" results narrowed down to what is set in the URL. The confusion you're having is the Ajax option. Ajax (asynchronous JavaScript and XML) option fetches only a ...


2

I think this is what you are looking for. https://www.drupal.org/project/view_mode_page It will create viewable routes for view modes. Check the examples and readme. They will display on the page the way they are configured to display from the backend.


0

Field group can create tab groups (horizontal and vertical) and tab elements on the same view mode. Than you are able to access each tab with a hash. The ID of each tab becomes the has anchor (#company etc). You have to setup the fields in 1 view mode and place them under the appropriate tabs. Here is a screenshot of how the setup should look.


2

hook_schema() is only used to return a structured array representing your module's database tables. You can't execute a query from it. Well, you physically can, but you shouldn't. Since hook_schema() is used on install, your code to create the View should be in hook_install(), and the code to remove it should be in hook_uninstall()


0

In Drupal 8, the following seems to work: $query->addWhere(0,'fee_schedule_payments.pid',NULL,'IS NULL');


0

It seems Field collection/tabular data solution is what you're after. In Drupal 7 the popular module for that was Field collection. In Drupal 8 Paragraphs seems to be popular, although its description is pointing heavily to the current fad of designing content pages with separate sections, it is still a solution that allows for a more structured group of ...


1

You can try to apply getValue() of the field handler on the result row, for example: {% if view.field.field_name.value(view.result[key]) %} Edit: In a views table template row is not of the type ResultRow, so you need to get it directly from the view object using key of the loop {% for key, row in rows %}. See these questions for different views ...


1

The combination of Relationships and Contextual filters to make it work isn't random, it actually follows your requirements just as you've written them, you only need to add them to your Views configuration the way you describe. How Views types work You want a list of nodes, that is why you create a Content Views Display. Content Views display information ...


0

Although there may be a method to do this via a query alter I was unable to find the correct solution. I was however able to find a solution. Although we utilise search API heavily and we can use the content type relevance weighting we had a requirement to sort by a custom content type order and then by date, in addition some content types needed the same ...


0

Check out Content Planner Drupal 8 contrib module - it provides Kanban planning. Drupal Content Planner helps you to create, plan and manage content. It offers a dashboard, a content calendar and a todo list. It's completely open source and free to use. Feature highlights Content Planner dashboard Editorial team widget Content status widget Custom ...


0

Ok, so Content using field_course_reference (Relate each Content with a field_course_reference set to the content.) was used and required and then Content using field_course_offerings (Relate each Content with a field_course_offerings set to the paragraph.) was used and required using the first relationship. This ended up allowing me to filter out and only ...


0

Notes: The View has to be a block. Exposed filters can be added but will not be displayed on your page. You can set them in your page, eg for a 'severity' field: $filters = $view->getDisplay()->getOption('filters'); $filters['severity']['value'] = [0,1,2,3,4,5,6]; // include a set of values. $view->getDisplay()->overrideOption('filters', $...


0

i have been struggling for customizing "D8 Search Index". Though there are many solutions and discussion, it's really not possibly to get it configured the way you want, unless you really get your hands dirty with twig templates. i believe in less coding. This allows end-user to customize things without actually entering the code. So i was looking to avoid ...


0

I figured out my problem and it had to do with classes as I suspected. For whatever reason, a snippet of javascript that was not previously interfering with the preview functionality just recently started breaking the view. I'm still not entirely sure why but I'm guessing I removed the class in another template and so it was never being rendered and now my ...


0

Your friend is: Taxonomy term: Representative node This is a duplicate, by the way.


0

Click in "Edit" this Database server, and navigate to the end of that page:


0

You can draw some clues from this question: Views contextual filters for NULL value You should use Computed field or some other way of introducing custom PHP into your Views (custom module is the best option). If you use more than one Contextual and need to have the OR operator between them you can use the Views Contextual Filters OR module. There is ...


1

Finally, I did that: In amap.routing.yml, there is amap.export_subscriptions: path: '/amap/contract/export/{contract}' defaults: _controller: '\Drupal\amap\Controller\ContractsController::export_subscriptions' In ContractsController.php, there is public function export_subscriptions($contract) { amap_exportCSV('amap_contracts_subscriptions'...


1

Views sets the title configured in a Views page statically in the route definition. Get this title from the current route in a preprocess hook for your specific block content UUID. Add a routecache context, so that the block changes the title when you visit different pages: function mytheme_preprocess_block(&$variables) { if ($variables['plugin_id'] ==...


1

The HTTP header Content-Disposition will suggest the filename the browser will save as. What's needed here is to make the REST export to add the HTTP header. It turns out there's an existing issue for the CSV Serialization module. The current patch in the issue will take the last part of the URL after the slash and appends .csv to it (e.g. 2.csv in your ...


0

I think there is no way to get the the view Object directly it's protected property and there is no method to get it: From ViewsBlockBase /** * The View executable object. * * @var \Drupal\views\ViewExecutable */ protected $view; But there is a way first get the view id from the DerivativeId and then load the view here is a code ...


0

I tried it myself and views filter OR group is not working. I think you just hit on a known bug. Follow the discussion in this issue and this one and apply the latest patches mentioned and see if you can make it work. Make sure that you post back with your experience (did it work or not) so you can help this issue move along and eventually make it into a ...


2

The raw replacement pattern isn't available, but you can customize a new hidden field to be the replacement equivalent: Add a new link field Check the Exclude from display, URL only, Show URL as plain text options to have your field be available. Add a new title field Uncheck Link to the Content Use <a href="{{ field_MY_LINK_FIELD }}">{{ title }}&...


0

the offending view also had aggregation enabled. To stop the escaped html, open the field's aggregation settings and include 'format'.


0

Mahdi Baghery, You can customize the JSON response using views plugin that extends Serializer like https://cgit.drupalcode.org/one_api/tree/src/Plugin/views/style/SerializerCount.php The above SerializerCount.php code is used to add pager to ResTful export like http://one-drupal-demo.technikh.com/onedrupal/api/v1/content?page=1 { results: [], pager: {} } ...


0

Here is a simple method available for the same : $tid = 'Enter tid number say 5'; $nids = taxonomy_select_nodes($tid, FALSE); // count node here $count = count($nids); // you can load node content here $nodes = node_load_multiple($nids);


0

As Sunil says you are probably using view variables in your block template Perhaps look for another template to override further down in order to find a views template to override and use your html/twig code Here is what I would do. Find the first template inside views-view.html.twig in my case it is views-view-unformatted.html.twig (red arrow above) and ...


0

In my example I have Article with taxonomy term reference field tags and have create following content/terms 2 Tags: test1, test2 4 articles (2 including test1, 2 including test2) Create a view of content displaying fields and filter to display articles only add title field add tag field (can exclude it from display) format settings > choose grouping ...


0

The way I've done this is to preprocess the paragraph and alter the $variables['content'] to contain the views data/render array you've retrieved programatically: function HOOK_preprocess_paragraph(&$variables) { if ($variables['paragraph']->type->target_id == 'yourparagraph') { //code to get the view you want ... ... $...


Top 50 recent answers are included