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.
Inspired by : #2804323: Need a views group URL field
Currently Node has a dedicated field handler to provide the canonical URL to a node: \Drupal\node\Plugin\views\field\Path
The generic entity link handler currently doesn't have the option to return a raw URL, only formatted links. We should allow the generic handler to provide this data, and probably depreciate the node specific implementation.
Comment | File | Size | Author |
---|---|---|---|
#48 | 2810097-views-links-48.patch | 24.62 KB | larowlan |
#48 | interdiff-085e6d.txt | 1.05 KB | larowlan |
#39 | 2810097-39.patch | 24.73 KB | Lendude |
#38 | afterapplyingpatchrowenitylink.png | 189.66 KB | MeenakshiG |
#38 | beforepplyingpatchrawentitylink.png | 187.38 KB | MeenakshiG |
Comments
Comment #2
LendudeSo something like this.
Comment #3
rachel_norfolkI like this approach more
Comment #4
dawehnerWhat about using "output_url"?
I'm confused, this line looks just wrong. Its two times basically the same function call
Comment #5
Lendude@dawehner thanks as always.
4.1 Yeah that is better, changed
4.2 That was me being lazy and not wanting to add more data to the info array and forcibly reusing existing data, changed to hopefully make it more clear.
Comment #6
dawehnerShould we provide an update path here?
Comment #7
LendudeWell we are providing defaults here right? I don't know if missing settings are an issue for valid config.
And then we would just be back to the same discussion we were having at #2784233: Allow multiple vocabularies in the taxonomy filter and the issues resulting from #2459289: Boolean default values are not saved. We could use a post-update to update any existing config, but that still leaves us without a way to deal with newly imported/installed config.
So:
Unless we have a way to deal with all three types of outdated config, I don't think there is much point, and the default values should allow us to deal with missing config.
/rant off :)
Comment #8
dawehnerYeah you are right, we don't need one as long we just add new options. On the other hand, its nice to reduce the amount of random additions to config. An update makes it pretty clear, what caused the config change.
Comment #9
Lendude@dawehner yeah you're right of course.
So, update path and test for it.
Comment #10
dawehnerWhen we are in post update we can actually use entity api, can't we? I guess it doesn't really make a difference though.
Let's not override anything which is already there, you never know
Comment #11
Lendude1. Yeah, don't know, this works...
2. Fair enough.
Comment #12
dawehnerLet's see whether someone complains :)
Comment #13
rachel_norfolkWell, I’m certainly not going to complain!
Adding the issue in the Group project that sparked this issue when Lendude realised the best solution was to have the capability here.
Comment #14
catchWon't the node_path plugin still appear in the UI as a semi-duplicate here?
If that's the case, should we look at removing it from the UI, converting it in the update to the generic one, and also convert (in config presave) for default config so it never gets used unless someone's explicitly extended it?
Comment #15
Lendude@catch that sounds like a perfect way to do this.
Shot at this, probably needs additional test coverage though.
Comment #17
LendudeLets see what this does.
Comment #18
LendudeBleh this should have stayed removed. Lets see what THIS does...
Comment #19
jp.stacey CreditAttribution: jp.stacey at Magnetic Phield commentedTested as follows:
views_post_update_entity_link_url()
is never explicitly called anywhere to update existing views on 8.2.x=>8.3.x. Is it called by some kind of autodiscovery magic?Apart from the minor query #3 above, this looks great. Before/after screenshots attached for the testing done in #2.
Comment #20
Lendude@jp.stacey thanks for the review!
Yup hook_post_update_NAME is a less naming-conflict prone version of hook_update_N that also allows you to use any API.
Comment #21
jp.stacey CreditAttribution: jp.stacey at Magnetic Phield commented@lendude then that all checks out fine. Looks good to me (see screenshots).
Moving to RTBC.
Comment #23
alexpottThis is a strange label. I couldn't guess what it does from the name. Maybe
output_url_as_text
? I'm not sure what is best here.Nice that the UI does this.
Really nice to see module installs being coped with ++
Comment #24
alexpottAlso we need a CR and
This needs to follow the new https://www.drupal.org/node/2856615. We need to flesh out how a whole class is example - perhaps this issue can provide the example!
Comment #25
LendudeMy attempt at a CR: https://www.drupal.org/node/2857891
Rerolled for #2776975: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase, so no interdiff
#23.1, can't really think of anything better either, so lets go with that.
Attempt at adding the right deprecated @trigger_error.
Comment #27
LendudeOk so using entity_test in updates is annoying. Lets see what this does.
Comment #28
rachel_norfolkAdding some novice tasks for DrupalDevDays that will make this issue easier to approve.
Update the issue summary
Embed before and after screenshots in the issue summary
Comment #29
rachel_norfolkadding some tags for Mentored Core Sprint, Baltimore 2017.
Comment #30
sk33lz CreditAttribution: sk33lz at Zivtech commentedI've reviewed #27 in the same method that #19 reviewed the patch. #27 applies cleanly against 8.4.x with the new options for "Use absolute link (begins with "http://")" and "Output the URL as text". This should be RTBC if the CR is good to go.
Comment #32
rachel_norfolkI *think* this might have been a bit of a spurious error. Let’s just retest before thinking otherwise...
Comment #33
Lenduderandom fail, back to RTBC
Comment #34
maxplus CreditAttribution: maxplus commentedHi,
I patched my Drupal 8.3.2 successful but the only thing that is not working is translation.
For me the taxonomy term link is always displayed in my base language and is not displayed in the translated version when I switch the site to another language.
Comment #36
LendudePathPluginTest is now a BrowserTestBase test (yay!), so it's in a new place. Also #34 sounds like something we need to look at.
Comment #38
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commentedAdding the patch provides new options on an entity view's field "Link to [entity type]",i.e. two additional check boxes
1) Output the URL as text
2) Use absolute link (begins with "http://")
which allow views to provide the canonical entity URL of all entities, not just nodes.
here are the screenshots of before applying patch and after applying patch .
Comment #39
LendudeNeeded a reroll, so here we go.
Looked into #34 and indeed when working with translated content, this returns the URL to the original content. But this is also what EntityLink currently does, it has nothing to do with the new functionality, so that seems like a related bug to me, but not something we need to solve here.
Same goes for the Path plugin, that also doesn't return the correct URL to the translated content, so we are not introducing any new bugs here either (but with this in, we don't need to solve this in two different places!).
Comment #40
rachel_norfolkJust run through this again and tested that we can, indeed, now add links to entities that appear just as the text url of the entity.
Agreed that the translation thing is a bug but not necessarily in the scope of this issue as the same bug appears elsewhere. Indeed, it does make sense that this patch will make it easier to create a follow on issue to address the translation bug.
Assuming automated tests pass soon, I’m inclined to mark as RTBC when that happens.
BTW - what is stopping this going into 8.4?
Comment #42
rachel_norfolkTest fails looked like the db had gone away?? Retest...
Comment #43
LendudeThis is the issue with the translation problems #2877994: Entity Links fields does not have translation support.
It's a feature and we are in alpha for 8.4.x, so features go into 8.5.x. When its in there we can see if core committers want to backport.
Comment #44
rachel_norfolkYes, thought so. Was just a random dB fail
Comment #46
LendudeKnown random fail #2902191: Determine cause and fix random fail in \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testBlocks
Comment #47
larowlanLooks good, couple of minor observations that could be addressed if we have to reroll - more about complexity/readability than actual changes.
Retesting as last patch was one month ago
any reason not to just
return $this->getURl...
?Avoids both the else and the $text variable and makes the code easier to follow as reduces cyclic complexity
We could use
->toUrl($template)->setAbsolute($this->options['absolute'])
here and avoid the magic array keys (yes they are Drupal's speciality I know)Comment #48
larowlanFixed my own nits
Comment #49
Lendude@larowlan thanks for that! Tweaks look good.
Comment #50
catchOnly one comment. We should probably add a trigger_error(... E_USER_DEPRECATED) here, however it's not deprecated as such until the upgrade path has run.
Opened a follow-up for this here #2913850: Trigger E_USER_DEPRECATED from config entity presave bc layers
Committed f1aa6b3 and pushed to 8.5.x. Thanks!