Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Patterns are not working when you choose to only apply the pattern to specific content types. Opening a url with the given pattern is resulting in an exception;
Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. in Drupal\Core\Executable\ExecutablePluginBase->getContextDefinition() (line 184 of core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php).
Drupal\Core\Executable\ExecutablePluginBase->getContext(NULL) (Line: 116)
Drupal\Core\Executable\ExecutablePluginBase->getContextValue(NULL) (Line: 91)
Drupal\Core\Entity\Plugin\Condition\EntityBundle->evaluate() (Line: 77)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 411)
Drupal\view_mode_page\Entity\ViewmodepagePattern->applies(Object) (Line: 107)
Drupal\view_mode_page\PathProcessor\DynamicPathProcessor->processInbound('/profile/research', Object) (Line: 70)
Drupal\Core\PathProcessor\PathProcessorManager->processInbound('/profile/research', Object) (Line: 138)
Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 134)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- Add a view mode pattern for entity type 'content', at least one selected content type (but not all) and a language. E.g. pattern '/%/research'.
- Go to the url alias with the given pattern. E.g. '/profile/research'.
Proposed resolution
The node should be rendered in the given view mode.
Comments
Comment #2
Rik Wijnen CreditAttribution: Rik Wijnen at Maastricht University commentedComment #3
Rik Wijnen CreditAttribution: Rik Wijnen at Maastricht University commentedThis problem is caused by the bug reported for CTools in https://www.drupal.org/project/ctools/issues/3300682
After applying the path (https://www.drupal.org/files/issues/2022-08-03/3300682-50.patch) the problem is resolved.
Comment #4
asila96 CreditAttribution: asila96 commentedVerifying that the answer in #3 works for me.