[英]Drupal 7 Views : How to reuse one view for multiple fields OR how to let user select which field view displays?
My Task: I have content type which have 100+ different mostly numeric fields (big questionnaire for NGO with yearly reports). 我的任务:我的内容类型具有100多个不同的数字字段(针对具有年度报告的NGO的大型问卷调查)。 For one field I can use Views module to let user select which reports include (for example one year) and display it as nice graph (using for example Views+Charts).
对于一个字段,我可以使用“视图”模块让用户选择包括哪些报告(例如一年),并将其显示为漂亮的图形(例如使用“视图+图表”)。 I would have to define about 100+ nearly identical views, which differs only by what field data they use.
我将必须定义大约100多个几乎完全相同的视图,这些视图仅因它们使用的字段数据不同而不同。
My Question: Is there any way how to reuse one view definition and just change data from which field id display? 我的问题:有什么方法可以重用一个视图定义并仅更改显示哪个字段ID的数据?
Solutions so far: I found two not really good solutions: 到目前为止的解决方案:我发现了两个不太好的解决方案:
I suggest writing your own Views field display plugin! 我建议编写自己的“视图”字段显示插件! This is actually all documented within the Views module folder: views/docs/views.api.php.
实际上,所有这些都记录在“视图”模块文件夹中:views / docs / views.api.php。 Depending on your fields I'm not sure how you would exactly connect the data to the view.
根据您的字段,我不确定如何将数据准确连接到视图。
Another alternative would be to just use a PHP Code field, and figure out a way to programmatically display the data from the field you wanted. 另一种选择是仅使用PHP Code字段,并找到一种以编程方式显示所需字段中数据的方法。 The downside to this is that you wont be able to use that field to sort/search on with any filters as far as I know.
不利的一面是,据我所知,您将无法使用该字段对任何过滤器进行排序/搜索。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.