default sort on `many_many` relation table isn't clearly documented
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 35/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- php
调研方向
Search the developer documentation for the many_many relation and default_sort configuration described in the issue. Document that sorting uses the related TaxonomyTerm by default and explain how to configure sorting on the through relation, using the provided BlogPostTaxonomyTerm example. Done means a newcomer can find and understand the required configuration.
由索引模型根据 Issue 内容生成。
描述
Affected Version
5.0.0
Description
I have a BlogPost DataObject that has many_many relation with TaxonomyTerm DataObject through BlogPostTaxonomyTerm as below:
private static array $many_many = [
'Terms' => [
'through' => BlogPostTaxonomyTerm::class,
'from' => 'Parent',
'to' => 'TaxonomyTerm',
],
];
There is a Sort field on the TaxonomyTerm DataObject and a separate Sort field on the many_many through relation DataObject BlogPostTaxonomyTerm.
I want to sort the linked TaxonomyTerms on the BlogPost based on the Sort value on the BlogPostTaxonomyTerm table. However, I am not able to do that. The Sorting result is always determined by the Sort value on the TaxonomyTerm DataObject instead.
Here is an example, I have the following fixture file for unit test:
SilverStripe\Taxonomy\TaxonomyTerm:
term1:
Name: term1
Sort: 1
term2:
Name: term2
Sort: 2
term3:
Name: term3
Sort: 3
App\Pages\BlogPost:
page1:
Title: 'Blog Post 1'
PublishDate: '2023-06-20 15:55:50'
App\Taxonomy\ThroughRelations\BlogPostTaxonomyTerm:
blogPostTerm1:
Parent: =>App\Pages\BlogPost.page1
TaxonomyTerm: =>SilverStripe\Taxonomy\TaxonomyTerm.term3
Sort: 1
blogPostTerm2:
Parent: =>App\Pages\BlogPost.page1
TaxonomyTerm: =>SilverStripe\Taxonomy\TaxonomyTerm.term2
Sort: 2
blogPostTerm3:
Parent: =>App\Pages\BlogPost.page1
TaxonomyTerm: =>SilverStripe\Taxonomy\TaxonomyTerm.term1
Sort: 3
And I want to test the first term of the App\Pages\BlogPost.page1.
The expected result is the first term should be "term3", however the actual first term is "term1".
After I add the following config to the BlogPostTaxonomyTerm many_many relation, the Sorting works as expected.
private static string $default_sort = '"BlogPostTaxonomyTerm"."Sort"';
- 主要语言
- 没有语言数据
- 星标
- 7
- 派生
- 76
- 平均合并
- 1 小时 48 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
silverstripe/developer-docs 的其他 Issue
-
6.0.0 changelog: DBField formatters on array getters now render empty可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
silverstripe/developer-docs#912 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
silverstripe/developer-docs#911 ·
-
Read-only replicas: config key is rule_patterns_must_use_primary_db, not must_use_primary_db_rules未关闭affects/v6 complexity/low impact/low type/docs
难度 1/5 1 小时以内 新手友好度 92/100
silverstripe/developer-docs#909 · 1 条评论 ·
-
affects/v6 complexity/low impact/low type/docs
难度 2/5 1-3 小时 新手友好度 88/100
silverstripe/developer-docs#908 · 1 条评论 ·
-
affects/v5 affects/v6 complexity/low impact/low type/docs
难度 1/5 1 小时以内 新手友好度 90/100
silverstripe/developer-docs#907 · 1 条评论 ·
查看 silverstripe/developer-docs 的全部 Issue
相似的 Issue
-
License未关闭
难度 1/5 1 小时以内 新手友好度 65/100
-
documentation good first issue
难度 1/5 1 小时以内 新手友好度 85/100
ysb3996-blip/oops#51 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 25 天内回复
-
enhancement
难度 1/5 1 小时以内 新手友好度 78/100
-
good first issue
难度 1/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复