8 – Use theme template with specific Views

I have a D8 subtheme of Bootstrap and on the homepage I have 2 Views (2 carousel views).

I turned on twig debugging so I could see which template file(s) is (are) being used, and where it starts and ends. When I used this before it included a listing of sample alternate filenames for that specific content (e.g. paragraph–about-us-page–full.html.twig), which was a big help.

For each of the views on the homepage, they are shown using views-view.html.twig and views-view-field.html.twig whether from the module template, bootstrap template or my copy of the files into my theme.

Is there a way to set up a template file for each of the views individually?

View Machine Names:

  • homepage_slider
  • homepage_loans

They only reside on the front page. I have tried renaming files to see if I can see it being used in the Twig debugging and frequently clear the cache.

It could be a Page, View, Block, etc. template, but then how do I reference the parts of the View to control the display of the fields.

Thank you.

8 – Views custom relationship joined by plain text field

Let’s say I have a node type named ‘Book’.
‘Book’ nodes have ‘publisher’ field.
I want to create a node view which displays these two columns:

  • book title
  • title of a book published by the same publisher

enter image description here

Desired results is like this.
book view

The problem is I cannot use entity reverse relationship which is normally used to connect entities because ‘publisher’ field is not entity reference field.

So I added the code to my_module.views.inc.

funciton my_module_views_data() {
  // it seems first node's 'node__field_publisher' is already loaded, so join second node's node_field_data directly. 
  $data('node__field_publisher')('node_field_data') = (
    'title' => t('Same publisher books'),
    'help' => t('Get books sharing publisher'),
    'relationship' => (
      'id' => 'standard',
      'label' => 'Same publisher books',
      'left_table' => 'node__field_publisher',
      'field' => 'entity_id',
      'base' => 'node_field_data',
      'base field' => 'nid',
    ),
  );
}

It created join and relationship ‘Same publisher books’ became available.

LEFT JOIN {node_field_data} node_field_data_node__field_publisher ON node__field_publisher.entity_id = node_field_data_node__field_publisher.nid

If I click ‘Add’ in ‘field section’, select ‘Title’, set ‘Same publisher books’ as ‘relationship’, it adds query to SELECT statement like this

node_field_data_node__field_publisher.nid AS node_field_data_node__field_publisher_nid

But no titles.

I thought if I make a relationship to other node, it automatically loads field values belonging to the node(e.g. title), but is it a misconception?
How to get titles in this case?

8 – How to display content tagged with child terms in views?

I have a taxonomy vocabulary general in which I have a reference field to user roles allowed_roles.

I have two taxonomy terms. A and B where A is the parent of B.

Now I selected test_role in the A taxonomy term in allowed roles.

in the views I have added a relationship on Taxonomy term referenced from general.

In the contextual filter, I have added the allowed_roles with the above relationship and provided the test_role as value.

Now when I logged in with the user with role test_role, I can only see those content which are tagged with A. Which is default behaviour of the views and correct.

But I want that I should see all content of A and also those content which are tagged with the children of A.

is it possible with views? or I have to write a custom views relationship? Any idea?

9 – How to add filter criteria by current date in views

I am using Drupal 9 and have a content type with a field “Publish until” (datetime).
I want to add a filter in views that it will compare the date in this field with current date.
I found a solution here for Drupal 8
Views filter criteria date field is greater than current date

However, my screen looks a bit different:
enter image description here

To be more specific, I don’t have a “Value type” which seems to be necessary in my case.
Am I missing any module that should be enabled?
Or is it related to the Drupal 9 itself?

If there is any another approach to solve this problem with filtering I will be glad to know it.

views – Contextual Filter Path Alias

I searched for this for some time now but couldnt find an anwser. I am using drupal 9.1.5 and pathauto. I have content types department and depratment news. The news are linked to the department. So whenever you create a department news you link it to a department. Now I want to display all depratment news linked to the department when i am on the department page (all children) and when I am on a page of a children (department news) I want to display all siblings, i.e. all departments news linked with the same department.

My url for departments is
(node:title)
and for department news is
(node:field_department:entity)/(node:title)

I thought that using a contextual filter in my view using the raw value from the url would work. So I used path component 1 and checked to use path alias. However this does not display anything.
enter image description here

When using path component 2 and disable to use path alias it works for the department news, which makes sence as I am internally on page node/xxx. I was so frustrated that I tried every other combination of path component and use path alias but nothing works. When using a fixed value for a department everything works as expected for that specific department

views – how to use entity_access() and entity_load fuction in Drupal 9

function sun_gated_content_entity_view_mode_alter(&$view_mode, $context) {
  // All the content types which could be gated.
  $types = array( 'document', 'media', 'gallery' );

  $entity =& $context('entity');
  if ($context('entity_type') == 'node') {
    // Check if this could be a gated content type.
    if (in_array($entity->type, $types)) {
      // Check if it is gated.
      if (_sun_gated_content_is_gated($entity)) {
        // @todo: Make sure that the HTTP header Cache-Control: no-cache works with Varnish. Can also try drupal_set_header with max-age=0.
        // Prevent Drupal caching the page.
        $GLOBALS('conf')('cache') = FALSE;

        // Load the form gate webform node..
        $form = entity_load('node', array(
          $entity->field_form_gate(Language::LANGCODE_NOT_SPECIFIED)(0)('target_id')
        ));

and

$entity->field_form_gate(Language::LANGCODE_NOT_SPECIFIED)(0)('entity') = current($form);
          $entity->field_form_gate(Language::LANGCODE_NOT_SPECIFIED)(0)('access') = entity_access('view','node',$entity);

in my custom module in d7 i used this lines of code , but in d9 modules entity_access() and entity_load function are not working ,how to used it , can anyone help me with it .

will webform work with views bulk operations?


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




sharepoint online – It there still any threashold limitation on modern UI list views

Previously inside sharepoint 2010 & 2013 on-premises we were not able to show more than 5,000 items inside list views. for example if we filter the items based on their status (for example status = Open), and there are more than 5,000 items with Open status we will get an error.. but in sharepoint online using the modern UI, i can see that there is no more any restrictions, and inside modern UI we are able to search/filter lists view even if the result contain more than 5,000 items .. so is my assumption that modern UI no more have the 5,000 threshold issue? if the answer is yes, then is still any type of thresholds?

Thanks

8 – Views rest export does not update

I have two websites.

On website 1 I have a calendar showing upcoming events. Next to a regular views page I also created a views rest export page with 6, of the most near in the future, upcoming events.

On website 2 I created a rest import function with JavaScript. Getting the 6 events and showing them in a block.

Now my problem is that, when a day is passed and an event has taken place, the event is not removed from the block in website 2. I’m not caching anything on website 2 and it is just importing the rest export every time the page loads. And I turned the cache of the view on website 1 off.

It looks like the problem is with website 1 (because emptying the cache on website 1 fixes the problem on website 2 for some reason it is not updating the rest export when an event has passed.

The updating of the rest export on website 1 should take place because the filter of the view is set to only show the upcoming events.

I find it hard to explain what the problem really is hopefully my explanation makes sense (at least a little bit).

So what I’m wondering if this is a normal behavior? Did I miss a setting?

magento2 – Two store views ALOThemes footer and top bar


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.