-
Notifications
You must be signed in to change notification settings - Fork 51
Fix url template for custom content types #2002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…0' into tv4g1-issue1996-fix-url-template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works as described ✅
However, it is a bit disorienting for the URL scheme to change without telling the user. Especially as it's hidden in a vertical tabs so on editing you would only notice if you open it up.
Instead, perhaps we should just add some more tokens:
- [TripalEntityType__term_name]
- [TripalEntityType__term_accession]
- [TripalEntityType__machine_name]
Then the URL schema can be [TripalEntityType__term_name]/[TripalEntity__entity_id] right off the bat without any worry of it not existing yet and no need to change it.
This would be done by adding the tokens like this: https://github.com/tripal/tripal/blob/4.x/tripal/src/Entity/TripalEntityType.php#L550-L558
And then updating the parser to handle theme here: https://github.com/tripal/tripal/blob/4.x/tripal/src/Services/TripalTokenParser.php#L222-L234
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope you're ok with me making a few changes @dsenalik? If not, feel free to revert or change :-)
Specifically, I
- fixed an inconsistency between
[TripalBundle__bundle_id]and[TripalEntityType__label]which both refer to TripalContent Type and thus should use the same naming convention. See commit b9ab7b1 - Expanded descriptions to make each token more clear. The
[TripalBundle__bundle_id]token is actually the machine name I referred to. I'm guessing the difference was not clear because we often use the the term name as the content type label. See my screenshots below to see the difference. - Added a
[TripalEntityType__term_label]token to be the cvterm.name / term name that we intended to be included in the default token. - Moved the new tokens added by this PR out of the 'include id' if block since they are not IDs and thus should be available for use in the title.
Now when I test creating a new content type I see the new default URL template (shown here on edit since I didn't save my create screenshot 🤦 )
And when I create a primer page, I see the token is replaced properly:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did notice another issue though 🙈 I don't think this is new to this PR but it was aggravated by it. Specifically, if you try to create a new content type right now, the title format will fail validation. Technically that is because it has now gotten too long but more problematically, it is because we have no fields yet and therefore the default title pattern just includes all non-field tokens which A) is too long and B) is not unique 🙈 🫢
The reason I did that, keep them in the |
Ahhhh... I see. But they should be available 🙈 It sounds like we need to create a new issue for the title format when there are no fields. For now, I can add them back into an if block with a todo to remove once the title format issue is resolved. Sound good? |
|
That would be okay. Or alternatively we could remove the new tokens entirely for now, and add them back with a title fix. |
|
Well, you worked on the descriptions, so let's keep them |
We need the term_label token. The original bundle_id token you used is the machine name not the term. That's why I fixed the descriptions ;-p Ok, I will add the commit and make the new issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
It is working as desired. |
|
Thanks for the confirmation @dsenalik and for all the work on this! |
Bug Fix
Closes #1996
Depends on #2001 (merged)
Tripal Version: 4.x
Description
The current default URL template
[type]/[TripalEntity__entity_id]is not valid when you create a new custom content type.This PR does two things
[TripalBundle__bundle_id]/[TripalEntity__entity_id], which will now work as expected.[TripalEntityType__term_namespace]and[TripalEntityType__term_accession]Testing?
oligonucleotide_primer/2