Skip to content

Instantly share code, notes, and snippets.

View tanmayk's full-sized avatar

Tanmay Khedekar tanmayk

  • Opensource Seed
  • India
View GitHub Profile
protected function defineOptions() {
$options = parent::defineOptions();
$options['height'] = array('default' => '354');
return $options;
}
class Scroller extends StylePluginBase {
* @ViewsStyle(
* id = "scroller",
* title = @Translation("Scroller"),
* help = @Translation("Render a listing of view data."),
* theme = "views_view_scroller",
* display_types = { "normal" }
* )
<?php
/**
* @file
* Definition of Drupal\my_scroller\Plugin\views\style\Scroller.
*/
namespace Drupal\my_scroller\Plugin\views\style;
use Drupal\core\form\FormStateInterface;
name: My Style
type: module
description: 'Provides a views display style for listings.'
package: Views
core: '8.x'
dependencies:
- views
/**
* Implements hook_field_access().
* Check if user has access for the field.
*/
function MYMODULE_field_access($op, $field, $entity_type, $entity, $account) {
if ($entity_type == 'user') {
switch ($op) {
case 'view':
global $user;
// Implement you access logic here for each field.
/**
* Implements hook_user_insert().
* Add default privacy settings.
*/
function MYMODULE_user_insert(&$edit, $account, $category) {
// Add default privacy settings into users.data
$instances = field_info_instances('user', 'user');
$field_settings = array();
foreach ($instances as $field_name => $field_info) {
// Lets make it PUBLIC by default.
/**
* Privacy settings form for user.
*/
function privacy_settings_form_callback($form, &$form_state) {
global $user;
$form = array();
$options = array(0 => 'Public', 1 => 'Friends', 2 => 'Private');
$instances = field_info_instances('user', 'user');
foreach ($instances as $field_name => $field_info) {
$form[$field_name] = array(
/**
* Privacy level: Public.
* Field can be viewed by all.
*/
define('CORE_SECURITY_PRIVACY_PUBLIC', 0);
/**
* Privacy level: Friends only.
* Field can be viewed by only friends.
*/
function example_dependent_options($key) {
$plakalar = array(1, 2); // These are keys from parent dropdown.
$iller = array(
'1' => array(
'1' => 'Aladağ'
),
'2' => array(
'5' => 'Aşkale')