有什么方法可以在 Prismic 中创建嵌套的可重复内容吗?
Is there any way to create nested repeatable content in Prismic?
我的用例如下:
我的页面上有一个测验,测验有 N sections/questions 和 M 个可能的答案。尽管问题和答案都包含多个字段(例如每个答案的图像、标题和颜色)。我正在使用切片并将问题放在可重复区域中,但您不能在可重复区域中设置组字段。
还有其他方法吗? Wordpress 高级自定义字段可以轻松解决这个问题。
用切片建模应该没有问题。你会得到你的切片,就像你在问题中描述的那样,它是不可重复字段中的图像等,而答案是可重复字段中的图像。
然后在文档写作部分,您将为每个问题调用一个切片,并为每个答案调用 select 'Add a new element to group'。
这是您 json 内容类型结构的示例:
{
"Main" : {
"home_title" : {
"type" : "StructuredText",
"config" : {
"single" : "heading1, heading2, heading3, heading4, heading5, heading6",
"label" : "home title",
"placeholder" : "Home"
}
},
"body" : {
"type" : "Slices",
"fieldset" : "Slice zone",
"config" : {
"labels" : {
"mcq" : [ {
"name" : "...",
"display" : ""
} ]
},
"choices" : {
"Question" : {
"type" : "Slice",
"fieldset" : "Question",
"description" : "Question and answers",
"icon" : "help",
"display" : "list",
"non-repeat" : {
"question" : {
"type" : "StructuredText",
"config" : {
"single" : "heading4",
"label" : "question"
}
},
"code_snippet" : {
"type" : "StructuredText",
"config" : {
"multi" : "preformatted",
"label" : "code snippet"
}
},
"correct_answer" : {
"type" : "Number",
"config" : {
"label" : "Correct answer"
}
},
"answer_explanatrion" : {
"type" : "StructuredText",
"config" : {
"multi" : "paragraph, preformatted, heading3, heading4, heading5, heading6, strong, em, hyperlink, image, embed, list-item, o-list-item, o-list-item",
"label" : "Answer explanation"
}
}
},
"repeat" : {
"answers" : {
"type" : "StructuredText",
"config" : {
"multi" : "paragraph, preformatted, strong, em, embed",
"label" : "Answers"
}
}
}
}
}
}
}
}
}
我的用例如下:
我的页面上有一个测验,测验有 N sections/questions 和 M 个可能的答案。尽管问题和答案都包含多个字段(例如每个答案的图像、标题和颜色)。我正在使用切片并将问题放在可重复区域中,但您不能在可重复区域中设置组字段。
还有其他方法吗? Wordpress 高级自定义字段可以轻松解决这个问题。
用切片建模应该没有问题。你会得到你的切片,就像你在问题中描述的那样,它是不可重复字段中的图像等,而答案是可重复字段中的图像。
然后在文档写作部分,您将为每个问题调用一个切片,并为每个答案调用 select 'Add a new element to group'。
这是您 json 内容类型结构的示例:
{
"Main" : {
"home_title" : {
"type" : "StructuredText",
"config" : {
"single" : "heading1, heading2, heading3, heading4, heading5, heading6",
"label" : "home title",
"placeholder" : "Home"
}
},
"body" : {
"type" : "Slices",
"fieldset" : "Slice zone",
"config" : {
"labels" : {
"mcq" : [ {
"name" : "...",
"display" : ""
} ]
},
"choices" : {
"Question" : {
"type" : "Slice",
"fieldset" : "Question",
"description" : "Question and answers",
"icon" : "help",
"display" : "list",
"non-repeat" : {
"question" : {
"type" : "StructuredText",
"config" : {
"single" : "heading4",
"label" : "question"
}
},
"code_snippet" : {
"type" : "StructuredText",
"config" : {
"multi" : "preformatted",
"label" : "code snippet"
}
},
"correct_answer" : {
"type" : "Number",
"config" : {
"label" : "Correct answer"
}
},
"answer_explanatrion" : {
"type" : "StructuredText",
"config" : {
"multi" : "paragraph, preformatted, heading3, heading4, heading5, heading6, strong, em, hyperlink, image, embed, list-item, o-list-item, o-list-item",
"label" : "Answer explanation"
}
}
},
"repeat" : {
"answers" : {
"type" : "StructuredText",
"config" : {
"multi" : "paragraph, preformatted, strong, em, embed",
"label" : "Answers"
}
}
}
}
}
}
}
}
}