By admin , 7 November, 2024 Create tab for views in user profile my_custom.links.task.yml: Tags tabs views
By admin , 7 November, 2024 Hide tab created by views /** * Implements hook_menu_local_tasks_alter(). */ function MYMODULE_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface $cacheability) { $current_user = \Drupal::currentUser(); if ($current_user->hasRole('administrator') || $current_user->hasRole( Tags tabs views
By admin , 26 October, 2024 Views query: do not show rows where column value is unique. /** * Implements hook_views_query_alter(). */ function MYMODULE_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { // Do not show rows where CID is unique. if ($view->id() === 'MYVIEW_default') { $where_clause = 'cid IN (SELECT cid FRO Tags views
By admin , 16 October, 2024 Twig tweak: render views block with views title {{ drupal_block('views_block:VIEWSNAME-block_1', {'label': true} ) }} Tags twig views
By admin , 13 September, 2024 Add secondary tab to user local tasks Needs minimum 2 subtabs! custom.links.task.yml: Tags tabs views
By admin , 31 July, 2024 Set view title programmatically /** * Implements hook_views_post_render(). */ function MYMODULE_views_post_render(ViewExecutable $view) { if ($view->element['#view_id'] === 'user_blog') { $title = 'test'; $view->setTitle($title); } } Tags views
By admin , 26 March, 2024 Render views block programmatically /** * Implements hook_ENTITY_TYPE_view(). */ function my_module_user_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { if ($display->getComponent('my_module')) { $view = Views::getView('my_module_block'); Tags block views render
By admin , 25 January, 2024 Delete view programmatically \Drupal::service('config.factory')->getEditable('views.view.VIEWNAME')->delete(); Tags views
By admin , 2 August, 2023 Views with photoswipe slides not scroll Needs to add view global css class "photoswipe-gallery" Tags photoswipe views
By admin , 28 July, 2023 Hide an exposed filter block if the view results are empty /** * Implements hook_views_pre_render(). */ function mymodule_views_pre_render(ViewExecutable $view) { if ($view->storage->id() == 'myview' && $view->current_display == 'block_1') { if (empty($view-> Tags views exposed form