Timeline for Add cache context to altered links
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 16, 2018 at 14:10 | comment | added | Alfred Armstrong | Sorry @Sebastian I can see why it might work but I can't say whether it's the best method or not. It seems a little ooky. | |
Jul 16, 2018 at 13:49 | comment | added | Sebastian | I haven't thought about this. Can you tell me whether setting the cache tags as I did is correct? I don't understand why it works when adding $renderer = \Drupal::service('renderer'); $renderer->addCacheableDependency($build, \Drupal\user\Entity\User::load(\Drupal::currentUser()->id())); | |
Jul 16, 2018 at 13:42 | comment | added | Alfred Armstrong | I'd solve that using Javascript. Your script can use settings embedded into the page. But that's really a whole other post. | |
Jul 16, 2018 at 13:15 | comment | added | Sebastian | Because I want to open a modal dialog in some cases. Changing the content would work, but that's not what I want to do. The changes that I described in the Updated post seem to work. But I don't know wheter I'm using caching correctly. | |
Jul 16, 2018 at 10:00 | comment | added | Alfred Armstrong | I still don't understand why you want to change /links/ per role, as opposed to the usual approach, which is to change the page content per role, adding or removing elements as appropriate. The latter approach is simpler and more natural. | |
Jul 15, 2018 at 14:55 | comment | added | Sebastian | I updated the question. Would be great if you can have a look. | |
Jul 13, 2018 at 16:10 | comment | added | Alfred Armstrong | Sounds complicated. Rather than get into a long thread here, maybe add some more context to the question explaining what you are trying to achieve and why it needs to be different per role? | |
Jul 13, 2018 at 15:10 | comment | added | Sebastian | Currently I have 3 types of links that I modify: 1. menu links inserted by views and created through the ui. 2. links placed by myself using pseudo fields. 3. links by other modules | |
Jul 13, 2018 at 15:07 | comment | added | Alfred Armstrong | Without know more about how the site is built it's hard to advise. There's lots of ways to solve problems like this. Perhaps start earlier in the page creation process where the links /can/ be cached per role. What's outputting them? | |
Jul 13, 2018 at 14:43 | comment | added | Sebastian | But this means that all links would be ajaxified by default and that I have also to pass the original url to the intermediate function called via ajax. I'll try. But sounds quite complex. There is no way to add cache information to the links? | |
Jul 13, 2018 at 14:17 | comment | added | Alfred Armstrong | You can still change the links to use AJAX using your current method, just not change anything per role. The function called via AJAX can do different things based on user role. | |
Jul 13, 2018 at 14:01 | comment | added | Sebastian | Nice idea, but I'm also changing the links to use ajax $variables['options']['attributes']['class'][] = 'use-ajax'; I don't see a possibility to do this in an intermediate controller ? I'll update my question. | |
Jul 13, 2018 at 13:49 | history | answered | Alfred Armstrong | CC BY-SA 4.0 |