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 field override and use it in Global: Custom Text

In Drupal8, I have created a view of content and add a relationship of the user account field which is referenced entity of the content.
So, Basically I have one content type and in the account fields I have added one content referenced field, there user can select multiple values.

Now in the view I am showing the content and using the Global custom field I am overriding the output of the view.

In the field of referenced entity under view I am getting multiple values like 1,2,3,4,5 and I want something like if node id is present inside this multiple values then I want to display some text.

Can anybody let me know how can I achieve this?

I have tried something like below under Global: custom text field but it did not worked.

{% if nid in field_ref_content %}
  <p>Lorem Ipsum</p>
{% endif %}

I have tried to override the twig as well for that field and able to achieve the things what I want to show like some custom text, but that only rendered when we are using that field in view.

when I used that field’s replacement pattern inside that Global: custom text, that is returning only the default value which is 1,2,3,4,5 not the one which I have override using the view field override hook

Hook_preprocess_views_view_field

Can someone please guide me, I spend so much time for this but no luck.

Thanks in advance.

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

webforms – Filter Views With Tokens on Computed Token Fields

I want to add a filter criteria on my view with a token (ex: (webform_submission: user: name)) on a “Computed Token Field” of my webform.
To display the data of my Webform in my view I use the Webform Views Integration module.

I tried by various means to solve my problem:

  • Use the Token Filter module, the Use Token option does not appear for data from Webform (Webforms Integration Views)

  • Use the contextual filter using the Views Extra module, on this side we have access to the data of the Webform, but the data which comes from type “Computed Token” or “Computed Twig” is not available to make the filter

Can someone help me solve my problem please?

How to aggregate values from fields in Paragraphs based on value of another field in that same paragraph, and display in an aggregated Views table?

Hopefully my title makes sense…

I am setting up a Drupal 9 website for internal use as a financial reporting engine and a CRM. I am making use of the following modules:

  • Paragraphs
  • Views
  • Viewfield
  • View Fields View
  • Views Aggregator Plus

I have one Paragraph (Entity Reference) unlimited-value field on a paragraph type called “Project”. That field is called “Transactions”. It refers to a paragraph type called “Transaction”.

The “Transaction” paragraph type has the following fields:

  • Transaction Amount (decimal field))
  • Status (term reference field. Values are PAID and UNPAID)
  • Paid On (date field)
  • Year (a taxonomy entity reference field that contains pre-set years (2019, 2020, 2021, etc).

I have a content type called “Company”. It has the following fields:

  • Title
  • Project (a Paragraph/Entity Reference field)
  • Transaction Amount – Paid (a Viewfield)
  • Transaction Amount – Unpaid (a Viewfield)
    • These two Viewfields are of content type “Company”
      • One is filtered to the Transaction paragraph’s status “Paid”; the other is filtered to “Unpaid”.
    • They contain this field, which is SUMmed through Views Aggregation: (field_transactions: Paragraph) SUM(Paragraph: Transaction Amount)
    • They contain these relationships:
    field_projects_paragraph: Paragraph
    (field_projects_paragraph: Paragraph) field_transactions: Paragraph
    (field_projects_paragraph: Paragraph) field_transactions




    

The output displays the sum of the paid or unpaid transactions. For example, if a company has a project which has 3 PAID transactions of $100 each, this view will output “$300”. The intent is to display this value on the “Overview of Transactions” view, as described below:

Overview of Transactions view…

I have created a View of “Company” content of display format: “Table with Aggregation Options” that will display a table of the following columns:

  • Company Title
  • Total Transaction Amount (a SUM aggregation of all transaction “Transaction Amount” values.
  • Total Transaction Amount with status = PAID
  • Total Transaction Amount with status = UNPAID

The intent is to display an at-a-glance table of all Companies on the site, showing a line for each Company, that Company’s Total Transaction amount (which includes paid and unpaid), that company’s PAID total amount, and that company’s UNPAID total amount.

Further, the intent is to be able to filter this table based on the “Year” taxonomy term value from the Transaction paragraph type (filter it to only contain data that is tagged with “2020”, for example), or to filter it by date range using the “Paid On” value from the Transaction paragraph type (filter it to only contain data that contains a date value of 01/01/2020 – 01/03/2020, for example). The purpose is to be able to see all dollar amounts per company on a yearly, monthly, weekly, daily, or any other date range basis. For example: “display all company transaction data for Jan 1, 2020 through March 31, 20020, and then run that same report for that same time period in 2021.

To the View, I added the following settings:

Relationships:

    - field_projects_paragraph: Paragraph
    - (field_projects_paragraph: Paragraph) field_transactions: Paragraph

Filter Criteria:

    Content: Content type (= Company)
    (field_transactions: Paragraph) Paragraph: Year (exposed)
    (field_transactions: Paragraph) Paragraph: Paid On (exposed)

Fields:

    Content: ID (ID) (hidden)
    (field_transactions: Paragraph) Paragraph: ID (ID) (hidden)
    Content: Title (Title)
    (field_transactions: Paragraph) SUM(Paragraph: Transaction Amount) (Transaction Amount)
    Content: Transaction Amount - Paid (Transaction Amount - Paid) - This is one of the Views Field View fields from the Company content type
    Content: Transaction Amount - Unpaid (Transaction Amount - Unpaid) - This is one of the Views Field View fields from the Company content type

Format:Table with aggregation options

        ID: Apply Group Function: Group and Compress
        (field_transactions: Paragraph) Transaction Amount: Column Aggregation: Sum

    

My current end result is as follows:

  • Each Company has its only single line in the table.
  • The “Total
    Transaction Amount” field correctly sums the company’s total
    transactions (paid and unpaid), and the column successfully
    aggregated the total transactions of all Companies on the site.
  • The
    “Content: Transaction Amount – Paid (Transaction Amount – Paid)”
    field correctly displays the company’s total PAID transactions, but
    it does not adhere to the Year and Paid On filters. Additionally, the
    column will not SUM with the Table Aggregation settings at all.
  • The
    “Content: Transaction Amount – Unpaid (Transaction Amount – Paid)”
    field correctly displays the company’s total UNPAID transactions, but
    it does not adhere to the Year and Paid On filters. Additionally, the
    column will not SUM with the Table Aggregation settings at all.

How can I display each company’s Paid and Unpaid transaction totals in this Views aggregated table, and also make those two values subject to the Year and Paid On filters?

I am open to completely re-thinking the organization of the node types, data, etc.

fullscreen – 2014 Mac mini on 2 monitors no screen extension option available. Just mirror and regular left right views. Can this be done and how?

fullscreen – 2014 Mac mini on 2 monitors no screen extension option available. Just mirror and regular left right views. Can this be done and how? – Ask Different

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123