views – Exposed filter value into the session and cookie?

I want users visit my site regularly. And I need to store their settings to session (cookie). These settings are: Views Exposed Filter on the FrontPage (like to hide materials from the black list users).

So I have the FrontPage View and Taxonomy Term View. These views have exposed filter.

Once visitor selected values in this filter they should to store during he browsing the site and more when he visit site again.

I do not want to use JavaScript. I want to store cookie with php and to get it with php.

And I want drupal cache all pages for all possible filter values.

Please, have I to write a new Drupal CMS or where have I to get the answer?

8 – Can I pass a view’s exposed filter values to the next page?

I have a D8 site view with exposed filters. I want the selected filters from that view to carry over to the next page’s URL.

For example: The page lists software titles. If someone filters on OS, and picks MacOS, the URL of the view page changes from “viewpage” to “viewpage?os=MacOS”. I want to make the links in the view change from “drupalpage” to “drupalpage?os=MacOS”.

I can’t figure out how to add the “?os=MacOS” query string to a link in the view. Is there a way to do that?

Using a View Page and it’s exposed filters as separate blocks on same page

I have created a View Page that exposes some filters, and I put this view on my front page. When creating a Page in D7, I was able to add the exposed filters as a piece of content that was found under the Views category, and add the View Page as a separate piece of content that was found under the Views Pane category. This is not the case in D9, I only have access to the exposed filter, and when you search it takes you to a different page.

In D9, using Layout Builder, how can I add a View’s form’s exposed filters as one block and the actual view as another block?

web browser – How do developers prevent a third party from looking at exposed information on a javascript console? For example on a public computer

If a user was using your application on a public computer and were to log out of your website without closing the tab, the next person to use this computer could snoop through the console and look for errors logged there. Even if you weren’t explicitly logging any request errors to the console you could forget to catch an error from an axios request. This then would be logged to the console. The third party could look at these errors and possibly find sensitive information or even the user’s access token.

How would one prevent this? With console.clear()? Or would you reload the page on logout? Any other tips?

8 – Programmatically set latitude and longitude exposed input

I’ve been using geolocation 8.x-1.12 for a while now. I have a REST route that gets a view with my exposed form and returns the results.

Previously I did:

$plugin = Drupal::service('plugin.manager.geolocation.geocoder');
$geocoder = $plugin->getGeocoder('google_geocoding_api');
$geocode = $geocoder->geocode($zip_code);

$view = Views::getView('local_pharmacies');
$view->setDisplay('block_1');
$exposed = (
  'field_geolocation_proximity-lat' => $geocode('location')('lat'), // No longer exists in 3.x
  'field_geolocation_proximity-lng' => $geocode('location')('lng'), // No longer exists in 3.x
  'field_geolocation_proximity' => "50",
);
$view->setExposedInput($exposed);
$view->preExecute();
$view->execute();

I updated to 8.x-3.7 because I plan to upgrade to D9 soon. The above is no longer working. I think because field_geolocation_proximity-lat and field_geolocation_proximity-lng no longer exist. I tried diving into the source as well as kinting form alters to figure out how to properly set the coordinates but I cannot figure it out. Any ideas?

8 – Setting geolocation LAT LNG exposed input programmatically

I’ve been using geolocation 8.x-1.12 for a while now. I have a REST route that gets a view with my exposed form and returns the results.

Previously I did:

$plugin = Drupal::service('plugin.manager.geolocation.geocoder');
$geocoder = $plugin->getGeocoder('google_geocoding_api');
$geocode = $geocoder->geocode($zip_code);

$view = Views::getView('local_pharmacies');
$view->setDisplay('block_1');
$exposed = (
  'field_geolocation_proximity-lat' => $geocode('location')('lat'), // No longer exists in 3.x
  'field_geolocation_proximity-lng' => $geocode('location')('lng'), // No longer exists in 3.x
  'field_geolocation_proximity' => "50",
);
$view->setExposedInput($exposed);
$view->preExecute();
$view->execute();

I updated to 8.x-3.7 because I plan to upgrade to D9 soon. The above is no longer working. I think because field_geolocation_proximity-lat and field_geolocation_proximity-lng no longer exist. I tried diving into the source as well as kinting form alters to figure out how to properly set the coordinates but I cannot figure it out. Any ideas?

9 – Creating a view with an exposed filter for “is not empty” where all results are shown by default

I’m creating a view. By default, I want all results shown, with an exposed filter for ‘has a value’ (aka is not empty) and ‘is empty’.

I cannot figure out how to make the exposed filter work for this. If I make the exposed filter on either ‘is empty’ or ‘is not empty’, it filters the values initially based on that section. I only want the exposed filter to take effect when the value is in the URL.

Can anyone point me how to do that?

7 – Taxonomy dynamic dependent exposed filters

I have a content type with two taxonomy term fields: Region and Country.

I created some nodes and entered values for those fields. I created a view with both the fields as exposed filters. When a region is selected, is there a way to only to shown in Country all the related terms as shown in the screenshot?

screenshot

The project page for the Views Reference Filter module says, at the bottom:

By default, the view receives the same arguments as the view being filtered. This can be changed in the filter settings.
Possible value for any argument:

  • the argument of the view being filtered
  • any string value
  • the value of any exposed filter of the view being filtered

The last option makes the exposed filter dependent on the other filter. This creates the functionality missing in the Views: dynamic dependent filters, i.e. when the value of the main filter is changed, the list of options of the dependent filter is updated via AJAX.

I couldn’t make it work. It looks like it works only with entity reference fields.

Views AJAX Dynamic Dependent Exposed Filters looks promising, but it’s using a lot of custom code that might be outdated.

Before I start to write custom code, may you suggest me any clean out-of-box idea?

7 – Taxonomy dynamic dependent exposed filters for Views

A Content Type contains two Taxonomy term fields

Region Taxonomy vocabulary has terms like e.g. Europe, Asia, etc.

Country vocab has terms like Germany, Japan, Australia, etc.

  1. Create list of nodes and give it Region and Country terms.
  2. Create a View with both term fields as Exposed Filters.
  3. When Selecting Region e.g. Europe, filter out results in the dropdown of Country, only to those terms that are set/related to nodes with Europe?

As seen in this screenshot, if we select Europe from all the continents, it filters out Countries only to European (so that means e.g. node with Germany term also has Europe term andd that’s how they are related?).

enter image description here

Research so far:

At the bottom of this module description https://www.drupal.org/project/entityreference_filter it says:

The last option makes the exposed filter dependent on the other filter. This creates the functionality missing in the Views: dynamic dependent filters, i.e. when the value of the main filter is changed, the list of options of the dependent filter is updated via AJAX.

But I couldn’t make it work and looks like it works ONLY with Entity Reference fields.

This article from 2012 http://bouteillenicolas.com/fr/blog-drupal/views-ajax-dynamic-dependent-exposed-filters looks promising, but it’s using a lot of custom code that might be outdated?

Before dipping into custom code hoping for any clean out-of-box ideas first? (for security purposes)

Thank you for your time.