Skip to content

Instantly share code, notes, and snippets.

const myTest = (string) => {console.log(string)};
/**
* Hide <select> and submit-button
*/
#views-exposed-form-filter-articles-page-1 .form-type-select {
display: none;
}
#views-exposed-form-filter-articles-page-1 .form-submit {
display: none;
}
(function ($) {
/**
* Set active class on Views AJAX filter
* on selected category
*/
Drupal.behaviors.exposedfilter_buttons = {
attach: function(context, settings) {
$('.filter-tab a').on('click', function(e) {
e.preventDefault();
popolo_custom.forms:
version: VERSION
css:
theme:
css/popolo_custom.theme.css: {}
popolo_custom.enable:
version: VERSION
js:
js/popolo_custom.js: {}
<?php
function popolo_custom_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
/**
* Apply the form_alter to a specific form #id
* the form #id can be found through inspecting the markup
*/
if($form['#id'] == 'views-exposed-form-filter-articles-page-1') {
/**
name: Popolo Custom
type: module
description: 'Example module for Drupal 8.'
package: Custom
version: 8.x
core: 8.x
@leanderlindahl
leanderlindahl / gist:8be5f9947e85c7e00acb
Created September 3, 2015 14:36
Wordpress Responsive YouTube embed
In your themes functions.php:
add_filter( 'embed_oembed_html', 'custom_oembed_filter', 10, 4 ) ;
function custom_oembed_filter($html, $url, $attr, $post_ID) {
$return = '<div class="video-container">'.$html.'</div>';
return $return;
}
In your themes css:
.video-container {
(function ($) {
/**
* Set active class on Views AJAX filter
* on selected category
*/
Drupal.behaviors.exposedfilter_buttons = {
attach: function(context, settings) {
$('.filter-tab a').on('click', function(e) {
e.preventDefault();
<?php
function exposedfilter_buttons_form_alter(&$form, &$form_state, $form_id) {
/**
* Manipulate output of Views Ajax Exposed filter
*/
if ($form['#id'] == 'views-exposed-form-exposed-filter-example-block') {
$form['#attached']['js'] = array(
drupal_get_path('module', 'exposedfilter_buttons') . '/js/exposedfilter_buttons.js',
);