layout builder – How to set an ALL option on contextual filters passed to a view with twig tweak?

In Drupal 8, I have a twig tweak embedded view that passes variables from the Layout Builder dialogue to filter results in a custom block.

{% set event_type = block.field_filtered_events_event_type.value %}
...
{{ drupal_view('events_group_content', 'filtered_events', event_type, center_id, cat) }}

The filters all work great except I need an option for ALL results if the user doesn’t select anything from the filter. I have the “Display all results for the specified field” checked under “When the value is NOT available”, but it does nothing. If I try to insert the block without making any selections, it posts and empty block.

Is there a way to add an ALL option as the default values passed into the view?

Adding my attempt to unset if not selected –

<div>
  {{ title_prefix }}
  {{ title }}
  {{ title_suffix }}
  {% if block.field_filtered_events_event_type.value|render is not empty %}
    {% set event_type = block.field_filtered_events_event_type.value %}
  {% else %}
    {% set event_type = 'all' %}
  {% endif %}
  {% if block.field_filtered_events_center_id.target_id|render is not null %}
    {% set center_id = block.field_filtered_events_center_id.target_id %}
  {% endif %}
  {% if block.field_filtered_events_samhsa.target_id|render is not null %}
    {% set samhsa = block.field_filtered_events_samhsa.target_id %}
  {% endif %}
  {% set upcoming = block.field_filtered_events_upcoming.value %}
  {% set qty = block.field_filtered_events_qty.value %}
  {% if upcoming == 1 %}
    {{ drupal_view('events_group_content', 'filtered_events', event_type, center_id, samhsa) }}
  {% else %}
    {{ drupal_view('events_group_content', 'filtered_events_past', event_type, center_id, samhsa) }}
  {% endif %}
</div>

xna – Basic Projection & View matrix

Currently writing a camera component for FNA (basically XNA), and can’t for the life of me figure out why my matrix transform isn’t working as expected. This is how I calculate my view & projection matrices:

// projection
// WorldSize is something like 16x9, 20x10, etc. Basically the "simulated" world size.
// Zoom is just a float to zoom the camera.
var left = Zoom * -WorldSize.X / 2;
var right = Zoom * WorldSize.X / 2;
var bottom = Zoom * -WorldSize.Y / 2;
var top = Zoom * WorldSize.Y / 2;
const float near = 0;
const float far = 100;
var projection = Matrix.CreateOrthographicOffCenter(left, right, bottom, top, near, far);

and

// view
// Position is the position of my Camera, e.g. (10, 15), (6.51, 16.612), etc.
var position = new Vector3(Position, 0);
var target = position + Vector3.Forward;
var up = Vector3.Up;
var view = Matrix.CreateLookAt(position, target, up);

// Combine them
var combined = projection * view;

This should, by all the sources I’ve checked, double-checked, and triple-checked, be correct. However when I apply this matrix to my batch or effects it doesn’t show anything at all:

// I would expect a white square to be rendered in the middle of the screen. Since WorldSize is
// 16x9 I would expect a 1x1 square to be clearly visible.
var batch = new SpriteBatch();
batch.begin(/* the rest */, combined);
var texture = new Texture2D(Game.GraphicsDevice, 1, 1);
texture.SetData(new (){Color.White });
batch.Draw(texture, Vector2.Zero, Color.White);
batch.End();

// Also tried just rendering lines, shows nothing
var effect = new BasicEffect(graphicsDevice)
{
    VertexColorEnabled = true,
    View = view,
    Projection = projection
};
effect.CurrentTechnique.Passes(0).Apply();
graphicsDevice.DrawUserPrimitives(PrimitiveType.LineStrip, vertices, 0, vertices.Length - 1);

I have checked so many sources and they all do exactly like this. I even tried copy+pasting the matrix source code for a Java project I made some time back that I know works, and that didn’t work either so I don’t think the Matrix transforms are to blame. Anyone know what I’m doing wrong?

python – The view insertemp.views.Insertrecord didn’t return an HttpResponse object. It returned None instead?

views.py
from django.shortcuts import render
from insertemp.models import Empinsert
from django.contrib import messages

def  Insertrecord(request):
    if request.method == 'POST':
        if request.POST.get('empname') and request.POST.get('email') and request.POST.get('country'):
            saverecord=Empinsert()
            saverecord.empname=request.POST.get('empname')
            saverecord.email=request.POST.get('email')
            saverecord.country=request.POST.get('country')
            saverecord.save()
            messages.SUCCESS(request,'your detail saved succeccfullt.......!')
            return render(request,"index.html")
    else:
            return render(request,"index.html")
urls.py
from django.contrib import admin
from django.urls import path
from . import views

urlpatterns = (
    
    path('', views.Insertrecord),

)
models.py
from django.db import models
class Empinsert(models.Model):

    empname=models.CharField(max_length=100)
    email=models.CharField(max_length=100)
    country=models.CharField(max_length=100)
    class meta:
        db_table="newemployeetable1"
settings.py
"""
Django settings for insertemp project.

Generated by 'django-admin startproject' using Django 3.1.7.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'n7#@rb50!g7yh9_aw@eud++4zv4ee9zgxvrbf0my34pxu=avmc'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ()


# Application definition

INSTALLED_APPS = (
    'insertemp',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

MIDDLEWARE = (
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',`enter code here`
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'insertemp.urls'
TEMPLATES = (
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS':(os.path.join(BASE_DIR, 'templates')),
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': (
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ),
        },
    },
)

WSGI_APPLICATION = 'insertemp.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME':'sampledb1',
        'USER':'root', 
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '3306',
        'OPTIONS':{
            'init_command':"SET sql_mode='STRICT_TRANS_TABLES'"
        }
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = (
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
)


# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True




STATIC_URL = '/static/'

8 – Import single view configuration fail – layout_builder__layout will not exists after import

I have Drupal 8.9.13 and I want to export/import single views configuration to other Drupal 8.9.13. I can select single view to export, but when I import it I get the next error:

The configuration core.entity_view_display.node.page.default depends on the configuration of field.field.node.page.layout_builder__layout that will not exists after import.

This is one of the views I want to import. The problem happens with all views:

uuid: xxxxx
langcode: es
status: true
dependencies:
  config:
    - field.storage.user.field_documento
    - user.role.administrator
  module:
    - mycustommodule
    - file
    - rest
    - serialization
    - user
id: custom_user_files
label: 'User files'
module: views
description: 'REST Export user files'
tag: ''
base_table: file_managed
base_field: fid
display:
  default:
    display_plugin: default
    id: default
    display_title: Master
    position: 0
    display_options:
      access:
        type: role
        options:
          role:
            administrator: administrator
      cache:
        type: tag
        options: {  }
      query:
        type: views_query
        options:
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_comment: ''
          query_tags: {  }
      exposed_form:
        type: basic
        options:
          submit_button: Apply
          reset_button: false
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
      pager:
        type: mini
        options:
          items_per_page: 10
          offset: 0
          id: 0
          total_pages: null
          expose:
            items_per_page: false
            items_per_page_label: 'Items per page'
            items_per_page_options: '5, 10, 25, 50'
            items_per_page_options_all: false
            items_per_page_options_all_label: '- All -'
            offset: false
            offset_label: Offset
          tags:
            previous: ‹‹
            next: ››
      style:
        type: serializer
      row:
        type: fields
        options:
          inline: {  }
          separator: ''
          hide_empty: false
          default_field_elements: true
      fields:
        filename:
          id: filename
          table: file_managed
          field: filename
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: false
            ellipsis: false
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: value
          type: file_filemime
          settings:
            link_to_entity: 0
          group_column: value
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          entity_type: file
          entity_field: filename
          plugin_id: field
        field_documento:
          id: field_documento
          table: user__field_documento
          field: field_documento
          relationship: reverse_field_documento_user
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: target_id
          type: astec_fichero_base64
          settings: {  }
          group_column: ''
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          plugin_id: field
        fid:
          id: fid
          table: file_managed
          field: fid
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: value
          type: number_integer
          settings:
            thousand_separator: ''
            prefix_suffix: false
          group_column: value
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          entity_type: file
          entity_field: fid
          plugin_id: field
      filters: {  }
      sorts: {  }
      header: {  }
      footer: {  }
      empty: {  }
      relationships:
        reverse_field_documento_user:
          id: reverse_field_documento_user
          table: file_managed
          field: reverse_field_documento_user
          relationship: none
          group_type: group
          admin_label: field_documento
          required: true
          entity_type: file
          plugin_id: entity_reverse
      arguments:
        uuid:
          id: uuid
          table: users
          field: uuid
          relationship: reverse_field_documento_user
          group_type: group
          admin_label: ''
          default_action: default
          exception:
            value: all
            title_enable: false
            title: All
          title_enable: false
          title: ''
          default_argument_type: query_parameter
          default_argument_options:
            query_param: uuid
            fallback: ''
            multiple: and
          default_argument_skip_url: false
          summary_options:
            base_path: ''
            count: true
            items_per_page: 25
            override: false
          summary:
            sort_order: asc
            number_of_records: 0
            format: default_summary
          specify_validation: false
          validate:
            type: none
            fail: 'not found'
          validate_options: {  }
          glossary: false
          limit: 0
          case: none
          path_case: none
          transform_dash: false
          break_phrase: false
          entity_type: user
          entity_field: uuid
          plugin_id: string
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - request_format
        - url
        - url.query_args
        - user.roles
      tags:
        - 'config:field.storage.user.field_documento'
  rest_export_1:
    display_plugin: rest_export
    id: rest_export_1
    display_title: 'REST export'
    position: 1
    display_options:
      display_extenders: {  }
      path: custom-user-files
      pager:
        type: none
        options:
          offset: 0
      style:
        type: serializer
        options:
          formats:
            json: json
      row:
        type: data_field
        options:
          field_options:
            filename:
              alias: ''
              raw_output: true
            field_documento:
              alias: ''
              raw_output: false
            fid:
              alias: ''
              raw_output: true
            uuid:
              alias: ''
              raw_output: true
      auth:
        - basic_auth
        - key_auth
        - cookie
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - request_format
        - url
        - user.roles
      tags:
        - 'config:field.storage.user.field_documento'

I don’t use layout builder templates. field_documento is a field in the user profile. How could I solve this issue?.

magento2 – Paging not showing on category view

I am unable to see paging on my category view products.
By default 12 products show and when I add a query string ?p=2 then other page products show.

Here is my setting inside admin panel

enter image description here

I have checked the file.
app/design/frontend/vendor/theme/Magento_Catalog/templates/product/list.phtml

these two methods also exist responsible to print paging

<?= $block->getToolbarHtml() ?>
<?= $block->getAdditionalHtml() ?>

9 – Programmatically enable the entity view display

I figured it out. You can enable Layout Builder by running the following code in a custom module:

$entity_type = 'node';
$content_type = 'article';
$view_type = 'default';

Drupallayout_builderEntityLayoutBuilderEntityViewDisplay::load("{$entity_type}.{$content_type}.{$view_type}")
  ->enableLayoutBuilder()
  ->setOverridable()
  ->save();

Hopefully this helps someone else. Having to do it via the UI is painful if you have a lot of content types. I’m actually surprised this isn’t a Drush command yet. Oh well.

Source: https://www.drupal.org/project/drupal/issues/3158916

Cubic Voxel Game, Calculate What Chunks are in the Player’s View, using 3D chunks?

I need to calculate what chunks are in the player’s view, meaning I need the 3D positions (the bottom, back, left corner in world space) of each chunk that is in the player’s view. I’m not worried about culling, this is mainly to prioritize the generation of new chunks that are in the player’s view.

These are 3D chunks, meaning unlike Minecraft, the world is infinite in all directions, including up and down. The chunks are 32x32x32 right now.

The way I am doing it now is I will look at a giant cube of chunks around the player and then do the same exact thing but around points that are cast out in front of the player’s camera. This works, but it is fairly slow, I have to check every chunk if it already exists in two different dictionaries before adding it to the right one because my algorithm isn’t perfect and sometimes it checks the same position twice, and then after all of that I only use a few of the closest chunk positions because if I used them all it would continue generating those chunks even after the player has moved miles away from it.

So it would be great if I could figure out a fast way to create a list of all the chunk’s positions that are in the player’s view with no duplicates. Any ideas at all are very welcome! Thank you.

postgresql – Postgres view role permissions

I am trying to work out how database roles work.
Here is my user case…

create role user1 login password 'user1';

create schema authorization user1;

CREATE ROLE DEV_ROLE;

grant connect, temporary on database test to DEV_ROLE;
GRANT ALL ON SCHEMA manager TO DEV_ROLE;

Now how do i view the all the grants assigned to ‘DEV_ROLE’? This is possible in Oracle but trying to work out the same here.

Do appreciate your reply.
Ta

sharepoint online – How to migrate a public library view from one library into another

From SharePoint Online, I was able to go into Site Settings, create my custom content type, and add new columns to it.

I then created a new SharePoint site, added my custom columns from my custom content type and saved a public view for my library in this site.

I then created a new library within the same site, and added my columns to it (from my custom content type), but how do we copy over the public view that was in the previous library into this new library?

In this case, does the view have to be re-created when going from library to library?

sharepoint online – Create a View with PowerShell Returns Error: One or more field types are not installed properly

I’m trying to create views on sub-folders in a SharePoint Online document library using SharePoint Online Management Shell. The script creates the view but generates the following error message when I try to display the view.

One or more field types are not installed properly. Go to the list settings page to delete these fields. Correlation ID: 0f3fbe9f-80e3-0000-c877-398c5f1cc2bf

I’m using the following script to create the view.


#Config Variables
$SiteURL = "https://XXXX.sharepoint.com/sites/TestTeamSite"
$ListName= "Documents"
$ViewName= "0001TestFolder"
$ViewFields = @("Name","Modified")
$Query = "<Where><Eq><FieldRef Name = 'Title' /><Value Type = 'Text'>Active</Value></Eq></Where>"
 
#Get Credentials to connect
#$Cred = Get-Credential
 
Try {
    #Connect to PNP Online
    Connect-PnPOnline -Url $SiteURL -UseWebLogin
 
    #sharepoint online pnp powershell create view
    Add-PnPView -List $ListName -Title $ViewName -ViewType Html -Fields $ViewFields -Query $Query -ErrorAction Stop
    Write-host "View '$ViewName' Created Successfully!" -f Green
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}